Giter VIP home page Giter VIP logo

mqtt-demo's Introduction

MQTT Network for data Exchange - Raspberry Pi & ESP32 Microcontrollers

Read the :- complete article here. Watch Video :- on Youtube.

The code for this project is created to demonstrate data exchange mechanism between Raspberry Pi & ESP32 Microcontrollers using MQTT network. In a MQTT network, the communication between devices takes place using a Publish & Subscribe mechanism. Messages can be published on a specific topic by a device. The devices that are subscribed to that topic can receive the message. Devices can send and receive data through a MQTT broker.

No sensor is required to be interfaced for this project.

The Code

rpi_mqtt_clients (Raspberry Pi code)

There two Python scripts in this folder. Both connects the broker as clients with following functionality

client_pub.py

This file publishes a simple counter value on a topic 'rpi/braodcast' every 02 seconds. This topic is subscribed by all other clients on the network.

client_sub.py

This file subscribe to all the 03 topics (one as mentioned above and other two topics are used by ESP32 to publish thier data). The data received by other clients is printed on the terminal.

esp32_clients (ESP 32 code)

This folder contains the C code written in Arduino IDE for 02 ESP32 microcontrollers. The code for both the ESP32 is completely identical. The only difference in the two codes is the name of the client and the topic to which it publishes. Both the ESPs do the publish & subscribe simultneously. One ESP publishes to the topic 'esp/sensor1' and the other publishes to 'esp/sensor2'. They both subscribe to 'rpi/broadcast' and receive data from this topic.

The Information Flow

The task of Python scripts running in Raspberry Pi and C code running in ESP32 can be summarised by the following diagram

You can replicate this demo code on your devices and understand the MQTT communication. Later you can modify it for practical use by interfacing sensors and actuators as per your requirement.

mqtt-demo's People

Contributors

jiteshsaini avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.