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:
In this test, I used 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:
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:
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:
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
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.