Index

Group Assignment: - compare the performance and development workflows for other architectures

Group Assignment#

In the group assignment we selected to explore and investigate the BBC micro:bit and the Espressif ESP32 chip. Asano-san had a lot of fun (and made a lot of sounds and noise) with BBC micro:bit, I went through the steps to program a circuit with the Espressif ESP32, the Barduino2.0 board. Jun-san made the board and did a local documentation.

Teaser and tl;dr#

ESP32 Specification#

Why use the ESP32-WROOM Series? Product Page Data Sheets, User Guides, Technical Reference Manuals

  • Operation Range: -40ºC to +125ºC
  • Ultra-low Power Consumption (how can we test that?)
  • Hybrid Wi-Fi & Bluetooth Chip
  • Dual Core
  • Core clock maximum freq: 240Hz
  • Flash (MB) 4, 8, 16

Step 1: ESP32 Description File#

  • Install additional Board Manager for the ESP32 package
  • Open Ardinoo > Preferences… > Additional Board Manager
  • Add thttps://dl.espressif.com/dl/package_esp32_index.json to the list
  • Restart the Arduino.app for the Package to appear in the Package Manager

Step 2: Install the ESP32 Software#

  • Search for ESP32
  • Install the package esp32 by Espressif System. I installed version 1.0.5

Step 3: Connecting a FTDI Cable#

  • I am connecting with my (newly acquired) USB-to-UART FTDI cable my computer with the board.
  • The shiny black side neeeds to be on top (convention)
  • The red LED on top indicates that the chip is getting power.

Step 4: Echo#

I downloaded the Neil’secho program and opened it in the Ardunio IDE.

A quick lsusb confirmed the serial number of the board.

Select the ESP Dev Port with your board’s serial number.

After uploading the program, I got the following response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
*Uploading error:
Arduino: 1.8.13 (Mac OS X), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

Sketch uses 204216 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13476 bytes (4%) of dynamic memory, leaving 314204 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.0-dev
Serial port /dev/cu.usbserial-AQ01D57A
Connecting........_____....._____....._____....._____....._____....._____.....____An error occurred while uploading the sketch
_

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

Ok, interesting.

I went into full debugging mode, searching for the error, and tried the following solution attempts to solve it:

  • Holding down button while uploading: no
  • Holding before connecting appears: no
  • Change upload speed setting to 115200, press button after coonnecting appears: no
  • Install esp32 library 1.0.4 (instead of 1.0.5): no

After a creative pause, and some re-reading of the japanese documention I realized I was making a mistake with the button/slider settings:

The board has a Reset Button (top left) and a Mode Switch (bottom right), which are involved in the choreography of uploading a program.

  • Before uploading, put the switch to Programming Mode (switch to left)
  • Upload the Program
  • When the word ‘Connecting’ appears in the Arduino Consle, press the Reset Button, otherwise you get the error

Uploading works! No error messages.

I open the Arduino Serial Monitor, and type a message, which should be echoed by the board…

Ok… no echos… hmmm.

Right! Run Mode. Mode Switch to right!

Pressing the Reset Button!

Echo works!

Step 5: Installing PySerial#

Installing the Python-based Serial Monitor PySerial

1
python -m pip install pyserial

Get the USB Serial Number with lsusb (TODO: make a filter script wrapping lsusb, show only external USB devices - and not all Apple internals) lsusb

Connect the Serial Montior

1
python3 -m serial.tools.miniterm /dev/tty.usbserial-AQ01D57A 115200

Where /dev/tty.usbserial-AQ01D57A is your device ID, and 115200 is the baud rate.

Step 5: WifiSimpleServer#

The Echo was a nice, minimal start, now it’s getting interesting. Turning the board into a Server, controlling the LED from a Webbrowser. The sample script comes from Espressif’s GitHub Repo and can also be openend in the Arduino IDE via File > Examples > Examples for ESP32 Dev Module > Wifi > SimpleWifiServer.

I set the Kamakura Wifi-Settings in the code and defined the LED.

1
2
3
4
const char* ssid     = "yourssid";
const char* password = "yourpasswd";

#define LED_BUILTIN 13

and doing the usual Switch-Left, Upload, Reset, Switch-Right route started the program.

In the Serial Monitor the IP Address for the ESP32 is being shown:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4

Connecting to fablabkamakura_wifi
.....
WiFi connected.
IP address: 
192.168.1.45

Pointing a browser to the local IP Adress shows the basic site that has been created by the ESP32:

1
2
3
4
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.print("Click <a href=\"/H\">here</a> to turn the LED on pin 13 on.<br>");
client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 13 off.<br>");

Going to 192.168.1.45/H turns the LED on, going to 192.168.1.45/L turns it off.

I wanted to know, if applying some CSS styles would also work:

1
2
3
4
5
6
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.print("<style>body { background: #00f; color: #fff; font: 50px Helvetica, sans-serif; } a.hover { color: #0f0; }</style>");
// the content of the HTTP response follows the header:
client.print("LED 13: ");
client.print("<a href=\"/H\">ON</a> <a href=\"/L\">OFF</a>");

Hmmm. Not quite.

How about adding <html><body>?

1
2
3
4
5
6
7
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.print("<html><body>");
client.print("<style>body { background: #00f; color: #fff; font: 50px Helvetica, sans-serif; } a.hover { color: #0f0; }</style>");
// the content of the HTTP response follows the header:
client.print("LED 13: ");
client.print("<a href=\"/H\">ON</a> <a href=\"/L\">OFF</a>");

Also works when connecting more than one browser!

The modified SimpleWifiServer code is linked here.

Learning Outcomes#

I was positively impressed by both the capapilities and possibities of both the BBC micro:bit and the ESP32. It was a very, very satisfying moment to get the webserver to run on the ESP32 and control the LED via a website.

I only caught some glimpses of the BBC micro:bit - and the Scratch programming enviroment for kids. By chance, my 11-year old also asked me this week how to do programming “with blocks, and not that strange text that you are always doing.” Turns out they are starting to learn Scratch in school, and as the BBC micro:bit can also be programmed in Scratch, I am getting a BBC micro:bit for her.

And I will most likely use a ESP32 for my Final Project.


micro:bit#

The micro:bit is a board developed mainly by the BBC, and is often used in STEM education.

img02

part spec
MCU 32 bit ARM Cortex M4base Nordic nRF52833, 64MHz, with BLE
RAM 128KB
LED 25pcs, can use as light sensor
Swith 2
Touch Sensor 1
Speaker 1
Microphone 1
Acceleration sensor 1
Magnetic force sensor 1
Size 43 × 52 × 11 mm
Weight 9 g

Programming is done from a web browser. It was a block-based no-code environment, and the conditional branching and use of sensors was intuitive and easy to understand.

img03 img04

We try to detect touch and play sounds program.

M5 Stack#

M5 Stack is equipped with ESP32, it can handle Wi-Fi and Bluetooth communication and can be developed in the Arduino environment.

img05

part spec
MCU MPU6886 + BMM150
Interfaces SPI x 1, I2C(GROVE) x 1, UART x 2, I2S x 1, microSD slot x 1
LCD 320 x 240 Color TFT LCD
Speaker 1 W
Vattery 3.7 V / 150 mAh
Tempreture 0 ~ 40℃
Size 54 × 54 × 17 mm
Weight 120 g

When programming from Arduino, have to add esp32 board, include m5stack library. In case of M5 Stack Gray, choose M5 Stack-Core-ESP32.

img06 img07 img08

Then, We ran random triangle showing program.

1
2
3
4
5
6
7
8
9
#include <M5Stack.h>
void setup() {
  M5.begin();
  M5.Power.begin();
}
void loop() {
  M5.Lcd.fillTriangle(random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1), random(0xfffe));
  M5.update();
}

imgADD