Skip to content

Instantly share code, notes, and snippets.

View maxpromer's full-sized avatar

Max maxpromer

View GitHub Profile
#include <driver/i2s.h>
#include <math.h>
// ─── กำหนดขา I2S ───────────────────────────────────────
#define I2S_BCK_PIN 26 // Bit Clock
#define I2S_WS_PIN 25 // Word Select (LRCK)
#define I2S_DATA_PIN 22 // Data Out → DIN ของโมดูล
// ─── พารามิเตอร์เสียง ────────────────────────────────────
#define SAMPLE_RATE 44100
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
// ─── กำหนดขา I2S ───────────────────────────────────────
#define I2S_BCK_PIN 26
#define I2S_WS_PIN 25
#define I2S_DATA_PIN 22
// ─── ข้อมูล Wi-Fi ────────────────────────────────────────
#define DE_RE_PIN 4
#define MODE_SEND HIGH
#define MODE_RECV LOW
void setup() {
pinMode(DE_RE_PIN, OUTPUT);
digitalWrite(DE_RE_PIN, MODE_RECV);
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 16, 17); // Rx, Tx
@maxpromer
maxpromer / cam_ai.py
Created November 16, 2025 17:22
Raspberry Pi Camera Module 3 image classification with MobileNet
from picamera2 import Picamera2
import cv2
import numpy as np
# Load the TensorFlow model (frozen graph + pbtxt)
model = cv2.dnn.readNetFromTensorflow(
"frozen_inference_graph.pb",
"ssd_mobilenet_v1_coco_2017_11_17.pbtxt"
)
@maxpromer
maxpromer / cam_opencv_resize_and_draw.py
Created November 16, 2025 17:21
Raspberry Pi Camera Module 3 image editor by OpenCV
from picamera2 import Picamera2
import cv2
picam2 = Picamera2()
# Set up Auto Focus
config = picam2.create_preview_configuration()
picam2.configure(config)
picam2.start()
@maxpromer
maxpromer / cam_autofocus_test.py
Created November 16, 2025 17:19
Raspberry Pi Camera Module 3 autofocus settings with Python
from picamera2 import Picamera2
import cv2
picam2 = Picamera2()
# Set up Auto Focus
config = picam2.create_preview_configuration()
picam2.configure(config)
picam2.start()
@maxpromer
maxpromer / cam_test.py
Created November 16, 2025 17:18
Raspberry Pi Camera Module 3 image preview with Python
from picamera2 import Picamera2
import cv2
# Initialize the camera
picam2 = Picamera2()
picam2.start()
try:
while True:
# Capture frame from the camera
#include <Arduino.h>
#include <Wire.h>
#include <IOXESP32_4-20mA_Receiver.h>
Receiver4_20 sensor(&Wire, 0x45); // Default 0x45
void setup() {
Serial.begin(115200);
Wire.begin(); // Start I2C
#include <TinkerC6.h> // เรียกใช้ไลบรารี่ Tinker C6
void setup() {
Serial.begin(115200); // เริ่มใช้งาน Serial Monitor
TinkerC6.Power.enable12V(); // สั่งเปิดใช้ไฟเลี้ยง 12V
}
void loop() {
float mA = TinkerC6.Analog.getCurrent() + 0.08; // อ่านค่าช่อง 4-20mA เก็บลงตัวแปร mA
float percent = (mA - 4.0) * 100.0 / (20.0 - 4.0);
float temp = 0, humi = 0;
void readXY_MD02() {
uint8_t buff[] = {
0x01, // Devices Address
0x04, // Function code
0x00, // Start Address HIGH
0x01, // Start Address LOW
0x00, // Quantity HIGH
0x02, // Quantity LOW