Connect your ESP32 Devices to a powerful Toit Environment, and manage the data with Qubitro Cloud.
![Toit with Qubitro](https://leadup.in/blog/wp-content/uploads/2022/11/img_6363d3e91c731.jpg)
Things used in this project
Hardware components | ||||
RAKwireless RAK11200 esp32 WiFi Module | × | 1 | ||
![]() | RAKwireless WisBlock Base Board RAK5005-O | × | 1 | |
Software apps and online services | ||||
Toit | ||||
![]() | Qubitro |
Story
Toit with Qubitro:
Have you considered creating your own Internet of Things (IoT) product? Yes, thousands and thousands of codes are sufficient. But how about managing the device and devices data without any physical interactions?. These are the critical things when it comes to developing and managing an IoT Product, We can do this all in a very simple manner, will see that in this blog post.
Do you know about Toit & Qubitro?
Toit is built on the free and open source Toit language, so you write your applications in a high-level, memory-safe language and let the battery-optimized virtual machine execute them efficiently on your ESP32s. Fast to develop, safe to run.
Toit Console
Toit allows you to control your ESP32 devices over the air, as well as upload and update software. As a result, large-scale deployment is simple. After connecting and deploying your scripts to the ESP32 via Toit, we’ll need a cloud partner to visualize our device data. Here comes Qubitro; if you want to know more about Qubitro please visit Qubitro Blog.
![](https://leadup.in/blog/wp-content/uploads/2022/11/image_pQQJYD1JIj.jpg)
Let’s configure the Toit :
First, you have to connect your ESP32 devices to Toit. For this, you have, signup for an account with Toit.
Here I have used Rak11200 Wi-Fi core as an esp32 development board. for more details https://docs.rakwireless.com/Product-Categories/WisBlock/RAK11200/Quickstart/
![toit.io](https://leadup.in/blog/wp-content/uploads/2022/11/image_N3B0vhW0TH.jpg)
toit.io
The interface will look like this once you’ve signed in with Toit.
![toit console](https://leadup.in/blog/wp-content/uploads/2022/11/221543_image.jpg)
toit console
Then, from the left menu bar, select the Serial tab and click on Ready.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221547_image.jpg)
When you click Ready, it will look for any ESP32s connected to your computer’s com port.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221552_Screenshot__18.jpg)
Following that, it will display the various com ports; select the suitable com port and click Connect.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221557_image.jpg)
Then, in order to control through network, you must burn Toit firmware to the esp device. To do so, go to the menu and select Provision.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221559_image.jpg)
To provision the ESP32, enter the Wi-Fi credentials. It took a few seconds for the firmware to upload, and then it will connect to your Wi-Fi network.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221616_image.jpg)
Navigate to the Device tab using the navigation bar. There, you’ll find your device listed.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221619_image.jpg)
When you open your device and look about, you’ll notice a variety of options such as device status, logs, and configuration.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221623_image.jpg)
Now that we’ve successfully linked our ESP32 to Toit Console, the next step is to set up the Toit Programming environment. You can find this information in the Toit Docs.
Let’s configure Qubitro :
To begin, you should first create a Qubitro account. Then, as seen below, you should create a project.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221652_image.jpg)
After you’ve created a project, pick device brand and device model to add a device to it.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221653_image.jpg)
After creating a device, you’ll need the device credentials for further process.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221654_image.jpg)
Copy the device ID and the Device Token from the portal.
Let’s move on to programming:
Now that we’ve set up both the Toit and Qubitro environments, we’ll need some Toit Lib packages to connect our Toit Device to Qubitro.
![](https://leadup.in/blog/wp-content/uploads/2022/11/22170_image.jpg)
toit pkg install github.com/kasperl/toit-qubitro – Qubitro library package for Toit
Open VS Code and pick the Toit Extension after installing the Qubitro package with your Toit. It will automatically redirect you to the Toit authentication page, where your Toit Esp32 devices will appear following a successful login.
![](https://leadup.in/blog/wp-content/uploads/2022/11/22174_image.jpg)
I’ve provided the random data values to Qubitro in this, but you can input your own sensor data here as well. Then, in the code, replace the device ID and tokens with your Qubitro Device ID and tokens.
import qubitro
import gpio
main:
led_pin1 := gpio.Pin 12 --output
led_pin2 := gpio.Pin 2 --output
led_pin1.set 1
led_pin2.set 0
client ::= qubitro.connect
--id="253c34c6-af14-45fd-9866-c6add0117147"
--token="VpVrlbUfn6jjrTTdddNgMfsjCI6ko8-iki63so9t"
client.publish { "Data1": random 1000,"Data2": random 1000, "Data3":random 1000}
print "Yeah im uploading!! "
led_pin1.set 0
led_pin2.set 1
sleep --ms=10000
led_pin1.close
led_pin2.close
You can execute the program directly from the.toit file, however if you want to use this code as an application (Boot up Script for your device), you’ll need to deploy the.yaml file.
# filename: Qubitro-Client.yaml
# This app specification file executes the 'Weather Station' app on install
# and subsequently every 5 seconds.
name: Qubitro Client
entrypoint: Qubitro-Client.toit
triggers:
on_install: true
on_interval: 5s
Here is the sample code to connect Rakwisblock and Toit with Qubitro.
Deployment:
Once you’ve entered your code into VS Code and selected the Device to deploy the program, the deployment process is quite straightforward. After that, press the deploy button, which will prompt you for the.yaml file. Select the proper yaml file, and the program will begin to upload.
This is the message that appears after successful uploading.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221723_image.jpg)
Select your device’s Application area in the Toit interface, and you’ll see the program, which we uploaded using VS Code.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221725_image.jpg)
Open up the Qubitro portal and check for the incoming data.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221726_image.jpg)
Visualize the data according to the usage.
![](https://leadup.in/blog/wp-content/uploads/2022/11/221728_image.jpg)
You can see all our readings are showing up perfectly…😎
Helpful links
Create a free account on Qubitro Portal
Visit Qubitro MQTT documentation
Code
https://github.com/pradeeplogu0/Qubitro-MQTT/tree/master/Qubitro-TOIT