Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Monday, August 11, 2025

NodeMCU v0.9 and v1.0 pins

 NodeMCU v0.9


NodeMCU v1.0



Monday, May 05, 2025

FT232H + Adafruit Blinka + 0.19 inch OLED (SSD1306) on Windows 11

 FT232H + Adafruit Blinka on Windows 11

Windows Ver.24H2, OS Build 26.100.3915
Python 3.10.7

Download Zadig from its page: https://zadig.akeo.ie/

Plug FT232H board to Windows

Open Zadig and reinstall the driver for FT232H, follow the instructions in this page:
https://learn.adafruit.com/circuitpython-on-any-computer-with-ft232h/windows

Make sure selecting the correct device then select "libusbK", then click on "Replace Driver"

  • Driver: FTDIBUS (...)
  • USB ID: 0403 6014


Before & After replace the driver:

  • libusbK USB Devices should appear in the Device Manager


Create python virtual env then activate python virtual env

% mkdir ws_py && cd ws_py
% python -m venv .venv
% .venv\Scripts\activate.bat

Install additional libraries to check if FT232H can be recognized

% pip3 install pyusb
% pip3 install pyftdi

Then try to run this code to show the device information

>>> import usb
>>> import usb.util
>>> dev = usb.core.find(idVendor=0x0403, idProduct=0x6014)
>>> print(dev)


Now we can try to use this with the 0.91 inch OLED SSD1306 by executing the following steps

(.venv) % pip install Pillow
(.venv) % pip install adafruit-circuitpython-ssd1306
(.venv) % pip install adafruit-blinka


(.venv) % git clone https://github.com/adafruit/Adafruit_CircuitPython_SSD1306.git
(.venv) % cd Adafruit_CircuitPython_SSD1306\examples
(.venv) % set BLINKA_FT232H=1 → Always need this ENV when using FT232H(!!!)
(.venv) % python ssd1306_simpletest.py

Now we should see something drawn on the tiny display

Done.


Raspberry Pi Zero 2W + 0.91 inch OLED (SSD1306)

Playing with this cheap OLED display:
Size: 0.91 inch
Resolution: 128 x 32 pixels
Interface: I2C
Operating voltage: 3.3 V~5V
 
Update the system once:

$ sudo apt update
$ sudo apt upgrade -y

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

$ uname -a
Linux pizero2w 6.12.25+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.25-1+rpt1 (2025-04-30) aarch64 GNU/Linux

Setup I2C for Raspi

$ sudo raspi-config → then enable I2C communication from "Interface Options" menu
$ sudo reboot

Install I2C utilities

$ sudo apt install i2c-tools

Connect the display to raspi

Display GND →  Raspi GND pin no.5
Display VCC →  Raspi 3V pin no.1
Display SDA  →  Raspi pin no.2
Display SCK  →  Raspi pin no.3

Check if Raspi can detect the display 

$ i2cdetect -y 1 → this command should show "0x3C" address


Install the following packages for python environment:

$ sudo apt install python3-pip
$ sudo apt install python3-venv

Create python virtual environment

$ mkdir $HOME/ws_py
$ cd $HOME/ws_py && python -m venv .venv

Activate python virtual environment (current working directory is $HOME/ws_py)

$ . .venv/bin/activate
(.venv) ~/ws_py $

After python virtual environment is activated, install python packages using pip

$ pip install Pillow
$ pip install RPi.GPIO
$ pip install adafruit-circuitpython-ssd1306
$ pip install adafruit-blinka

Check if the display is working properly using example code from Adafruit

$ cd $HOME/ws_py
$ git clone https://github.com/adafruit/Adafruit_CircuitPython_SSD1306.git
$ cd examples
$ python ssd1306_stats.py

The display should show the IP address, CPU, memory and disk info of the raspberry pi after this step




Wednesday, May 03, 2023

About ESP32-S3 N16R8 DevKit (AI-S3) board RGB LED

 このAI-S3ボードをAliexpressで購入(ここ

サンプルプログラムのBlinkRGBでこのボードの上にあるRGB LEDを点滅させる.このボードのレイアウトはESP32-S3-DevKitC-1に似ているが,所々異なっている・・・探してもこのボード自体のschematicが出てこないため,RGB LEDの型番は不明,接続先も不明・・そのためサンプルプログラムがなかなか動かすことができなかった.結論からいうとこのRGB LEDはGPIO38ではなく,GPIO48で制御することができる.

オリジナルのESP32-S3-DevKitC-1schematicを見るとGPIO38に接続されているがこれはESP-IDF v5.0.1のバージョンで,ESP-IDF v4.4.xのバージョンだとGPIO48になっていた.おそらくAI-S3ボードはこの古いバージョンをベースに作られていると思われる.


環境
- Arduino IDE + esp32 v2.0.8
- Board: ESP32S3 Dev Module

サンプルプログラム
/*
  BlinkRGB
*/

#define RGB_BRIGHTNESS 150 // Change white brightness (max 255)

// Explicitly define the pin here, overwrite the one in 
// C:\Users\...\AppData\Local\
//    Arduino15\packages\
//       esp32\hardware\esp32\2.0.8\variants\esp32s3\pins_arduino.h
#define RGB_BUILTIN 48 
void setup() {
  Serial.begin(115200);
  Serial.println("setup done...");
}

void loop() {
#ifdef RGB_BUILTIN
  digitalWrite(RGB_BUILTIN, HIGH);   // Turn the RGB LED white
  delay(1000);
  digitalWrite(RGB_BUILTIN, LOW);    // Turn the RGB LED off
  delay(1000);

  neopixelWrite(RGB_BUILTIN,RGB_BRIGHTNESS,0,0); // Red
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,RGB_BRIGHTNESS,0); // Green
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,0,RGB_BRIGHTNESS); // Blue
  delay(1000);
  neopixelWrite(RGB_BUILTIN,0,0,0); // Off / black
  delay(1000);
#endif
}

RGB_BUILTINをコード内に再定義しておくことでesp32s3/pins_arduino.h内に定義されているののを上書きさせる

ちなみに,上のAI-S3ボードを購入するのであれば,下記のYD-ESP32-S3ボードを購入した方がいい.このボードのschematicはGithubにある(ここ