Adsense HTML/JavaScript

Tuesday, March 15, 2022

Remark on "Arduino Nano RP2040 Connect" of "Arduino Mbed OS Boards" vs "Arduino Mbed OS Nano Boards"

It's my case of selecting "Arduino Nano RP2040 Connect" of "Arduino Mbed OS Boards" vs "Arduino Mbed OS Nano Boards".

The case is:
I have both Arduino Nano RP2040 Connect and Seeed XIAO BLE (Sense).

To program in Arduino IDE (1.8.15), follow this post (in my another blogspot) to install Arduino Mbed OS Nano Boards for Arduino Nano RP2040 Connect, and follow former post to install Seeed nRF52 Boards for Seeed XIAO nRF52840 Sense.

After then, there are two selection of "Arduino Nano RP2040 Connect" from "Arduino Mbed OS Boards" and "Arduino Mbed OS Nano Boards".

Case I - "Arduino Nano RP2040 Connect" from "Arduino Mbed OS Boards", actually it come from Seeed nRF52 Boards 2.6.1:


Select board "Arduino Nano RP2040 Connect" from "Arduino Mbed OS Boards"


If you have ArduinoBLE library installed, its examples is located within INCOMPATIBLE.


If you compile any example, even Blink, error will be reported!


Arduino: 1.8.15 (Linux), Board: "Arduino Nano RP2040 Connect"

WARNING: library ArduinoBLE claims to run on samd, megaavr, mbed, apollo3, mbed_nano, mbed_portenta architecture(s) and may be incompatible with your current board which runs on nrf52 architecture(s).
Traceback (most recent call last):
  File "/home/pi/.local/bin/adafruit-nrfutil", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/nordicsemi/__main__.py", line 239, in genpkg
    package.generate_package(zipfile_path)
  File "/home/pi/.local/lib/python3.7/site-packages/nordicsemi/dfu/package.py", line 189, in generate_package
    Package.normalize_firmware_to_bin(work_directory, firmware[FirmwareKeys.FIRMWARE_FILENAME])
  File "/home/pi/.local/lib/python3.7/site-packages/nordicsemi/dfu/package.py", line 329, in normalize_firmware_to_bin
    temp.tobinfile(new_filepath)
  File "/home/pi/.local/lib/python3.7/site-packages/nordicsemi/dfu/nrfhex.py", line 160, in tobinfile
    start_address = self.minaddr()
  File "/home/pi/.local/lib/python3.7/site-packages/nordicsemi/dfu/nrfhex.py", line 114, in minaddr
    min_address = max(self.get_mbr_end_address(), min_address)
TypeError: '>' not supported between instances of 'NoneType' and 'int'
exit status 1
Error compiling for board Arduino Nano RP2040 Connect.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Case II - "Arduino Nano RP2040 Connect" from"Arduino Mbed OS Nano Boards" 2.8.0:


Select board "Arduino Nano RP2040 Connect" from "Arduino Mbed OS Nano Boards"


Now ArduinoBLE example is located under Custom Libraries.


Compile and Upload without error.


Monday, March 14, 2022

XIAO BLE Sense/Expansion board (Arduino Framework) to control SSD1306 I2C OLED

Example run on XIAO BLE Sense/Expansion board (Arduino Framework) to control SSD1306 I2C OLED

Refer to document Seeeduino XIAO Expansion board > OLED Display:
- u8g2 library is suggested
- a example is provided to control the on-Expansion board SSD1306 I2C OLED

To make it work on XIAO BLE Sense/Expansion board (Arduino Framework), change the code as below, using U8X8_SSD1306_128X64_NONAME_HW_I2C instead of U8X8_SSD1306_128X64_NONAME_SW_I2C.

XIAOBLE_OLED.ino

#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>
 
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);

void setup(void) {
  u8x8.begin();
  u8x8.setFlipMode(1); //rotary 180
}
 
void loop(void) {
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.setCursor(0, 0);
  u8x8.print("Hello World!");
}




Connection of OLED on Seeeduino XIAO Expansion board

According to Seeeduino XIAO Expansion board_v1.0_SCH_200824, OLED SCL and SDA is connected to XIAO D5 and D4.

Sunday, March 13, 2022

Setup Arduino IDE to support Seeed XIAO BLE (Sense), fix 'exec: "adafruit-nrfutil": executable file not found in $PATH'

To add support of Seeed XIAO BLE (Sense) to Arduino IDE:
- File > Preferences
- Add https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json to "Additional Boards Manager URLs"

Tools > Board > Boards Manager...
- Search and install "Seeed nRF52 Boards by Seeed Studio"

Select board:
- Tools > Board > Arduino Mbed OS Boards > "Seeed XIAO nRF52840 Sense"
- Select correct port

Now you can try to program and upload to your XIAO BLE (Sense).

If you run on Linux, including Raspberry Pi OS, you will be reported with error:

exec: "adafruit-nrfutil": executable file not found in $PATH
Error compiling for board Seeed XIAO nRF52840 Sense.

You have to install adafruit-nrfutil manually:

$ pip3 install --user adafruit-nrfutil

Done


ref:
Getting Started with XIAO BLE (Sense)
~ Adafruit Bluefruit nRF52 Feather Learning Guide > Arduino Support Setup

If you have Arduino Nano RP2040 Connect also, check Remark on "Arduino Nano RP2040 Connect" of "Arduino Mbed OS Boards" vs "Arduino Mbed OS Nano Boards".

Friday, March 11, 2022

Install CircuitPython 7.2.0 on ESP32-S3 (ESP32-S3-DevKitC-1), using esptool v3.2 on Linux Mint

