Posts

Showing posts with the label code.arduino

Control Nologo Nano 33 BLE nRF52840 on-board LEDs

Image
Arduino code to control Nologo Nano 33 BLE nRF52840 on-board LEDs /* Exercise run on Nano 33 BLE nRF52840 to change LEDs. */ // the setup function runs once when you press reset or power the board void setup() { delay(1000); Serial.begin(9600); delay(500); Serial.print("LED_BUILTIN: "); Serial.println(LED_BUILTIN); Serial.print("LEDR: "); Serial.println(LEDR); Serial.print("LEDG: "); Serial.println(LEDG); Serial.print("LEDB: "); Serial.println(LEDB); // set LED pins to output mode pinMode(LEDR, OUTPUT); pinMode(LEDG, OUTPUT); pinMode(LEDB, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); //turn off all LED digitalWrite(LED_BUILTIN, LOW); digitalWrite(LEDR, HIGH); digitalWrite(LEDG, HIGH); digitalWrite(LEDB, HIGH); } void changeRGB(){ digitalWrite(LEDR, HIGH); digitalWrite(LEDG, HIGH); digitalWrite(LEDB, HIGH); delay(1000); digitalWrite(LEDR, LOW); //LEDR On delay(500); digit...

XIAO nRF52840/CircuitPython implement BLE UART Service, linked with XIAO ESP32C3/Arduino BLE UART Client.

Image
  The BLE GATT Nordic UART Service (NUS) is a custom service that receives and writes data and serves as a bridge to the UART interface. ref: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/nrf/libraries/bluetooth_services/services/nus.html In this exercise, XIAO nRF52840 Sense running CircuitPython, implement BLE UART Service. cpynRF_ble.py """ Circuitpython BLE exercise Run on XIAO nRF52840 Sense/CircuitPython 8.1.0-beta.1 Provide an echo service over BLE UART. Act as BLE UART server, receive from BLE UART and echo back ref: https://learn.adafruit.com/circuitpython-ble-libraries-on-any-computer/ble-uart-example """ import os, sys import time import board, busio from adafruit_ble import BLERadio from adafruit_ble.advertising.standard import ProvideServicesAdvertisement from adafruit_ble.services.nordic import UARTService #------------------------ print("========================================") print(...

Generate QRCode with Raspberry Pi Pico (arduino framework), display on 1.54" 200x200 B&W e-Paper (SSD1681)

Image
Last post show how to  display on 1.54" 200x200 e-Paper (SSD1681) with Raspberry Pi Pico using GxEPD2 library, in Arduino framework . It's another exercise to generate QRCode with Raspberry Pi Pico, and display on 1.54" 200x200 B&W e-Paper (SSD1681) GxEPD2 and QRCode libraries are needed, install them in Arduino IDE's Library Manager. Code Pico_GxEPD2_SSD1681_qrcode.ino /* *Exercise run on Raspberry Pi Pico/RP2040 *display QRCode on 1.54" 200x200 e-Paper with SSD1681 SPI driver, *using ZinggJM/GxEPD2 and qrcode lib * *qrcode: *https://github.com/ricmoo/qrcode/ */ #include <GxEPD2_BW.h> #include <qrcode.h> #define EPD_CS 17 #define EPD_DC 21 #define SRAM_CS -1 #define EPD_RESET 20 #define EPD_BUSY 22 GxEPD2_BW<GxEPD2_154_GDEY0154D67, GxEPD2_154_GDEY0154D67::HEIGHT> display( GxEPD2_154_GDEY0154D67(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY)); const int DISP_WIDTH = display.width(); const int D...

Display on 1.54" 200x200 e-Paper (SSD1681) with Raspberry Pi Pico using GxEPD2 library, in Arduino framework.

Image
To display on 1.54" 200x200 e-Paper (SSD1681 SPI) with Raspberry Pi Pico using GxEPD2 library, in Arduino framework. GxEPD2 library is needed, it can be installed in Arduino IDE Library Manager. Connection between Raspberry Pi Pico and SSD1681 SSD1681 e-Paper Raspberry Pi Pico ================================= BUSY 22 CS 17 DC 21 RES 20 SDA 19 (MOSI) SCL 18 (SCK) VCC 3V3 GND GND Code: Pico_GxEPD2_SSD1681_hello.ino, display text. /* *Exercise run on Raspberry Pi Pico/RP2040 *display on 1.54" 200x200 e-Paper with SSD1681 SPI driver, *using ZinggJM/GxEPD2 lib. * */ #include <GxEPD2_BW.h> #include <Fonts/FreeMonoBold9pt7b.h> #include <Fonts/FreeMono9pt7b.h> #define EPD_CS 17 #define EPD_DC 21 #define SRAM_CS -1 #define EPD_RESET 20 #define EPD_BUSY 22 GxEPD2_BW<GxEPD2_154_GDEY0154D67, GxEPD2_154_GDEY0154D67::HEIGHT> display( GxEPD2_154_GDEY0154D67(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY)); void setup()...

Serial communication between two RP2040 (Arduino Framework)

Image
These are simple examples to implement Serial Communication, between Raspberry Pi Pico and WeAct RP2040 with 128x128 SH1107 SPI OLED . Connection between two RP2040s +-----------------------------------+ | | |      +----------------------------------+ |      |           | | |      | +------------------------------------+ |      | |      | |    | |      | |           +---------------+    | |   | +---------------+ |      +-|-TX    GP0 | RPi Pico | | | +---TX GP0 | WeAct RP2040 | |      +-RX GP1 | | | +-------RX GP1 | | +------------GND | | +---------------GND | | |           | |           Connection: Raspberry Pi WeAct RP2040 Pico =========...

Display on 128x128 SH1107 SPI OLED with RP2040 (Arduino Framework) using U8g2 lib.

Image
Steps to setup library on Arduino IDE, to display on 1.12" 128x128 SH1107 SPI OLED with RP2040. Tested on WeAct RP2040 (16MB) . Run example, using suitable constructor and run. Library: Install U8g2 in Arduino IDE Library Manager.  U8g2 is a library for monochrome displays, version 2. Connection: Raspberry Pi Pico pre-defines SPI pins in Arduino are: SPI_MOSI:      19 SPI_MISO:      16 (not use) SPI_SCK:         18 Connection between RP2040 and SH1107 SPI OLED SH1107 RP2040 ================== GND GND VCC 3V3 SCL GP18 SDA GP19 RES GP20 DC GP21 CS GP22 Example: Open Examples > U8g2 > full_buffer > GraphicsTest In my test, Use one of the constructors: U8G2_SH1107_PIMORONI_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 22, /* dc=*/ 21, /* reset=*/ 20); //U8G2_SH1107_SEEED_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 22, /* dc=*/ 21, /* reset=*/...

Raspberry Pi Pico (in Arduino) get board info, include pins assignment.

Image
This simple code retrieve board info, include pre-defined pins assignment, for Raspberry Pi Pico (rp2040) in Arduino framewok. pico_pins_info.ino void setup() { delay(2000); Serial.begin(115200); delay(200); Serial.println("\n- Pico (rp2040) pins info -"); Serial.println("-----------------------------"); Serial.println("BOARD_NAME:\t\t" + String(BOARD_NAME)); Serial.println("BOARD_VENDORID:\t\t" + String(BOARD_VENDORID, HEX)); Serial.println("BOARD_PRODUCTID:\t" + String(BOARD_PRODUCTID, HEX)); Serial.println(); Serial.println("LED_BUILTIN:\t" + String(LED_BUILTIN)); Serial.println(":\t" + String()); Serial.println("SPI_MOSI:\t" + String(SPI_MOSI)); Serial.println("SPI_MISO:\t" + String(SPI_MISO)); Serial.println("SPI_SCK:\t" + String(SPI_SCK)); Serial.println(); Serial.println("I2C_SDA:\t" + String(I2C_SDA)); Serial.println("I...

Min. exercises to display on 2.13" 250x122 3-color E-paper with ESP32-S3, using GxEPD2 and Adafruit_EPD

Image
In my former posts, show how to install library and run example to display on 2.13" 250x122 3-color Epaper with ESP32-S3, using GxEPD2 and Adafruit_EPD . Here is my minimum exercise using GxEPD2 and Adafruit_EPD libraries respectively. ESP32_GxEPD2_SSD1680.ino , using ZinggJM/GxEPD2 library. /* *Minimum exercise using ZinggJM/GxEPD2 *Run on ESP32 Dev Module *display on 2.13" 250x122 3-color E-paper (SSD1680) * * ref: GxEPD2_MinimumExample.ino * https://github.com/ZinggJM/GxEPD2/blob/master/examples/GxEPD2_MinimumExample/GxEPD2_MinimumExample.ino * */ #include <GxEPD2_3C.h> // including both doesn't use more code or ram #include <Fonts/FreeMonoBold9pt7b.h> #define EPD_CS 5 #define EPD_DC 0 #define SRAM_CS -1 #define EPD_RESET 2 #define EPD_BUSY 15 GxEPD2_3C<GxEPD2_213_Z98c, GxEPD2_213_Z98c::HEIGHT> display( GxEPD2_213_Z98c(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY)); void setup() { display.init(); display.setRotatio...

Drive ILI9341 (8-bit parallel) using ESP32-S3 (ESP32-S3-DevKitC-1) in Arduino Framework

Image
This post show how to driver 2.8" 320x240 ILI9341 TFT with 8-bit parallel interface using Espressif ESP32-S3-DevKitC-1 , in Arduino framework, using TFT_eSPI library. Connection:  For my  2.8 inch 320x240 ili9341 TFT with 8/16BIT parallel interface , it's set in 16-bit data bus mode by default. To make it in 8-bit mode: Solder R4 with 0Ω resistor or short circuit directly, and disconnect R5. In 8-bit data bus mode, use DB8~DB15 data pin. Connection between Espressif ESP32-S3-DevKitC-1 and 2.8" 320x240 ili9341 TFT in 8-bit parallel interface: ESP32-S3 GPIO |      | V           V +------------+ | CLK T_CS | | F_CS PEN | | MOSI MISO | | NC GND | GND GND | GND VDD | 3V3 3V3 | VDD BL | 3V3 | SDCS DB15 | 3 14 | DB14 DB13 | 8 13 | DB12 DB11 | 18 12 | DB10 DB9 | 17 11 | DB8 DB7 | | DB6 DB5 | | DB4 DB3 | | DB2 DB1 | | DB0 RST  ...

Nano RP2040 Connect get time from Network Time Protocol (NTP) time server display on ST7789 SPI IPS

Image
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. ~ ref: wikipedia.org>Network_Time_Protocol To get time from Network Time Protocol (NTP) time server using Arduino Nano RP2040 Connect With WiFiNINA library installed in Arduino IDE's Library Manager, it a sample WiFiUdpNtpClient show how to get the time from a Network Time Protocol (NTP) time server, demonstrates use of UDP sendPacket and ReceivePacket. Display on 1.14" 135x240 ST7789 SPI IPS Read here for Nano RP2040 Connect to display on 1.14" 135x240 IPS ST7789 SPI in Arduino Framework . Exercise code to get time from Network Time Protocol (NTP) time server display on ST7789 SPI IPS NRP_WiFiUdpNtpClient.ino /* * Arduino Nano RP2040 Connect query NTP TIme Service (base on WiFiNINA example WiFiUdpNtpClient), * display on 1.14" 135x240 ST7789 SPI IPS. *...

Get info of XIAO ESP32C3 (Arduino)

Image
XiaoESP32C3_info.ino , Arduino code to read info of XIAO ESP32C3 . #include <Esp.h> void setup() { delay(500); Serial.begin(9600); delay(500); Serial.println("\n\n================================"); Serial.println("Seeed Studio XIAO ESP32C3"); Serial.println("================================"); Serial.printf("Chip Model: %s\n", ESP.getChipModel()); Serial.printf("Chip Revision: %d\n", ESP.getChipRevision()); Serial.printf("with %d core\n", ESP.getChipCores()); Serial.printf("Flash Chip Size : %d \n", ESP.getFlashChipSize()); Serial.printf("Flash Chip Speed : %d \n", ESP.getFlashChipSpeed()); esp_chip_info_t chip_info; esp_chip_info(&chip_info); Serial.printf("\nFeatures included:\n %s\n %s\n %s\n %s\n %s\n", (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded flash" : "", (chip_info.features & CHIP_FEATURE_...

Nano RP2040 Connect (in Arduino Framework) connect to WiFi network

Image
This Arduino exercise run on Nano RP2040 Connect with WiFiNINA library, to connect to WiFi network. If connection lost, it will try to re-connect again. The onboard LED indicate the connection status. Library need: Install WiFiNINA in Arduino IDE Library Manager. Code:  NRP_toConnect.ino //"WiFiNINA by Arduino" needed to be installed in Arduino IDE Library Manager #include <WiFiNINA.h> int status = WL_IDLE_STATUS; char ssid[] = "ssid"; // your network SSID (name) char pass[] = "password"; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key index number (needed only for WEP) unsigned long previousMillis; const long interval = 1000; //interval for 1 second void setup() { delay(500); Serial.begin(9600); delay(500); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("\n--- Start ---...

Arduino Nano RP2040 Connect display on 1.14" 135x240 IPS ST7789 SPI (in Arduino Framework)

Image
Arduino Nano RP2040 Connect display on 1.14" 135x240 IPS ST7789V SPI (in Arduino Framework), using Adafruit ST7735 and ST7789 Library. The default SPI pins of Nano RP2040 Connect in Arduino Framework is: SS:          D10 MOSI:    D11 MISO:    D12 SCK:      D13 Connection using Hardware SPI:      ST7789V(SPI)      Nano RP2040 Connect      GND      GND      VCC      3V3      SCL      D13 (default SCK)      SDA      D11 (default MOSI)      RES      D10      DC      D9      CS      D8      BLK      3V3 Nano RP2040 Connect ST7789 SPI +---------------------+ +------ |      | GND-| GND | ...

I2C Scanner for Arduino Framework

Image
i2c_scanner is a simple sketch scans the I2C -bus for devices. If a device is found, it is reported to the Arduino serial monitor. How it run on Arduino Nano RP2040 Connect: