Monthly Archives: March 2021

A Remote Microcontroller Laboratory

Even having several interesting and powerful electronics simulators, such as TinkerCad for Arduino, it is interesting to test and debug microcontroller applications on real hardware. With that in mind we have built a remote microcontroller laboratory, based on a set of PHP files that allow users to edit programas, compile and upload to a remote board, on a remote laboratory, and access the serial port of this board for debugging purposes and testing embedded systems. Basically, it runs a makefile. It is compatible with Arduino boards ESP32 / 8266 and also it would be easy to be used with mBed and other boards using the UF2 bootloader.

Functional demo:
http://uc.bipes.net.br:5000/

Source code:
https://github.com/rafaelaroca/RemoteMicrocontrollerLab/

On 2021, it is being used to help a microcontroller course (in Portuguese):
https://rafaelaroca.wordpress.com/courses/microcontroladores/

Happy anniversary BIPES Project with 2000 users!

BIPES project started about one year ago. Its website (https://www.bipes.net.br) was made available on March 15th 2020 and the first github commit happened in April (https://github.com/rafaelaroca/BIPES_ui_testing/).

Since then, many interesting things have happened to the BIPES Project. Here are some curiosities – thanks to Google Analytics BIPES usage report:

– Today, BIPES is already used in more than 65 countries
– More than 2000 unique users have used / are using BIPES
– Average session time / time to build a program is 5 minutes
– Germany is the country with most users (1200), followed by Brazil (330)
– Qatar, Brazil, Panama and Czechia are the countries with higher average session time (48, 13, 12 and 11 minutes respectively)

These informations were obtained anonymously by Google Analytics by monitoring BIPES page hits. Note that BIPES does not require you to create a user account and does not store / analyse created programs. However, if you want, you can share the program you created using the share button.

Also note that BIPES stands for Block Based Integrated Platform for Embedded Systems, allowing block based programming for Raspberry Pi Pico, ESP32, ESP8266, mBed / STM32, Micro:bit, and any Linux based system, such as BeagleBone and Raspberry Pi 1, 2, 3 and 4. For the other boards, BIPES generates Python code for the MicroPython or CircuitPython firmware installed on the board.

BIPES is fully open source under GPL licence and does not require any software installation on the developer machine. Simply access BIPES website, build the blocks, connect to the board, transfer the program and run it! Moreover, as BIPES is based on standard HTML + JavaScript, it works offline! Load BIPES once, and it will run without Internet connection!

The figures show BIPES usage around the world by cities and countries.

bipes contries

bipes cities

The Fantastic Mr. Feynman

The Fantastic Mr. Feynman and one of the phrases I most like:

“We make no apologies for making these excursions into other fields, because the separation of fields, as we have emphasized, is merely a human convenience, and an unnatural thing. Nature is not interested in our separations, and many of the interesting phenomena bridge the gaps between fields.”

I also strongly recommend his book: Surely You’re Joking, Mr.
Feynman!: Adventures of a Curious Character.


https://www.youtube.com/watch?v=H9fjhQMsDW4

PS.: Thanks Debora Milori for recommending this great documentary.

 

Web Serial now available in stable Google Chrome

As always, Gustavo Tamanaka (http://github.com/gtamanaka) brings great news.

Latest stable version of Google Chrome highlights:

“WebHID, WebNFC, and Web Serial have graduated from their origin trials and are now available in stable”

https://developer.chrome.com/blog/new-in-chrome-89/

https://www.youtube.com/watch?v=O-gv6zLZHKw

BIPES uses Web Serial since its very first / early implementation on Google Chrome, allowing direct access to USB devices such as Raspberry Pi Pico, ESP8266, etc, without the need of any plugin / additional software.

As Web Serial goes stable, there is no need to enable web experimental features anymore. Just open https://bipes.net.br/beta2serial/ui/, connect and create IoT / embedded applications from blocks using BIPES!

Timer and Threads on Raspberry Pi Pico with BIPES

Some days ago, Rudolf Schenke sent a message suggesting a block for threads on Raspberry Pi Pico. This site has a good explanation about threads on RPI Pico + MicroPython:
https://www.electrosoftcloud.com/en/multithreaded-script-on-raspberry-pi-pico-and-micropython/

We implemented 2 simple blocks: one for timer and one for threads.

They can be used together, so we can get 3 tasks at once! Take a look at these 2 examples:

Example 1
Timer blinks LED with 222 milliseconds interval while main prints messages to serial console at each 1 second.

pico timer

pico timer

Example 2
Timer prints “Pico Timer” to serial console at each 500 milliseconds. Thread 1 prints “Thread 1” to console at each 222 milliseconds and finally, main prints “Main: xxx” each 2 seconds, where xxx is the number of milliseconds since the Pi Pico booted.

pico timer thread

pico timer thread

Example 2 Result

pico timer thread result

pico timer thread result

EasyMQTT with BIPES and ESP8266 – Quick demonstration

amica

BIPES can send data to any MQTT server! However, if you do not have a MQTT server ready to use, just start with BIPES own MQTT server, called EasyMQTT, without the need of creating an account or
configuring anything more. Simply add the EasyMQTT block and use it!

EasyMQTT is a BIPES feature created by Caio Augusto Silva as a final paper of his Computer Engineering course at DC-UFSCar. Implementation details are available here:

http://www.bipes.net.br/papers.html (only in Portuguese, sorry)

Here are the steps to test it from from scratch:

1. Download latest MicroPython:
https://micropython.org/download/esp8266/

In this test, I used esp8266-20210202-v1.14.bin

Available here:
https://micropython.org/resources/firmware/esp8266-20210202-v1.14.bin

2. Get a board with ESP8266
For this test, I used NodeMCU from Amica (ESP8266) – the one shown at the beggining of this post

3. Check your device serial port address
Use device file manager if you use Windows or dmesg / lsusb / ls /dev/tty* if you use Linux

On my Linux machine, dmesg shows:

[263285.144051] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[263285.144052] usb 1-4: Product: CP2102 USB to UART Bridge Controller [263285.144054] usb 1-4: Manufacturer: Silicon Labs
[263285.144055] usb 1-4: SerialNumber: 0001
[263285.152678] cp210x 1-4:1.0: cp210x converter detected
[263285.154297] usb 1-4: cp210x converter now attached to ttyUSB0

So, in my case, my device is using /dev/ttyUSB0

4. Install esptool.py
If you still don’t have esptool.py, install it to upload the firmware to ESP8266. This needs to be done only once. You can download it here.

5. Erase anything in your board’s flash

esptool.py --port /dev/ttyUSB0 erase_flash

6. Write MicroPython firmware


esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash
--flash_size=detect 0 esp8266-20210202-v1.14.bin

Note: steps 4, 5 and 6 can be done using a graphical tool, such as uPyCraft

7. Create your MQTT program

Access https://bipes.net.br/beta2serial/ui/ and build the program as follows:

amica 1

In this example, the wifi network SSID is Termometro and password is Termometro too. The example updates the MQTT server with 3 variables each second. First a counter, from 1 to 100, second the milliseconds counter from the moment the board was powered on and third the ADC reading of ESP8266 builtin Analog to Digital Converter.

Direct access to program:
https://bipes.net.br/beta2serial/ui/#9ik3wd

8. Test it!

Go to the console tab, select connect and choose your board serial port address. Remember that this feature only works on Google Chrome and you should first enable experimental web features as said on our last post (https://rafaelaroca.wordpress.com/2021/03/03/block-based-programming-on-raspberry-pi-pico-with-bipes/).

Click on the Run button or on the button “Run block based program” and monitor the results on console screen. You can also view real time updates on the EasyMQTT tab.

9. Access the data sent to the cloud (MQTT Server)

In addition to the EasyMQTT tab, you can also directly access the data received by the server, allowing integrations with other programs and platforms:

Direct access to data sent by the program:
http://bipes.net.br/easymqtt/index.html?session=9too6u8

bipes easymqtt

Direct access to JSON data sent by the program for integrations:
http://bipes.net.br/easymqtt/gettopic.php?session=9too6u8&topic=ADC http://bipes.net.br/easymqtt/gettopic.php?session=9too6u8&topic=millis http://bipes.net.br/easymqtt/gettopic.php?session=9too6u8&topic=test-value

Demonstration video:

Video URL: https://youtu.be/5NQubtBMDy4

Please note, that the “EasyMQTT Start” block creates a random session ID each time it is inserted. In this case, the session is 9too6u8. You can manually set a session ID or just use the one created by the block.


Block based programming on Raspberry Pi Pico with BIPES

Create block based programs for Raspberry Pi Pico in minutes!

About one year ago, we created BIPES Project – Block Based Integrated Platform for Embedded Systems (http://www.bipes.net.br), specially focused on integrating Blockly and MicroPython with a direct connection from the web browser to the development boards – initially for ESP8266 and ESP32.

With more than 500 different users currently using BIPES (according with Google Analytics), it has several interesting features, such as the possibility of programming embedded devices without the need of installing absolutely no software or plugin. Simply access BIPES website, connect the blocks, connect to the board and get the program running. A USB/Serial/WebREPL console/terminal is integrated in the webpage, allowing direct access to serial devices.

We have now created some blocks on BIPES specifically for Raspberry Pi Pico.

It’s simple and easy to use:
(Tested / working on Google Chrome)

0. Get a Raspberry Pi Pico board with MicroPython loaded. If you still did not load MicroPython on your RPI Pico, it is as easy as copying a file to a thumb drive. Details here:
https://www.raspberrypi.org/documentation/rp2040/getting-started/

1. [for outdated Google Chrome] On Google Chrome, enable the option “Experimental Web Platform features ” (see figure). To enable the option, go to the URL: chrome://flags and activate the web platform features. This option will allow Google Chrome to directly access the USB devices connected to the serial port, without the need of additional softwares. This action must be done only once.

bipes chrome experimental features

September/2021 update: If you are using the latest Google Chrome or Microsoft Edge, you do not need to enable “experimental web platform features” anymore. It comes enabled on the default installation.

2. Go to https://bipes.net.br/beta2/ui/

3. On the target device box, select “Raspberry Pi Pico”

pico_select

4. Click on the USB Symbol

pico_select

4a. Next, click on “Serial”

pico_serial

 

4b. Select the USB port your Raspberry Pi Pico is connected to

pico_port

5. Go to the Console tab and you should be able to talk with the board! Type Enter one or twice, to check if the board is responding. If everything is ok, you should get a MicroPython prompt (>>>). Now you can interact directly with the board from the web browser!

6. Go to the blocks tab and build your program. Then simply click on the “Run” button, and your program blocks program will be translated into Python and executed!

That’s all!

If you want, you can directly share the programs you created by sending a link to your program, by clicking on the link button. Here are some working block based examples:
(just click on the link and you will open the working program)

1. Blink built in LED
https://bipes.net.br/beta2/ui/#4xcc9e

bipes rpi pico example1

2. Blink built in LED with different approach
https://bipes.net.br/beta2/ui/#jfg4h3

bipes rpi pico example2

3. Fading built in LED with PWM
https://bipes.net.br/beta2/ui/#e3eahj

pico_pwm

4. Read GPIO Input
https://bipes.net.br/beta2/ui/#dwq8df

bipes rpi pico example4

4b. Read GPIO Input and show on IOT tab

BIPES allows you to send data from Raspberry Pi Pico Serial port to a flexible and customizable IoT dashboard using USB/Serial! This example will update a LED on the IOT tab on real time according with the pin 1 state. You can easily customize the dashboard using the “wrench” button.

https://bipes.net.br/beta2/ui/#z2dot6

pico_bipes2

pico_bipes

5. Read ADC Input (raw values)
https://bipes.net.br/beta2/ui/#g56zdg

bipes rpi pico example5

5b. Read ADC Input (raw values) and show on the dashboard
https://bipes.net.br/beta2/ui/#35yvmr

pico_adc1
IOT Tab:

pico_adc2

6. Temperature sensor
https://bipes.net.br/beta2/ui/#w2aibu

pico_temp1

IOT Tab:

pico_temp2

7. Share your dashboard with anyone using MQTT / BIPES EasyMQTT

Even if your board is not connected to the Internet, BIPES offers the “EasyMQTT bridge” option, which uses your web browser as a bridge between the board (connected over USB) and a MQTT server. The browser received data on the USB port and forwards the data to a MQTT server, allowing data and dashboards to be shared with anyone, in real time over the Internet!

To use it, just enable the EasyMQTT bridge on the Console tab:

bridge1You can also click on the gear icon to setup the EasyMQTT session. There you will be able to specify a ID for your EasyMQTT session:

bridge2

I randomly typed 9764422 to be the ID of this test. You can also click on “View this EasyMQTT session”, which you send you to a page with all the data stored on this EasyMQTT session. For example:

bridge3

The EasyMQTT session above can be accessed by this URL:

http://bipes.net.br/easymqtt/?session=9764422

As data is stored on the BIPES EasyMQTT server, you can setup your dashboard to get data from the EasyMQTT session, so anyone can view your dashboard with real time updates:

bridge4

This dashboard can be accessed here and will look exactly the same you saw on the dashboard with local / USB access:

https://bipes.net.br/beta2/ui/#mkke2m

File Manager and Editor

BIPES also offer a complete file manager and text / program editor on the Browser. Without the need of any additional software or plugin, you can use BIPES on your web browser to manage and edit files on the board connected on the USB Port!

bipes_file_manager

BIPES OFFLINE
If you need, you can download BIPES for offline usage. Go to:

https://github.com/BIPES/BIPES/releases/

Download bipes_offline.zip, extract the ZIP File to a folder and open index.html on your favorite browser. You will be able to use BIPES to program, monitor and manage your Raspberry Pi Pico without Internet connection.

Demonstration video (english):

Demonstration video (portuguese):
https://www.youtube.com/watch?v=er4cQtDe5qU

BIPES Source code is available on github:

https://github.com/BIPES/BIPES