Adsense HTML/JavaScript

Saturday, November 28, 2020

nanoESP32-S2/CircuitPython control on-board NeoPixel, using Adafruit CircuitPython Library Bundle

With CircuitPython installed to nanoESP32-S2, we are going to program nanoESP32-S2 with CircuitPython, using neopixel library come from Adafruit CircuitPython Library Bundle.


The CircuitPython Library Bundle contains all current libraries available for CircuitPython.

To use neopixel library, we have to install Adafruit CircuitPython Library Bundle to our CircuitPython board, nanoESP32-S2. 

- Visit CircuitPython Libraries, download the appropriate bundle for your version of CircuitPython, it is adafruit-circuitpython-bundle-6.x-mpy-20201126.zip in my case. Unzip the file, open the resulting folder and find the lib folder. Open the lib folder and find the library files you need to load. Copy the individual library files you need to the lib folder on your CIRCUITPY drive.

- And we have to check the IO assigned to nanoESP32-S2 on-board NeoPixel.
Visit GitHub wuxx/nanoESP32-S2/schematic/nanoESP32S2-v1.2.pdf to check the schematic. 

Found that the IO assigned to DIN of WS2812B is GPIO18, board.IO18 in CircuitPython.  Actually, board.NEOPIXEL is defined as board.IO18.

WS2812B is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050 components, the NeoPixel.

- Edit code.py in CIRCUITPY, save and run it:
import time
import os
import microcontroller
import neopixel
import board

def cycleNeopixel(wait):
    for r in range(255):
        pixel[0] = (r, 0, 0)
        time.sleep(wait)
    for r in range(255, 0, -1):
        pixel[0] = (r, 0, 0)
        time.sleep(wait)
        
    for g in range(255):
        pixel[0] = (0, g, 0)
        time.sleep(wait)
    for g in range(255, 0, -1):
        pixel[0] = (0, g, 0)
        time.sleep(wait)
        
    for b in range(255):
        pixel[0] = (0, 0, b)
        time.sleep(wait)
    for b in range(255, 0, -1):
        pixel[0] = (0, 0, b)
        time.sleep(wait)
        
print("==============================")
print(os.uname())
print("Hello nanoESP32-S2/CircuitPython NeoPixel example")
print("cpu.temperature: " + str(microcontroller.cpu.temperature))
print()
print("neopixel version: " + neopixel.__version__)
print()

# Create the NeoPixel object
pixel = neopixel.NeoPixel(board.IO18, 1, pixel_order=neopixel.RGB)
pixel[0] = (0, 0, 0)
time.sleep(2.0)

cycleNeopixel(0.01)

pixel[0] = (0, 0, 0)
time.sleep(2.0)

print("- bye -\n")


Check in the video:


It seem R and G is swapped in my unit, it should be GRB order for the build-in NeoPixel. To correct it, have to change "pixel_order=neopixel.RGB" to "pixel_order=neopixel.GRB" to match. It will be fixed in next exercise.

Next:

Wednesday, November 25, 2020

Hello ESP32-S2/CircuitPython, on nanoESP32-S2

To install CircuitPython to nanoESP32-S2 (run on Raspberry Pi), refer to my another post: Hello Raspberry Pi - Install CircuitPython to nanoESP32-S2, on Raspberry Pi.


How to run code.py on nanoESP32-S2/CircuitPython, in Mu editor:

When CircuitPython finishes installing, or you plug a CircuitPython board into your computer with CircuitPython already installed, the board shows up on your computer as a USB drive called CIRCUITPY.

The CIRCUITPY drive is where your code and the necessary libraries and files will live. You can edit your code directly on this drive and when you save, it will run automatically. When you create and edit code, you'll save your code in a code.py file located on the CIRCUITPY drive.

CircuitPython looks for code.py and runs the contents of the file automatically when the board starts up, reloads, or when you save changes to the file.


This video show how to run code.py on nanoESP32-S2/CircuitPython, in Mu editor:



More related to CircuitPython/ESP32-S2:

Updated for CircuitPython 7

Monday, November 23, 2020

ESP32-S2 dev. board: ESP32-S2-Saola-1 and nanoESP32-S2

ESP32-S2 is a highly integrated, low-power, single-core Wi-Fi Microcontroller SoC, designed to be secure and cost-effective, with a high performance and a rich set of IO capabilities. They are an ideal choice for a wide variety of application scenarios relating to the Internet of Things (IoT), wearable electronics and smart home. (ref: https://www.espressif.com/en/products/socs/esp32-s2)

Currently, it have 6 modules include:

My boards with ESP32-S2 Module: ESP32-S2-Saola-1 and nanoESP32-S2



My ESP32-S2-Saola-1 (with ESP32-S2-WROVER module):




ESP32-S2-Saola-1 is a small-sized ESP32-S2 based development board produced by Espressif.

It currently support:

WROOM: no PSRAM
WROVER: with PSRAM
-I: IPEX Antenna
without -I: PCB Antenna

My unit have ESP32-S2-WROVER (PCB Antenna, with PSRAM) module.


My nanoESP32-S2 (with ESP32-S2-WROVER-I module):




nanoESP32-S2 is another development board of ESP32-S2 produced by museLab. It support the four modules also, ESP32-S2-WROVER, ESP32-S2-WROVER-I, ESP32-S2-WROOM and ESP32-S2-WROOM-I.

One advantage of this board is it have a extra USB port (marked "esp32"), connect to ESP32-S2 chip directly. It is more easy to develop using CircuitPython.

My unit come with ESP32-S2-WROVER-I module (IPEX Antenna, with PSRAM) module.


Next:



Monday, November 16, 2020

Install esptool on Raspberry Pi OS (32 bit)

esptool.py is a Python-based, open source, platform independent, utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32 chips, and also ESP32-S2.

To install on Raspberry Pi (running 32 bit Raspberry Pi OS), open Terminal and enter the command:

$ sudo pip install esptool

or install Development mode, allows you to run the latest development version from this repository.

$ git clone https://github.com/espressif/esptool.git
$ cd esptool
$ pip install --user -e .


Monday, November 9, 2020

Yahboom K210 Developer Kit, to learn Al vision technology

This Yahboom K210 Developer Kit is a small full-featured development board kit developed by Yahboom and Canaan. The RISC-V processor structure adopted by K210 is specially designed for machine vision and machine hearing multi-mode shape recognition, it can be widely used in smart home, machine vision, intelligent robots, security monitoring and other fields. The development board not only contains a variety of peripherals such as capacitive touch screen,camera, micro-phone,speaker, six-axis aittitude sensor, and WIFl module, but also provides rich development materials to facilitate secondary development and learning, and lower the threshold for learning Al vision technology.

details: ~ K210 Developer Kit repository