Skip to content

Instantly share code, notes, and snippets.

View fxprime's full-sized avatar

Modulemore ขายอุปกรณ์ Arduino, เครื่องมือช่าง, raspberry pi, สอน ROS fxprime

View GitHub Profile
#pragma once
// html_page.h
// Place this file in the SAME folder as ESP32_PCA9685_ServoWS.ino
// Arduino's prototype-generator only scans .ino files, so JavaScript
// "function" keywords inside this string won't cause compile errors.
const char INDEX_HTML[] PROGMEM = R"HTMLEOF(
<!DOCTYPE html>
<html lang="en">
<head>
/*
* ESP32 + PCA9685 Servo Controller with WebSocket GUI
* =====================================================
* Controls servos 0-3 on PCA9685 via a browser-based dashboard.
*
* FOLDER STRUCTURE (both files must be in the same sketch folder):
* ESP32_PCA9685_ServoWS/
* ESP32_PCA9685_ServoWS.ino ← this file
* html_page.h ← HTML dashboard (included below)
*
#!/usr/bin/env python3
"""
RS-LDO-N01-1 Fluorescence Dissolved Oxygen Sensor
Raspberry Pi — USB to RS485 reader
Default: address 0x01, baud 4800
"""
import serial
import struct
import time
@fxprime
fxprime / DO_sensor_auto_scanner.ino
Created April 21, 2026 17:25
RS-LDO-N01-1 — Auto Scanner
/* -------------------------------------------------------------------------- */
/* RS-LDO-N01-1 — Auto Scanner (address + baud rate) */
/* -------------------------------------------------------------------------- */
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <ModbusMaster.h>
EspSoftwareSerial::UART mySerial;
/**
PS2 Wireless Controller Data Streaming
Modified for web visualization with structured data format
Messages prefixed with:
- DATA: Controller state data
- LOG: User information
- ERROR: Error messages
- WARN: Warning messages
**/
/*
ESP8266 Board Tester (I/O + WiFi)
- Arduino core for ESP8266
- Features:
* Serial menu for quick tests
* Simple web UI to view digital inputs & ADC, toggle outputs
* WiFi scan, connect (via Serial), start SoftAP
Pin notes:
- Be careful with GPIO0, GPIO2, GPIO15: they affect boot. Use them carefully.
- A0 is ADC (analogRead)
#include <Arduino.h>
#include "HX711.h"
#include <Preferences.h>
// HX711 circuit wiring
#define LOADCELL_DOUT_PIN 27
#define LOADCELL_SCK_PIN 26
HX711 scale;
Preferences preferences;
@fxprime
fxprime / TCS3200_esp32.ino
Created July 1, 2025 17:03
ตัวอย่างโค้ดสำหรับการใช้งาน TCS3200 Sensor บน ESP32 พร้อมการปรับเทียบเซ็นเซอร์เพื่อให้สามารถอ่านค่าสีได้อย่างแม่นยำ
/**
* ตัวอย่างโค้ดสำหรับการใช้งาน TCS3200 Sensor บน ESP32
* พร้อมการปรับเทียบเซ็นเซอร์เพื่อให้สามารถอ่านค่าสีได้อย่างแม่นยำ
*
* วิธีการต่อสาย:
* | ESP32 Pin | TCS3200 Pin |
* |------------|-------------|
* | 3.3v | Vcc |
* | GND | GND |
* | 3.3v | LED |
@fxprime
fxprime / sensor.h
Created July 1, 2025 13:41
tcs3200 ported to PTBOT need test
#define TCS34725_ADDRESS 0x29
#define TCS34725_COMMAND_BIT 0x80
SoftI2C SoftWire1(25, 26);
SoftI2C SoftWire2(27, 14);
// Assume S0 goes HIGH, S1 goes LOW
#define S2 26 /*Define S2 Pin Number of ESP32*/
#define S3 25 /*Define S3 Pin Number of ESP32*/
@fxprime
fxprime / testTCS3200_esp32.ino
Created July 1, 2025 13:23
testTCS3200 esp32
#include <Arduino.h>
#define S2 26 /*Define S2 Pin Number of ESP32*/
#define S3 25 /*Define S3 Pin Number of ESP32*/
#define sensorOut 14 /*Define Sensor Output Pin Number of ESP32*/
/*Define int variables*/
int Red = 0;
int Green = 0;
int Blue = 0;