CircuitPython 7.2.0 was released. With espressif ESP32-S3 and ESP32-C3 supported (considered alpha and will have bugs and missing functionality).

To flash firmware on esp32s3, esptool v3.2 is needed. This post show the steps to flash CircuitPython 7.2.0 on ESP32-S3-DevKitC-1 N8R8 (with 8MB Flash and 8MB PSRAM) run on Linux Mint (over VirtualBox/Windows 10).



Visit CircuitPython download page, search "S3" and download .BIN for "ESP32-S3-DevKitC-1-N8R8 by Espressif".

Connect USB to the port marked "UART".

To check the ESP chip ID and Flash using commands:
$ esptool.py --chip auto --port /dev/ttyUSB0 chip_id
$ esptool.py --chip auto --port /dev/ttyUSB0 flash_id

Erase flash:
$ esptool.py --port /dev/ttyUSB0 erase_flash

Flash firmware:
$ esptool.py --chip esp32s3 --port <port> write_flash \-z 0x0 <file.BIN>

To program using CircuitPython, re-connect USB to the port marked "USB".

cpyESP32S3_info.py

"""
CircuitPython 7.2.0 exercise run on ESP32-S3,
get system info.
"""
import board
import sys
import os
"""
ref:
The entire table of ANSI color codes working in C:
https://gist.github.com/RabaDabaDoba/145049536f815903c79944599c6f952a
"""
class color:
   RED = '\033[1;31;48m'
   BLUE = '\033[1;34;48m'
   BLACK = '\033[1;30;48m'
   END = '\033[1;37;0m'

print(board.board_id)
print(sys.implementation[0] + ' ' +
      str(sys.implementation[1][0]) +'.'+
      str(sys.implementation[1][1]) +'.'+
      str(sys.implementation[1][2]))
print("==========================================")
info = color.RED + \
       sys.implementation[0] + ' ' + \
       os.uname()[3] + color.END + '\n' + \
       'run on ' + color.BLUE + os.uname()[4] + color.END
print(info)
print("==========================================")

print()
cpyESP32S3_NEOPIXEL.py, control onboard RGB LED.
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("Hello ESP32-C3/CircuitPython NeoPixel exercise")
#print(os.uname())
for u in os.uname():
    print(u)
print()
print("neopixel version: " + neopixel.__version__)
print()

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

cycleNeopixel(0.01)

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

print("- bye -\n")

Related:
~ To flash ESP32-S3, esptool v3.2 or above is needed. With esptool upgraded, we can now flash ESP32-S3 on Rspberry Pi.

Next:
CircuitPython BLE UART between XIAO BLE Sense and ESP32-C3/S3


Wednesday, March 9, 2022

Seeed XIAO BLE Sense (nRF52840) + Expansion board

Seeed XIAO BLE Sense (nRF52840) + XIAO Expansion board




ref:
Getting Started with XIAO BLE (Sense)
Seeeduino XIAO Expansion board

Ai-Thinker NodeMCU ESP-C3-32S-Kit and ESP-S3-12K-Kit

Ai-Thinker NodeMCU:
ESP-C3-32S-Kit (internal 4M)
ESP-S3-12K-Kit



Check chip_id and flash_id using esptool:
$ esptool.py --chip auto --port /dev/ttyUSB0 chip_id
$ esptool.py --chip auto --port /dev/ttyUSB0 flash_id
for ESP-C3-32S-Kit:
pi@raspberrypi:~ $ esptool.py --chip auto --port /dev/ttyUSB0 chip_id
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-C3
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 34:b4:72:4e:19:f4
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-C3 has no Chip ID. Reading MAC instead.
MAC: 34:b4:72:4e:19:f4
Hard resetting via RTS pin...
pi@raspberrypi:~ $ esptool.py --chip auto --port /dev/ttyUSB0 flash_id
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-C3
Chip is unknown ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 34:b4:72:4e:19:f4
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...



ESP-S3-12K-Kit:
(esptool v3.2 is needed, error reported in esptool v3.1)

Using esptool v3.1 on Raspberry Pi, detected as ESP32-S3(beta3) and reported "A fatal error occurred: Invalid head of packet (0x65)"!
pi@raspberrypi:~ $ esptool.py --chip auto --port /dev/ttyUSB0 chip_id
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-S3(beta3)
Chip is ESP32-S3(beta3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 00:00:00:00:00:00
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-S3(beta3) has no Chip ID. Reading MAC instead.

A fatal error occurred: Invalid head of packet (0x65)
pi@raspberrypi:~ $ esptool.py --chip auto --port /dev/ttyUSB0 flash_id
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-S3(beta3)
Chip is ESP32-S3(beta3)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 00:00:00:00:00:00
Uploading stub...
Running stub...
Stub running...

A fatal error occurred: Invalid head of packet (0x65)



Using esptool v3.2 on Linux Mint, detected as ESP32-S3 and no error.
eric@eric-VirtualBox:~$ esptool.py --chip auto --port /dev/ttyUSB0 chip_id
esptool.py v3.2
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-S3
Chip is ESP32-S3
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:43:65:2c
Uploading stub...
Running stub...
Stub running...
Warning: ESP32-S3 has no Chip ID. Reading MAC instead.
MAC: f4:12:fa:43:65:2c
Hard resetting via RTS pin...
eric@eric-VirtualBox:~$ esptool.py --chip auto --port /dev/ttyUSB0 flash_id
esptool.py v3.2
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-S3
Chip is ESP32-S3
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:43:65:2c
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4017
Detected flash size: 8MB
Hard resetting via RTS pin...