Posts

Showing posts with the label Arduino framework

WebServer on ESP32-C5-WIFI6-KIT-N16R8, to control onboard RGB LED (Arduino Framework)

Image
Exercises (Arduino Framework) run on Waveshare ESP32-C5-WIFI6-KIT-N16R8 , act as WiFi Access Point, and setup simple WebServer to control onboard RGB LED. ESP32C5_WiFi_AP_WebServer , act as Access Point and setup a simple WebServer. /* Exercise run on Waveshare ESP32-C5-WIFI6-KIT-N16R8 Setup WiFi AP, and a simple WebServer. details: https://coxxect.blogspot.com/2026/03/webserver-on-esp32-c5-wifi6-kit-n16r8.html Ref: Arduino ESP32 Wi-Fi API https://docs.espressif.com/projects/arduino-esp32/en/latest/api/wifi.html Github: espressif/arduino-esp32/libraries/WebServer/ https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer */ #include <WiFi.h> #include <WebServer.h> // Built-in lightweight HTTP server const char* ssid = "ESP32-C5_AP"; const char* password = "12345678"; // Create a web server on port 80 WebServer server(80); void handleRoot() { server.send(200, "text/html", "<h1>Hello from ESP32-C5 W...

Waveshare ESP32-C5-WIFI6-KIT-N16R8 to control onboard RGB LED using Adafruit_NeoPixel library, Arduino framework.

Image
Exercise run on Waveshare ESP32-C5-WIFI6-KIT-N16R8 to control onboard RGB LED using Adafruit_NeoPixel library. ESP32C5_RGB.ino /* Exercise run on Waveshare ESP32-C5-WIFI6-KIT-N16R8 to control onboard RGB LED using Adafruit_NeoPixel library. The onboard RGB on Waveshare ESP32-C5-WIFI6-KIT-N16R8 is connected to GPIO27. https://coxxect.blogspot.com/2026/02/waveshare-esp32-c5-wifi6-kit-n16r8-to.html */ #include <Adafruit_NeoPixel.h> // Pin where the onboard RGB is connected #define LED_PIN 27 // Number of LEDs (number of onboard RGB is 1) #define LED_COUNT 1 // Create NeoPixel object Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800); void setup() { strip.begin(); // Initialize NeoPixel library strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(50); // Adjust brightness (0–255) } void loop() { // Cycle through Red, Green, Blue strip.setPixelColor(0, strip.Color(255, 0, 0)); // Red strip.show(); delay(100...

LVGL v9 exercise run on Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD (170x320 ST7789V2 SPI LCD and CST816 I2C capacitive touch).

Image
LVGL v9 exercise run on Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD (170x320 ST7789V2 SPI LCD and CST816 I2C capacitive touch) Basic setup and connection, refer to last exercise:  Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD, using Arduino_GFX_Library in Arduino Framework . To add LVGL function: - Install LVGL library in Arduino IDE Library Manager. - Go to lvgl library directory.   Copy lv_conf_template.h as lv_conf.h into the Arduino Libraries directory. - To enable the content of the file:     change the first #if 0 to #if 1 /* clang-format off */ #if 1 //0 /* Set this to "1" to enable content */ Exercise Code: rpPico2_ST7789_CST816_lvgl_button.ino , Create a button to control onboard LED. /* LVGL v9 exercise run on Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD (170x320 ST7789V2 SPI LCD and CST816 I2C capacitive touch). Create a button to control onboard LED. https://coxxect.blogspot.com/2025/12/lvgl-v9-exer...

First try VS Code/PlatformIO to program ESP32-S3 in Arduino Framework, to blink RGB LED.

Image
First try VS Code/PlatformIO to program YD-ESP32-S3 (N16R8) in Arduino Framework, to blink RGB LED. main.cpp #include <Arduino.h> #include <Adafruit_NeoPixel.h> #define LED_PIN 48 // YD-ESP32-S3 onboard WS2812 (IO48) #define NUMPIXELS 1 // One RGB LED only Adafruit_NeoPixel pixels(NUMPIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(115200); pixels.begin(); pixels.setBrightness(10); // Brightness (0~255) Serial.println("Rainbow demo start with brightness 100"); } uint32_t Wheel(byte pos) { pos = 255 - pos; if(pos < 85) { return pixels.Color(255 - pos * 3, 0, pos * 3); } else if(pos < 170) { pos -= 85; return pixels.Color(0, pos * 3, 255 - pos * 3); } else { pos -= 170; return pixels.Color(pos * 3, 255 - pos * 3, 0); } } void loop() { for(int i = 0; i < 256; i++) { pixels.setPixelColor(0, Wheel(i)); pixels.show(); delay(20); } } platformio.ini [env:e...

Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD, using Arduino_GFX_Library in Arduino Framework.

Image
Raspberry Pi Pico 2 +  Waveshare 1.9inch Touch LCD (170x320 ST7789V2 SPI LCD and CST816 I2C capacitive touch) in Arduino Framework, interface with ST7789 using Arduino_GFX_Library (GFX Library for Arduino by Moon On Our Nation), and reading register from CST816 via I2C. Connection: Code: rpPico2_Arduino_GFX.ino , setup for Arduino_GFX_Library, color test. /* Raspberry Pi Pico 2 + Waveshare 1.9inch Touch LCD, 170x320 ST7789V2 SPI LCD and CST816 I2C capacitive touch. Using Arduino_GFX_Library (GFX Library for Arduino by Moon On Our Nation) Details: https://coxxect.blogspot.com/2025/12/raspberry-pi-pico-2-waveshare-19inch.html Using board of Raspberry Pi Pico/RP2040/RP2350 by Earle F. Philhower III in Boards Manager. https://github.com/earlephilhower/arduino-pico Install Earle Philhower Raspberry Pi Pico Arduino core in Arduino IDE https://coxxect.blogspot.com/2023/08/install-earle-philhower-raspberry-pi.html */ /*********************...

Adafruit_GFX/ImageReader exercises to load bmp images from MicroSD and display on 240×320 ST7789 SPI TFT, run on Seeed Studio XIAO ESP32S3 Sense (Arduino Platform).

Image
Previous exercise of Seeed Studio XIAO ESP32S3 Sense display on 2.4" TFT 240×320 ST7789V using Adafruit_ST7789 lib in Arduino framework . In this exercise, load and display images from expansion board MicroSD card. Connection between XIAO ESP32S3 Sense and 2.4" TFT 240×320 ST7789V,  refer to previous exercise . Remark about the card slot on XIAO ESP32S3 Sense expansion boards Refer to  File System and XIAO ESP32S3 Sense document, Card slot circuit design for expansion boards part : The GPIO assigned to microSD Card Slot's CS is GPIO21, and SCK/MISO/MOSI are assigned to GPIO7/8/9 (the hardware SPI). And it's also stated that "if you choose to use the microSD card function of the expansion board, you cannot also use the SPI function of the XIAO ESP32S3. You can turn on/off the microSD card function by connecting/cutting the pads of J3" . But in my exercise as shown in the video: - It's no hardware ...

BlinkRGB Exercise run on WaveShare ESP32-S3-Zero, in Arduino Framework

Image
BlinkRGB Exercise run on WaveShare ESP32-S3-Zero , in Arduino Framework. Open example: > File > Examples > ESP32 > GPO > BlinkRGB On ESP32-S3-Zero, onboard RGB LED is connected to GP21, change all accordingly. /* BlinkRGB Demonstrates usage of onboard RGB LED on some ESP dev boards. Calling digitalWrite(RGB_BUILTIN, HIGH) will use hidden RGB driver. RGBLedWrite demonstrates controll of each channel: void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) WARNING: After using digitalWrite to drive RGB LED it will be impossible to drive the same pin with normal HIGH/LOW level */ //#define RGB_BRIGHTNESS 64 // Change white brightness (max 255) // the setup function runs once when you press reset or power the board #define NEOPIXEL 21 void setup() { // No need to initialize the RGB LED } // the loop function runs over and over again forever void loop() { #ifdef NEOPIXEL digitalWrite...

Display on 320x480 ILI9488 SPI TFT with Nano 33 BLE nRF52840 using Arduino_GFX Library (Arduino framework)

Image
This video show steps to display on 3.5" 320x480 ILI9488 SPI TFT with Nologo Nano 33 BLE nRF52840 using Arduino_GFX Library (Arduino framework). Makesure "GFX Library for Arduino" is installed in Arduino IDE Library Manager. Open Examples > GFX Library for Arduino > HelloWorldGfxfont Replace the code of Arduino_GFX setting, /******************************************************************************* * Start of Arduino_GFX setting ******************************************************************************/ #include <Arduino_GFX_Library.h> #define TFT_CS D10 #define TFT_RESET D9 #define TFT_DC D8 #define TFT_MOSI D11 #define TFT_SCK D13 #define TFT_LED D7 #define TFT_MISO -1 // not used for TFT #define GFX_BL TFT_LED // backlight pin /* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */ Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS); /* More display c...

Display on SSD1306/SSD1315 OLED with Uno R4 WiFi & Nano 33 BLE using Adafruit SSD1306 library

Image
Last post show how to display on SSD1306/SSD1315 OLED with Uno R4 WiFi & Nano 33 BLE using U8g2 library , this post show how to using Adafruit SSD1306 library. Install Adafruit SSD1306 library and dependencies, Adafruit BusIO and Adafruit GFX Library. Connnection, refer to last post . In last post, it's found that the I2C Address of SSD1306/SSD1315 OLED is 0x3C. Open File > Examples > Adafruit SSD1306 > ssd1306_128x64_i2c Change SCREEN_ADDRESS to 0x3C. #define SCREEN_ADDRESS 0x3C //0x3D Then it can run on Uno R4 WiFi & Nano 33 BLE to display on SSD1306/SSD1315 OLED.

Display on SSD1306/SSD1315 OLED with Uno R4 WiFi & Nano 33 BLE using U8g2 library

Image
This video show displaying on 0.96 inch 128x64 SSD1306/SSD1315 OLED with NoLogo Uno R4 WiFi & Nologo Nano 33 BLE nRF52840 using U8g2 library . Library: Install U8g2 Library in Arduino IDE's Library Manager. Connection: Connection between SSD1306/SSD1315 OLED and Uno R4 WiFi/Nano 33 BLE notice: Uno R4 WiFi operate on 5V Nano 33 BLE operate on 3.3V The operating voltage of my OLED board is 3.3~5V * Check operating voltage of your own OLED board! OLED Uno R4 WiFi Nano 33 BL ------------------------------ GND GND GND VCC +5V +3V3 SCL D19/SCL A5/P0.02 SDA D18/SDA A4/P0.31 Arduino Code: i2c_scanner.ino , scan connected I2C devices and print its I2C address. #include <Wire.h> void setup() { Wire.begin(); delay(1000); Serial.begin(115200); while (!Serial); delay(1000); Serial.println("\nI2C Scanner"); delay(2000); } void loop() { byte error, address; int nDevices; Serial.println(...

Check and update UNO R4 WiFi firmware

Image
unoR4WiFi_CheckWiFiFirmware.ino run on my dev.board - Nologo UNO R4 WiFi , to check the on board WiFi Firmware version. /* Simple code to check WiFi Firmware on Arduino Uno R4 WiFi Wi-Fi support is enabled via the built-in WiFiS3 library that is shipped with the Arduino UNO R4 Core. Installing the core automatically installs the WiFiS3 library. ref: UNO R4 WiFi Network Examples https://docs.arduino.cc/tutorials/uno-r4-wifi/wifi-examples */ #include <WiFiS3.h> void setup() { delay(500); //Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } delay(500); Serial.println("- Check Arduino Uno R4 WiFi firmware version -"); // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); // don't continue while (true); } String fv = WiFi.fir...

Adafruit_ImageReader exercises run on Raspberry Pi Pico to load images from SD Card, display on 320x240 IPS SPI ILI9341

Image
It's Adafruit_ImageReader exercises run on Raspberry Pi Pico to load images from SD Card, and display on 320x240 IPS SPI ILI9341 Module using using Adafruit_ILI9341 library. Basically follow the page Adafruit GFX Graphics Library Loading Images For 320x240 IPS SPI ILI9341 part using Adafruit_ILI9341 library, refer: ~  Raspberry Pi Pico (RP2040) + 3.2inch IPS SPI Module ILI9341 (using Adafruit_ILI9341 library)  It will also install Adafruit GFX Graphics Library as dependence. This exercise run on Raspberry Pi Pico in Earle Philhower's Arduino core (Raspberry Pi Pico/RP2040). refer: ~ Install Earle Philhower Raspberry Pi Pico Arduino core . Currently Adafruit_ImageReader support uncompressed 24-bit color BMPs only, refer: ~ Convert image to 24-bit color BMPs using GIMP  to prepare s1.bmp ~ s12.bmp, save in root directory of SD card. Install Adafruit_ImageReader and dependence in Arduino IDE Library Manager. Connection: ILI93...

Install Earle Philhower Raspberry Pi Pico Arduino core to fix error: 'rp2040' was not declared in this scope

Image
It's next Adafruit_ImageReader exercises run on Raspberry Pi Pico to load images from SD Card, and display on 320x240 IPS SPI ILI9341 Module using using Adafruit_ILI9341 library , following Adafruit GFX Graphics Library > Loading Images . But, if compile using Arduino Mbed OS RP2040 Boards, will fail with error: 'rp2040' was not declared in this scope It's another page by Adafruit, suggest Earle Philhower's Arduino core to program RP2040 in Arduino . This video show how to install Earle Philhower Raspberry Pi Pico Arduino core on Arduino IDE 2. In Arduino IDE > File > Preferences... Add the line in Additional Boards Manager URLs. https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json Install Raspberry Pi Pico/RP2040 by Earle F. Philhower III in Boards Manager. Select board of Raspberry Pi Pico/RP2040 > Raspberry Pi Pico If fail with error like: Fatal ...

Raspberry Pi Pico (RP2040) + 3.2inch IPS SPI Module ILI9341 (Arduino Framework using Adafruit_ILI9341 library)

Image
Display on 3.2inch IPS SPI Module ILI9341 with  Raspberry Pi Pico (in Arduino Framework using Adafruit_ILI9341 library). Install Libraries: Open Library Manager, install Adafruit_ILI9341 and dependencies. Connection:  ILI9341 Module           Raspberry Pi Pico      1 VCC 3V3 2 GND GND 3 LCD_CS GP17 4 LCD_RST GP21 5 LCD_RS GP20 6 SDI(MOSI) GP19 7 SCK GP18 8 LED 3V3 9 SDO(MISO) GP16 10 CTP_SCL 11 CTP_RST 12 CTP_SDA 13 CTP_INT 14 SD_CS Example: Open Adafruit ILI9341 graphicstest example. Modify pins assignment to match our connection. #define TFT_DC 20 #define TFT_CS 17 #define TFT_RST 21 // Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // If using the breakout, change pins as desired //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); update...

BLE UART Communication between XIAO ESP32C3 (client/central) and nRF52840 (server/peripheral), in Arduino Framework.

Image
Last post I have a  BLE UART Peripheral run on XIAO nRF52840 Sense (in Arduino Framework) , in this post I implement client/Central side running on XIAO ESP32C3 (in Arduino Framework also), modified from  ESP32 BLE Arduino > BLE_client example. Noted that the XIAO nRF52840 Sense server/Peripheral implemented a Nordic UART Service (NUS), so we have to use the matched UUIDs in client/Central side. - Nordic UART Service (NUS) UUID (6E400001-B5A3-F393-E0A9-E50E24DCCA9E) - RX Characteristic UUID (6E400002-B5A3-F393-E0A9-E50E24DCCA9E) - TX Characteristic UUID (6E400003-B5A3-F393-E0A9-E50E24DCCA9E). XESP32C3_BLE_client.ino /* * Modify Examples for XIAO_ESP32C3 * > ESP32 BLE Arduino * > BLE_client * Run on Xiao ESP32C3. * With UUID of Nordic UART Service (NUS), to work with * XnRF52_bleuart_OLED_Terminal run on Xiao nRF52840 Sensse. * Read from Serial and send to BLE UART server/peripheral. */ /** * A BLE client example tha...