Wednesday, February 8, 2023
Google search engine
HometelecomESP32 MQTT with MicroPython Programming

ESP32 MQTT with MicroPython Programming

ESP32 MQTT with MicroPython Programming

ESP32 is a system on chip microcontroller that comes with multiple inbuilt features like Wi-Fi, BLE, dual-core processor, inbuilt sensors, OTA programming, low power consumption etc. which makes it stand apart from its predecessors.

ESP32 is a system on chip microcontroller that comes with multiple inbuilt features like Wi-Fi, BLE, dual-core processor, inbuilt sensors, OTA programming, low power consumption etc. which makes it stand apart from its predecessors.

The IoT (or Internet of Things) is a network of interconnected computing devices like automobiles, digital machines with inbuilt sensors and each with a unique identifier along with the ability to communicate data over a network without any human intervention.

In this tutorial, we will learn how to program ESP32 to implement the MQTT protocol using the MicroPython programming language. We will publish the Hall sensor readings/values from ESP32 to ThingSpeak over the MQTT protocol.

MQTT (or Message Queuing Telemetry Protocol)

MQTT is a communication/messaging protocol for IoT applications. It is a Publish and Subscribe protocol to communicate data between the internet-enabled devices.
A broker is a kind of handler or acts as an interface medium between the publisher device or transmitter and the subscriber device that is the receiver. The broker’s role is to handle or filter all the incoming data from the publisher and distribute them to the subscribers in the most efficient way.

Role of a broker in MQTT protocol:

  • Receiving data or messages from the publisher or transmitter (i.e., ESP32)
  • Filtering the received data.
  • Determining the interested subscriber in each information packet or message.
  • Forwarding the data to the interested subscriber or receiver device.

There are multiple brokers available to handle and distribute the information and in this tutorial, we are using the ThingSpeak as an MQTT broker.

Hall Effect Sensor
The ESP32 module offers some inbuilt sensors and the Hall Effect sensor is one of them. It is a transducer that responds with a change in its Hall voltage (or output voltage) when placed in a magnetic field.
The Hall-effect comes into existence when the magnetic field makes the current (flowing inside a conductor) deviate from its path.

Software and Hardware requirements

  • uPyCraft IDE
  • MQTT Broker (ThingSpeak)
  • ESP32 development board.

Installing uPyCraft IDE for MicroPython programming in ESP32 (Windows)
To program the ESP32 using the Micropython firmware, it is recommended to use either uPyCraft IDE or Thonny IDE. In this tutorial, we are using the uPyCraft IDE.
Note: Before installing the uPyCraft IDE it is required to install the latest version of Python.

  • Once the Python installation file is downloaded successfully. Open the file.
  • Enable the Add Python 3.10 to Path at the bottom and click on Install Now.
  • Click ‘OK’ once it is installed successfully.
    Flashing the MicroPython firmware to ESP32 module:
Whether you are using the ESP32 or ESP8266, for each module it is required to install the Micropython firmware into ESP32 (because MicroPython is not flashed into the ESP32 by default).
● Click on the .bin file to download the ESP32 MicroPython firmware.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments