Skip to content

Instantly share code, notes, and snippets.

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
// ---------------------------------------------------
// กำหนดขา SDA และ SCL ใหม่ตรงนี้ได้ตามใจชอบเลยครับ
// ตัวอย่างนี้ผมสมมติให้ใช้ GPIO 21 และ GPIO 22
// ---------------------------------------------------
#define CUSTOM_SDA 21
#define CUSTOM_SCL 22
#include <Wire.h>
#include <SparkFun_VL53L5CX_Library.h> // ต้องติดตั้งไลบรารีนี้ก่อน
// กำหนดขา I2C สำหรับ ESP32
#define SDA_PIN 21
#define SCL_PIN 22
// สร้างออบเจกต์สำหรับเซ็นเซอร์
SparkFun_VL53L5CX myImager;
VL53L5CX_ResultsData measurementData; // ตัวแปรเก็บค่าที่อ่านได้
// A basic everyday NeoPixel strip test program.
// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
// connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
/************************************************************
* @file Basic_I2C.ino
* @author 7Semi
* @date 2025-07-09
* @version 1.0.1
* @license MIT
*
* @brief Example sketch to demonstrate BME690_7semi library in I2C mode.
*
* This sketch initializes the BME690 sensor using I2C interface,
/************************************************************
* @file Basic_SPI.ino
* @author 7Semi
* @date 2025-07-09
* @version 1.0.1
* @license MIT
*
* @brief Example sketch to demonstrate BME690_7semi library in SPI mode.
*
* This sketch initializes the BME690 sensor using the SPI interface,
#include <SPI.h>
#include <SD.h>
// --- กำหนดขา Input ---
const int inputPins[] = {1, 3, 4, 5};
const int numInputs = 4;
// --- กำหนดขา Output (Relay) ---
const int relayPins[] = {6, 7, 15, 16};
const int numRelays = 4;
/*
ENS160 eCO2 Sensor with AHT21 T/H Sensor
ens160.ino
Reads TVOC/eCO2/AQI and compensates with AHT21 T/RH
Requires SparkFun_ENS160 Library
Requires Adafruit_AHTX0 Library
Uses Seeeduino XIAO ESP32-S3, adjust pins for other ESP32
DroneBot Workshop 2025
https://dronebotworkshop.com
//ESP32 version 2.0.17
#include <Arduino_GFX_Library.h>
#include <Wire.h>
#include "TCA9554.h"
#define GFX_BL 6 // default backlight pin
#define SPI_MISO 2
#define SPI_MOSI 1
#include <SPI.h>
#include <TFT_eSPI.h> // เรียกใช้ไลบรารีจอ
#include <Wire.h> // สำหรับ I2C ของ SHT3x
TFT_eSPI tft = TFT_eSPI();
// กำหนดขาเซ็นเซอร์
#define PMS_RX_PIN 16
#define PMS_TX_PIN 17
#define SHT3X_SDA 27
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <SPI.h>
#include <TFT_eSPI.h>
#include <math.h>
Adafruit_BME280 bme;
TFT_eSPI tft = TFT_eSPI();