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.
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.
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.
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.
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.
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
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.
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.