Adsense HTML/JavaScript

Monday, September 28, 2020

Seeeduino XIAO display on OLED screen (with ssd1306 using I2C interface)

This example show how Seeeduino XIAO display on OLED screen, with ssd1306 driver using I2C interface, using ssd1306 library.

Connection between XIAO and OLED (ssd1306)
XIAO		OLED (ssd1306 I2C)
3V3			VCC
GND			GND
SDA			SDA
SCL			SCL

Make sure Seeed SAMD Boards is installed in Boards Manager, refer to the post Seeeduino XIAO for Install Seeeduino XIAO board to Arduino IDE.


Make sure ssd1306 library is installed in Library Manager.


Select board of Seeeduino XIAO


Confirm port


Open ssd1306_demo example




Thursday, September 17, 2020

Program Seeeduino XIAO as USB-to-Serial bridge, to access HC-08 BLE 4.0 Module/ESP WiFi Modules.


HC-08 is a Bluetooth 4.0 low energy module. It provide TTL Serial interface. If we want to access it using PC, normal a USB-to-Serial adapter is used.

In this exercise, Seeeduino XIAO is programmed as a USB-to-Serial bridge to read/write HC-08 from Raspberry Pi using Arduino IDE's Serial Monitor.

Connection between Seeeduino XIAO and HC-08

XIAO		HC-08
=====================
3V3		VCC
GND		GND
TX		RX
RX		TX

For the code, simple foreward date from SerialUSB to Serial1, and foreward Serial1 to SerialUSB.

X_USBbridge.ino

/*
Xiao act as a bridge between USB and Serial device

It's assumed the device is running 3V3
Connection
Xiao Rx   - device Tx
Xiao Tx   - device Rx
XIAO GND  - device GND
XIAO 3V3  - device VCC

*/

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  
  delay(1000);
  SerialUSB.begin(9600);
  Serial1.begin(9600);

  //wait serial ports to device
  //while(SerialUSB);
  while(!Serial1);
  
  //Blink the LED 3 times to indicate program started
  for(int i=0; i<3; i++){
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
}

void loop()
{
  if(SerialUSB.available() > 0){
    Serial1.write(SerialUSB.read());
  }

  if(Serial1.available() > 0){
    SerialUSB.write(Serial1.read());
  }
}

This video show how it work.

Before HC-08 connected (LED blinking), You can read/write HC-08 status with AT Command.
After HC-08 connected with test app on Android phone (LED on), you can send/receive text to/from the app. 

To know where/how to download datasheet (with AT Command Set) and test app for HC-08, read the post "HC-08 Bluetooth Module (BLE 4.0)".

To install Seeeduino XIAO board to Arduino IDE, read the post "Seeeduino XIAO".


This can be used to access HC-04 Dual Mode BLE SPP Bluetooth Module also.



Next:


Access ESP WiFi Modules:

With baud rate changed to 115200, it can access ESP WiFi modules. Tested with ESP-01S and ESP-12S.

X_USBbridge_115200.ino

/*
Xiao act as a bridge between USB and Serial device

It's assumed the device is running 3V3
Connection
Xiao Rx   - device Tx
Xiao Tx   - device Rx
XIAO GND  - device GND
XIAO 3V3  - device VCC

*/

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  
  delay(1000);
  SerialUSB.begin(115200);
  Serial1.begin(115200);

  //wait serial ports to device
  //while(SerialUSB);
  while(!Serial1);
  
  //Blink the LED 3 times to indicate program started
  for(int i=0; i<3; i++){
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
}

void loop()
{
  if(SerialUSB.available() > 0){
    Serial1.write(SerialUSB.read());
  }

  if(Serial1.available() > 0){
    SerialUSB.write(Serial1.read());
  }
}


Arduino IDE run on Raspberry Pi, to program Xiao as bridge to access ESP-01S:



Sunday, September 13, 2020

Seeeduino XIAO

The Seeeduino XIAO is a tiny microcontroller board with powerful cpu SAMD21G18, ARM® Cortex®-M0+ 32bit 48MHz microcontroller with 256KB Flash,32KB SRAM.





Seeeduino XIAO has 14 GPIO PINs, which can be used for 11 digital interfaces, 11 mock interfaces, 10 PWM interfaces (d1-d10), 1 DAC output pin D0, 1 SWD pad interface, 1 I2C interface, 1 SPI interface, 1 UART interface, Serial communication indicator (T/R), Blink light (L). The colors of LEDs(Power,L,RX,TX) are green, yellow, blue and blue. Moreover, Seeeduino XIAO has a Type-C interface which can supply power and download code. There are two reset pad, you can short connect them to reset the board.

Pinout:


Install Seeeduino XIAO board to Arduino IDE

With Arduino IDE installed, 
- select menu File > Preference, 
- add Additional Boards Manager URLs with: 
https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json

- Tools-> Board-> Boards Manager...
- Search "Seeeduino XIAO"
- Install "Seeed SAMD Boards"

Product page: Seeed Wiki - Seeeduino XIAO

Next:


HC-08/HC-04 Bluetooth Module

HC-08 Bluetooth Module (BLE 4.0)



HC-08 is a Bluetooth 4.0 low energy module, it can easily connect to iOS 5 and Android 4.3 or above by using a serial terminal app. You can use the Bluetooth communication up to 87 yards (80 meters) with this Bluetooth BLE module. It also runs on a 2.4GHz frequency. The chipset is CC2540 with 256K Byte space. You can change the role and serial baud rate and it supports AT commands for configuration.

It is very small in size, 1.1 x 0.5 in (26.9 x 13mm). The PCB thickness is 0.03 (0.7mm). Half-cut holes run along the lengths of the board, so it’s very easy to embed into your own project. It also has Tx and Rx 2.54 pin out, from which you can do a quick function test. Included are 90-degree male header pins.

HC-08 is a relatively new module made by an experienced Bluetooth design and manufacturing supplier in China. It’s mass produced and therefore well-tested. It can be incorporated into products or projects without worrying about being able to get it again. It’s already widely used in many Bluetooth projects.

Product page: http://www.hc01.com/products/6 (in Chinese)


This video show how to download and run test app for HC-08 Bluetooth module, and also download datasheet with AT command set.

In the testing, a wire is used to connect between HC-08 TX and RX pins, such that the message sent will be echo back.


Summary of AT Command Set in the datasheet is captured here.




HC-04 Dual Mode BLE SPP Bluetooth Module

HC-04 Bluetooth serial communication module is a new generation of dual-mode digital transmission module based on V2.1 (SPP) classic Bluetooth protocol and V4.0 (BLE) Bluetooth protocol. Only supports slave mode.



Friday, September 11, 2020

MicroPython on pyboard to display text on OLED (with I2C interface ssd1306)

It's a 0.96 inch 128x64  OLED displays with ssd1306 driver using I2C interface. This example show how to display text on it with pyboard using MicroPython ssd1306 library.

Connection between pyboard and OLED:
pyboard 3V3 connected to ssd1306 VCC
pyboard GND connected to ssd1306 GND
pyboard X12 connected to ssd1306 SCL
pyboard X11 connected to ssd1306 SDA


Download the MicroPython ssd1306 library HERE, ans save it to pyboard flash.

MicroPython script, pyb_i2c_ssd1306.py:

# Download ssd1306
# https://github.com/micropython/micropython/blob/master/drivers/display/ssd1306.py
# and save to pyboard flash

import ssd1306
import machine
import time

WIDTH = const(128)
HEIGHT = const(64)

ssd1306_scl = machine.Pin('X12', machine.Pin.OUT_PP)
ssd1306_sda = machine.Pin('X11', machine.Pin.OUT_PP)
i2c_ssd1306 = machine.I2C(scl=ssd1306_scl, sda=ssd1306_sda)

print(i2c_ssd1306.scan())
oled = ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c_ssd1306)
oled.fill(0)

oled.text("MicroPython", 0, 0)
oled.text("OLED(ssd1306)", 0, 10)
oled.text("pyboard", 0, 20)
oled.show()

while True:
    time.sleep(1)
    oled.invert(1)
    time.sleep(1)
    oled.invert(0)


pyboard MicroPython exercise: scan I2C address

 It's a MicroPython exercise running on pyboard, to scan I2C address of attached I2C device. Actually, the I2C device used is a OLED with I2C interface ssd1306 in next exercise.

i2c_scan.py

#I2C SCL connected to pyboard X12
#I2C SDA connected to pyboard X11

import machine
i2c_scl = machine.Pin('X12', machine.Pin.OUT_PP)
i2c_sda = machine.Pin('X11', machine.Pin.OUT_PP)

i2c = machine.I2C(scl=i2c_scl, sda=i2c_sda)
print(i2c.scan())


Monday, September 7, 2020

Modified MicroPython pyboard PYBv1.1, and more...



It's a modified version of MicroPython pyboard, PYBv1.1, with extra modification:
- BOOT0 button for enter DFU mode, such that you no need to use a wire to connect P1 and 3V3.
- SWD connetor
- PWR LED


Getting pyboard MicroPython REPL using Thonny, on Ubuntu 20.04


To install Thonny on Ubuntu 20.04 and add USB permission to user, read the post "Install esptool/thonny on Ubuntu 20.04". (No need to install esptool if you target not for ESP devices such as ESP8266/ESP32)

Run Thonny
> Run > Select interpreter...
> Select MicroPython (generic) and connected USB Port

Run MicroPython script using Thonny IDE




Update MicroPython firmware on pyboard

A list of all available firmware is here.
In my case, it's pybv11-20200902-v1.13.dfu.

To update pyboard MicroPython firmware on Ubuntu, have to install dfu-util:
$ sudo apt update
$ sudo apt install dfu-util

First, disconnect everything from your pyboard. Then connect the DFU pin with the 3.3V pin (they're right next to each other) to put the board into DFU (Device Firmware Update) mode, or press and hold the BOOT0 button for my Modified MicroPython pyboard PYBv1.1. Now connect the pyboard to your computer via USB.

Update firmware using dfu-util:
$ sudo dfu-util --alt 0 -D <downloaded dfu file>

After the the program finished, disconnect the pyboard from USB and remove the jumper between the DFU and the 3.3v ports.


MicroPython firmware updated


Related:

Sunday, September 6, 2020

Sipeed Maix Amigo


SIPEED Maix Amigo is an all-in-one programmable AIoT development kit that can be used for AI and IoT learning. It has a built-in RV64GC RISC-V 64-bit 400Mhz dual-core high-performance processor with 8M on-chip SRAM and 16MiB FLASH storage. It is equipped with 2 cameras, TF card slot, user buttons, TFT capacitive touch screen, lithium battery, speaker, microphone, 2 USB ports, and an expansion interface.




Related links:
- Official MaixPy Documentation website: https://maixpy.sipeed.com/
- Download site: https://dl.sipeed.com/
- Sipeed programming guide: https://wiki.sipeed.com/

- Seeed Studio's Sipeed Maix Amigo page - Sipeed Maix Amigo - All-in-One AIoT Development Platform Based on RV64GC (RISC-V)