Connect Your Magicblocks App With ESP 32

by magicbit in Circuits > Wireless

226 Views, 0 Favorites, 0 Comments

Connect Your Magicblocks App With ESP 32

_NOXMX1Gcoy.jpg

Send data to and from the Magicblocks app to ESP32.

Supplies

  • SparkFun ESP32 Thing

Story

Setting up the app

We wont be getting into details on how to setup the Magicblocks app. We have discussed this in a previous tutorial. The link is given below.

https://www.instructables.com/Send-Data-From-Your-Phone-to-Magicblocks/

The things you should be mindful is the publish and subscribe topic which you enter. They should be replicated in the ESP32 code as well. Both the app and the ESP 32 device should use the same MQTT broker as well.

Configuring the ESP32

This the code we will be using,

What is done in the above code is that the ESP32 is listening for any messages on the topic 'Databox'. Also it is publishing a random number between 1 and 10 to the topic 'Databox2'.

Before proceeding further keep in mind to fill the ssid password and mqtt broker with the real values.

If everything goes well the code should compile error free and get uploaded. After uploading, open the serial monitor to see whether your ESP32 connected to the WiFi and the MQTT Broker.

Then you have to open the app and send data. (If you have trouble with operating the app see the tutorial in the link given at the beginning). For this tutorial we will send data from the temperature sensor in the app. You will see the received data on the serial monitor.

For the data sent from the ESP32, they should appear as pop up notifications on your phone.