SlideShare a Scribd company logo
6
Most read
14
Most read
15
Most read
Department of Electrical Engineering and Information
Technology
Chair of Measurement and Sensor Technology
Project Documentation
„Project Lab Embedded Systems “
Member: Lavanya Loganathan (455840)
Project: WIFI MESH NETWORK
Date: 2017-06-26
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 2 of 20	
	
TABLE OF CONTENT
1. Objective…..…………………….………………………………...................3
2. Members Responsibility……………….………………………………….….3
3. Introduction...………………………………………………….......................3
4. Hardware…......…………………………………….……………………...…4
4.1.ESP32 Features…………………………………………………...4
5. Software for Development……………………………………..…………….5
5.1.Arduino Installation…………………………………………...….5
5.2.Installing Python 2.7.x…………………………………………5
5.3.Gitbash…………………………………………………………5
5.4.Preparing the ESP32 board in in Arduino IDE………………………7
5.5.Uploading Codes into ESP-WROOM-32……………………….8
6. MQTT Protocol……………….……………………………………………..9
7. Development Flow Chart…...………………………………………………10
8. Used Keys and Syntaxes……………………………………………………11
9. Implemented Network Topology using cloud service…...…………………13
9.1.Star Topology …………………………………………………13
9.2.Mesh Topology………………………………………………...14
10.Conclusion…………………………………………………………………..15
11.References…………………………………………………………………..15
12.Arduino Software Codes……………………………………………………..16
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 3 of 20	
	
Figure1: ESP32 WROOM
1. Objective
Create a WiFi Network with ESP-WROOM-32 and Share data with different network
Topologies (Mesh and Star) using cloud service via MQTT protocol.
2. Member Responsibilities
Lavanya Loganathan Mac address detection, Receive Packets
Raziuddin Khazi Mqtt, Star network topology
Vivek Anand WiFi scan, Send Packets
3. Introduction
The project WiFi mesh network is aimed to build a platform for wireless communication
between multiple ESP32 devices. ESP32 is dual core high performance, low cost.
Integrated WiFi dual mode Bluetooth microcontroller device. Each Esp32 device can
interface with sensors (Like
temperature, humidity, pressure etc.)
and the sensors data are shared
among them via different network
topologies (Star, mesh etc.).
In this project, devices communicate
via a server called MQTT (Message
Queue Telemetry Transport) which is a light weight machine-machine protocol built over
TCP/IP. The sensor information is shared through a broker via publish and subscribe
messaging pattern. Here Broker is mediator which receives message packet from one
ESP device(publishing) and send/forward it to the other subscribed devices. The
advantage of using MQTT is its lightweight and auto reconnecting feature when
disconnected. MQTT is popular in many educational institutions and the Facebook
messenger app also uses some features of MQTT.
This portable device (wireless communication in such a small size) can be purchased for
less than €15. The Open source Arduino software compatibility for ESP32 setup makes it
more interesting and attractive. Wifi device at this price is a completely satisfying
reward!
There are many possibilities when it comes to building projects with ESP-WROOM-02.
It can be deployed in Home and Industrial automation, also can be integrated with IoT
devices.
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 4 of 20	
	
Figure 2: Pin Layout of ESP32
4. Hardware
ESP-WROOM-32
ESP32 is a 2.4 GHz dual-core with inbuilt Tensilica LX6 microprocessor with a
performance of 600 DMIPS (Dhrystone million instruction per second). In addition; this
small device comprises 520 KB of SRAM, 16 MB of flash on board memory. This chip
can be operated between -40° C to 125° C temperature with operating voltage around 2.2
to 3.6 V hence makes it more suitable for industrial use. In deep sleep mode, the ESP32
consumes 2.5 µA according to the manufacturer which is quite good for industrial
purpose.
4.1 ESP32 Features
• 2.2V to 3.6V operating voltage
• 32 GPIO pins:
o 3x UARTs, including hardware flow control
o 3x SPI
o 2x I2S
o 12x ADC input channels
o 2x DAC
o 2x I2C
o PWM/timer input/output available on every GPIO pin
o Supports external SPI flash up to 16 MB
o SD-card interface support
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 5 of 20	
	
5. Software for Development
5.1 Arduino Installation
5.2 Installing Python 2.7.x
5.2.1 Go to Python website and download the 2.7.x version
https://www.python.org/downloads
5.2.2 Open the downloaded file and follow the installation instructions
5.2.3 Select the option “Install for all users”
5.2.4 In Customize Python 2.7.X, enable the last option “Add python.exe to Path”
5.2.5 Complete the further installation
5.3 Gitbash
5.3.1 Download and install Git and
Git GUI git-scm.com
https://git-
scm.com/download/win
5.3.2 Install Git GUI and select the
Clone Existing Repository
option.
Figure 3: Python Installation
Figure 4: GUI Clone
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 6 of 20	
	
5.3.3 Then, choose the source and destination:
Source Location: https://github.com/espressif/arduino-esp32.git
Target Directory: Your_Arduino_IDE_Folder_Path/hardware/espressif/esp32
(in my case, it looks like:
C:Program Files (x86) Arduino hardware espressifarduino-esp32)
5.3.4 Press the “Clone” button	
5.3.5 Open the folder:
Your_Arduino_IDE_Folder_Path/hardware/espressif/esp32/tools
5.3.6 Open the “get.exe” file and wait for it to download/prepare the files
Figure 5: GUI Source and destination selection
Figure 6: get.exe download window
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 7 of 20	
	
5.4 Preparing the ESP32 board in Arduino IDE
5.4.1 Adding Libraries to Arduino
Download ESP-32 Library: https://github.com/espressif/arduino-esp32 and
copy to the following path C:Program FilesArduinohardwareespressif
5.4.2 Libraries are available to use for Arduino and ESP32 separately, but both are
not much suitable for ESP32 operation, so download a combined library
from GitHub to execute further.
Issue: When we used separate libraries, and tried to run some example codes
of arduino with ESP32, we found an error of “Wifi mode class not defined”.
Reason: The Class Wifi is defined in both libraries (arduino and esp32) and
Figure 7: ESP32 Library Download
	
Figure 8: Aurduino- ESP32 Library issue
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 8 of 20	
	
while executing default Arduino library was selected not the ESP 32.
Solution: Rename Wifi.h to any other name (eg. Wifi_arr.h) and execute
again and this time it selects ESP32 WiFi class.
5.4.3 Run any available sample program and analyze
5.5 Uploading Codes into ESP-WROOM-32
To write Arduino programs to the ESP-WROOM, we need an USB serial adapter to
connect it to a PC. For the Arduino UNO we’ve been using, a normal USB cable is
fine but the ESP-WROOM-02 requires serial conversion to connect to a PC. There
are several types of this adapter: 3.3v only, 5v only, and a 3.3v/5v jumper select
type. The ESP-WROOM requires 3.3v supply so we need either the 3.3v or the
3.3/5v selection jumper.
5.5.1 Select your board in Tools > Board menu (in my case it’s the ESP32 Dev
Module) 	
5.5.2 Select the COM port
5.5.3 To make your ESP32 go into
Downloading/uploading mode:
hold the BOOT button and
press the EN button to reboot
your ESP32
Figure 9: USB Serial Communicator
Figure 9: COM port selection
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 9 of 20	
	
Publish (Topic, Data)
Publish (Topic, Data)
Subscribe (Topic, Data)
5.5.4 Press the Upload button in the Arduino IDE and wait a few seconds while the
code compiles and uploads to your board.
5.5.5 If everything goes right this what you should see:
5.5.6 Restart your ESP32 to run the newly uploaded code
6. MQTT protocol
MQTT stands for Message Queue Telemetry Transfer protocol which is
developed by IBM. It’s a light weight message publish/subscribe protocol that is
built on top of TCP/IP which send/receive data over a broker.
The MQTT client library for arduino can be added from the GIT hub, after
installation it can be seen in the example libraries.
Figure 10: ESP WROOM 32
Figure 12: MQTT Protocol
Figure 11: Uploading Codes to ESP32
Publisher SubscriberBroker
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 10 of 20	
	
No
Yes
Yes
No
No
Yes
ReceiveSend
No
Yes
7. Development Chart
publish „Topic“ Send
Send
	
Decode Packet with MAC Address
and data
Send
	 Display data information
nd
Print connected network
SSID
	
Form Packet with MAC Address
and sensor data
Client
Connected
MQTT ?
Publish to “topic”
Client
Connected
MQTT ?
Detect and Display MAC
	
Start
Connect to local Wifi network
(ssid & password)
Subscribe to „Topic“ Receive
Define MQTT and Wifi Client	
Wifi	&	MQTT	Client	
Serial print
„connecting..“
SSID			
	
Client
Connected to
Server
?
Wifi.status ()
= Connected
?
Client connect to server "iot.eclipse.org"
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 11 of 20	
	
8. 	Used	Keys and Syntaxes
8.1 Client:
ESP32 modules are used as a MQTT client, it can be configured as a publishing or
subscribing node or both to a broker/network. However, in real time, MQTT client can
be any microcontroller with TCP/IP protocol to a fully-fledged server that has a
MQTT library running.
Arduino syntax: MQTTClient <space> <client name>;
Example: MQTTClient client;
This command defines the ‘client’ as a MQTTClient name which communicates
with MQTT server.
8.2 Broker
A MQTT protocols, which handle publish and subscribe commands of clients. A
broker is primarily responsible for client authentications, authorizations and
integration to the backend systems also receiving the entire message and filtering them
accordingly to the clients.
• ESP32 microcontroller acts as a client and iot.eclipse.org as a broker. The
MQTT connection is between ESP32 microcontroller and eclipse broker.
Multiple ESP32 modules are subscribed and publish to broker.
• Always the connection is initiated by the client ESP32 by sending
“CONNECT” message and upon receiving the “CONNACK” back from the
eclipse the connection gets established. Once the connection establishes it
cannot be disconnected unless the client disconnects itself.
• After establishing the WiFi network, begin the WiFi client connection with
MQTT broker using the arduno command.
Arduino syntax : <client name> .begin(“MQTT broke ”, WiFiClient name);
Example : client. begin("iot.eclipse.org", net);
Figure 13: MQTT Protocol
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 12 of 20	
	
This will begin communicating once the WiFi is established. After connecting WiFi
client to MQTT broker, thereafter it checks wifi status. If status is connected then
proceed, otherwise reconnect the WiFi network and also reconnect WiFiClient to the
MQTT broker.
Arduino syntax: <client name> .connect(Client ID, username, password);
Example : client. Connect(“arduino_tx”, "try", "try");
[Note: Here username and password are optional.]
• Username and password (optional): This is an optional parameter but it is
recommended to use them to authenticate and authorize the client.
8.3 Client ID
An Identifier for each MQTT client, connecting to MQTT broker. It is unique per
broker.
8.4 Clean Sessions(optional)
It is the optional part, setting the clean session to true (1) means that the broker will
not store any information of the client, and setting it to false (0) will store all the
missed messages of the client.
8.5 TOPICS
A topic is a UTF-8 string which is used by broker to filter the message for each
connected client. A topic can have one or more levels which define the depth of the
communication.
Example: Sensor/Temp_node1/Temp_node2
Here Temp_node2 is second layer that can be accessed by first layerTemp_node1
only.A ‘+’ operator also called as wildcard is used to create a single layer whereas ‘#’
is used to create multilayered topics.
8.6 PUBLISH
Publish is a keyword using which an ESP32 can send its message to the broker in
string format.
Arduino syntax- Publish (Topic name, Payload)
Example: Publish (Temprature_sensor, 100);
8.7 SUBSCRIBE
An ESP32 can subscribe to a single layer to multiple layered topics such that any
changes/ updated information can be received to the subscribed client.
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 13 of 20	
	
Publish Publish
PublishPublish Subscribe
Arduino syntax: Subscribe(Topic_name);
Example: Subscribe(Temprature_sensor);
8.8 Message Received
The message Received will be in string format hence ESP32 decodes the string packet
and take appropriate actions.
Arduino syntax: messageReceived(String <Topic name>, String <payload>, char
*<size>, unsigned int <length>)
Example: void messageReceived(String Temprature_sensor, String payload, char
* bytes, unsigned int length)
• String Topic compares the topic name with the subscribed topic, if topic
matches then it accepts the payload otherwise not.
• String payload contains the string data received over the MQTT broker which
can be extracted later.
• Char *bytes contains the data received in bytes.
• Length contains the length of the string.
9. Implemented Network Topology
9.1 STAR Topology
In star topology, multiple ESP slave devices publish to the broker (iot.eclipse.org)
using “/esp_star” ID and one master ESP hub is subscribed to the same broker by
“/esp_star” ID. The ESP hub is the central node and all other ESP slave nodes are
connected to the central hub node.
.
Figure 14: WiFi Star Connection of ESP32 Modules via MQTT
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 14 of 20	
	
Note: Here all the nodes
Publish & Subscribe both
Whenever sensor packet is published by the slave ESP to the broker, the subscribed
ESP hub receives the message.
Features of Star Topology
• Every node publishes withthe same client ID but at different time.
• Hub is subscribed to the same Client ID and receives message at different time.
Advantages of Star Topology
• Adding slave nodes is easier
• Easy to setup and modify
• Only that node is affected which has failed, rest of the nodes can work smoothly
Disadvantages of Star Topology
• Expensive to use
• If the hub fails then the whole network is stopped because all the nodes depend
on the hub.
9.2 MESH Topology
In the mesh topology, every ESP device has a direct point-to-point connection to
every other node. Because all connections are direct, the network can handle very
high-volume traffic. It is also robust because if one connection fails, the others remain
intact. Security is also high since data travels along a dedicated connection
Figure 15: WiFi Mesh Connection of ESP32 Modules via MQTT
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 15 of 20	
	
In Mesh topology, each node publishes and subscribe to “/esp_mesh” ID, when a
device sends the sensor packet it is received by all other nodes. In other words, every
node acts as a star node. All nodes subscribe and publish to the same client ID.
Features of Mesh Topology	
• Fully connected.
• Data routing is possible.
Advantages of Mesh Topology
• Each connection can carry its own data load.
• Provides security and privacy.
• Data routing can extend to multiple nodes.
Disadvantages of Mesh Topology
• Installation and configuration is difficult.
• Complex design
10. Conclusion
Implementation of Star and Mesh network topologies using ESP32 via MQTT
communication protocol is successful and data packets are shared among the devices.
11. References
• Kolban-ESP32, Neilkoblan book on Esp-32, May 2017
• esp32_datasheet (www.esp32.net)
• http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-
windows-instructions/
• https://espressif.com/en/esp-wroom-32
• http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-
establishment
• http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices
• http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-
windows-instructions
• https://github.com
• https://espressif.com
• https://www.arduino.cc
• https://www.python.org
• https://iot.eclipse.org
• http://mqtt.org
• https://www.sparkfun.com
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 16 of 20	
	
12. Arduino Software Codes
#include<WiFi.h>
#include<MQTTClient.h>
const char ssid[] = "TP-LINK_KHAZI";
const char pass[] = "khazi1234";
byte mac[6];
WiFiClient net;
MQTTClient client;
unsigned long lastMillis = 0;
void connect();
void setup()
{
// select the baudrate and begin the wifi communication
Serial.begin(115200);
WiFi.begin(ssid,pass);
delay(100);
// Connect WiFi client to the MQTT broker
client.begin("iot.eclipse.org",net);
connect();
}
void connect(){
// Check WiFi status,if not connected the try reconnecting
Serial.print("Connecting.. ");
while(WiFi.status()!=WL_CONNECTED){
Serial.print(".");
delay(1000);
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 17 of 20	
	
}
// Displays connected access point name(SSID name)
Serial.println("");
Serial.print("Connected to ");
Serial.println(WiFi.SSID());
// Connecing from local server to the IoT.eclipse.org
// If not connected to the MQTT server then wait till reconnects
Serial.print("nConnecting....");
while(!client.connect("arduino_rx","try","try")){
Serial.print(".");
}
// Displays the MAC address of the device
WiFi.macAddress(mac);
Serial.println("");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[1],HEX);
Serial.print(":");
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 18 of 20	
	
Serial.print(mac[0],HEX);
//client subscribes to the topic name "esp_star"
client.subscribe("/esp_star");
}
void loop()
{
// this should always be in loop, to keep MQTT active/alive
client.loop();
delay(10);
if(!client.connected())
{
connect();
}
}
void messageReceived(String topic, String payload , char *bytes, unsigned int length)
{
// Predefined MAC address of the devices for decoding the incomming messages
String sub_temp,sub_temp1;
String esp_r1 = "64";
String esp_r2 = "72";
String esp_r3 = "244";
String esp_r4 = "252";
String esp_green = "156";
// Extraction of 2 digit or 3 digit MAC address into temporary variables
sub_temp = payload.substring(0,2);
sub_temp1 = payload.substring(0,3);
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 19 of 20	
	
// Decoding the Message and segregating based on the MAC ID of the device
// If MAC ID match the predefined MAC ID then displays the information on the screen
// Its prior known tha,
// Temperature sensor is connected to esp_r1,
// Pressure sensor is connected esp_r2
// Humidity sensor is connected to esp_r3
// Hall effect sensor connected to esp_green
if(sub_temp == esp_r1){
Serial.print("Temp : ");
Serial.println(payload.substring(2));
}
else if(sub_temp == esp_r2){
Serial.print("Pressure : ");
Serial.println(payload.substring(2));
}
else if((sub_temp == esp_r3)||(sub_temp1 == esp_r3)){
Serial.print("Humidity : ");
Serial.println(payload.substring(3));
}
else if((sub_temp == esp_r4)||(sub_temp1 == esp_r4)){
Serial.print("Accelerometer : ");
Serial.println(payload.substring(3));
}
else if((sub_temp == esp_green)||(sub_temp1 == esp_green)){
Serial.print("Halleffect sensor : ");
Serial.println(payload.substring(3));
Technische	Universität	Chemnitz	
Chair	of	Measurement	and	Sensor	Technology	
Prof.	Dr.-Ing.	Olfa	Kanoun	 	
	
Group	18:	Wi-Fi	Mesh	Network	 	 Page 20 of 20	
	
}
//If any MAC ID did not match then display "some problem"
else{
Serial.println("Some problem..");
}
}
To Send data from nodes to hub in star topology:
void loop()
{
client.loop();
delay(10);// <- fixes some issues with WiFi stability
String pld = "";
pld += mac[5];
if (!client.connected()) {
connect();
}
// publish a message roughly every second.
if (millis() - lastMillis > 2000) {
lastMillis = millis();
//float sen_val = analogRead(5);
float x = 19.45;
pld += x;
//publish sensor packet(pld)to the mqtt broker
client.publish("/esp_star",pld);
}
}
Note: Rest of the code remain same as previous code, only change in void loop() function.

More Related Content

What's hot (20)

PPTX
Bluethooth Protocol stack/layers
Jay Nagar
 
PDF
Teknologi Jaringan Berbasis Luas (WAN)
seolangit
 
PDF
Digital System Design and FPGA
Amairullah Khan Lodhi
 
PDF
volte call flow - SIP IMS Call Flow - MO and MT Call - Volte Mobile originati...
Vikas Shokeen
 
PDF
Metro ethernet-dg
Dereco Tecnologia
 
PPTX
Mobile computing security
Zachariah Pabi
 
PDF
Soc architecture and design
Satya Harish
 
PDF
Overview 3GPP NR Physical Layer
Eiko Seidel
 
PPTX
Wifi Technology
Pak Cik Nan
 
PDF
自由/開源授權的ABC
Florence T.M. Ko
 
PDF
Sensor networks: 6LoWPAN & LPWAN
Agence du Numérique (AdN)
 
PPTX
SOC Verification using SystemVerilog
Ramdas Mozhikunnath
 
PPTX
LTE Advance Pro
Mohammed Abuibaid
 
PPTX
Introduction to FPGAs
Sudhanshu Janwadkar
 
PDF
IoT Programming on the Raspberry Pi
Damien Magoni
 
PDF
fpga programming
Anish Gupta
 
PPT
The constrained application protocol (CoAP)
Hamdamboy (함담보이)
 
PPTX
Materi 3 Perangkat dan Aksesoris IKR IKG FTTX
5h4r3
 
PDF
6LoWPAN: An open IoT Networking Protocol
Samsung Open Source Group
 
PPTX
Ipv6 the next generation protocol
PRADEEP Cheekatla
 
Bluethooth Protocol stack/layers
Jay Nagar
 
Teknologi Jaringan Berbasis Luas (WAN)
seolangit
 
Digital System Design and FPGA
Amairullah Khan Lodhi
 
volte call flow - SIP IMS Call Flow - MO and MT Call - Volte Mobile originati...
Vikas Shokeen
 
Metro ethernet-dg
Dereco Tecnologia
 
Mobile computing security
Zachariah Pabi
 
Soc architecture and design
Satya Harish
 
Overview 3GPP NR Physical Layer
Eiko Seidel
 
Wifi Technology
Pak Cik Nan
 
自由/開源授權的ABC
Florence T.M. Ko
 
Sensor networks: 6LoWPAN & LPWAN
Agence du Numérique (AdN)
 
SOC Verification using SystemVerilog
Ramdas Mozhikunnath
 
LTE Advance Pro
Mohammed Abuibaid
 
Introduction to FPGAs
Sudhanshu Janwadkar
 
IoT Programming on the Raspberry Pi
Damien Magoni
 
fpga programming
Anish Gupta
 
The constrained application protocol (CoAP)
Hamdamboy (함담보이)
 
Materi 3 Perangkat dan Aksesoris IKR IKG FTTX
5h4r3
 
6LoWPAN: An open IoT Networking Protocol
Samsung Open Source Group
 
Ipv6 the next generation protocol
PRADEEP Cheekatla
 

Similar to WiFi mesh network(ESP32 mStar and mesh topology) (20)

PDF
ESP32 WiFi & Bluetooth Module - Getting Started Guide
handson28
 
PPTX
Human Alert Sensor
Object Automation
 
PDF
Human Alert Sensor Design
Object Automation
 
PDF
Advanced view of atmega microcontroller projects list at mega32 avr
WiseNaeem
 
PDF
IRJET- BSIOTR IT SMART LAB using IOT
IRJET Journal
 
PDF
NodeMCU || Controlling and observing a robotic car with a smartphone through...
Jiangxi University of Science and Technology (江西理工大学)
 
DOCX
Report
IshworKhatiwada
 
PPTX
Lab Handson: Power your Creations with Intel Edison!
Codemotion
 
PDF
manual Internet of ThingsArduino_IOTArdu
deepikayadav216323
 
PDF
Andrea De Gaetano - An Adventure with ESP8266 firmwares and IOT
Codemotion
 
PDF
IRJET- IoT based Smart Helmet for Coal Mining Tracking
IRJET Journal
 
PDF
Data Acquisition and Control System for Real Time Applications
ijsrd.com
 
PDF
Pradeep_Embedded
pradeep22kumark
 
PDF
ESP8266 and IOT
dega1999
 
PDF
Advanced View Arduino Projects List - Use Arduino for Projects {4}.pdf
Ismailkhan77481
 
PDF
IOT and embaded_Internship final Report-2.pdf
chandanml127
 
PDF
Network Design For Alliance Française de Dhaka
MD. Naimur Rahman
 
PPTX
Tac Presentation October 72014- Raspberry PI
Cliff Samuels Jr.
 
PDF
Decibel meter using IoT with notice board
IRJET Journal
 
ESP32 WiFi & Bluetooth Module - Getting Started Guide
handson28
 
Human Alert Sensor
Object Automation
 
Human Alert Sensor Design
Object Automation
 
Advanced view of atmega microcontroller projects list at mega32 avr
WiseNaeem
 
IRJET- BSIOTR IT SMART LAB using IOT
IRJET Journal
 
NodeMCU || Controlling and observing a robotic car with a smartphone through...
Jiangxi University of Science and Technology (江西理工大学)
 
Lab Handson: Power your Creations with Intel Edison!
Codemotion
 
manual Internet of ThingsArduino_IOTArdu
deepikayadav216323
 
Andrea De Gaetano - An Adventure with ESP8266 firmwares and IOT
Codemotion
 
IRJET- IoT based Smart Helmet for Coal Mining Tracking
IRJET Journal
 
Data Acquisition and Control System for Real Time Applications
ijsrd.com
 
Pradeep_Embedded
pradeep22kumark
 
ESP8266 and IOT
dega1999
 
Advanced View Arduino Projects List - Use Arduino for Projects {4}.pdf
Ismailkhan77481
 
IOT and embaded_Internship final Report-2.pdf
chandanml127
 
Network Design For Alliance Française de Dhaka
MD. Naimur Rahman
 
Tac Presentation October 72014- Raspberry PI
Cliff Samuels Jr.
 
Decibel meter using IoT with notice board
IRJET Journal
 
Ad

Recently uploaded (20)

PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
Thermal runway and thermal stability.pptx
godow93766
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Big Data and Data Science hype .pptx
SUNEEL37
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Presentation 2.pptx AI-powered home security systems Secure-by-design IoT fr...
SoundaryaBC2
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Ad

WiFi mesh network(ESP32 mStar and mesh topology)

  • 1. Department of Electrical Engineering and Information Technology Chair of Measurement and Sensor Technology Project Documentation „Project Lab Embedded Systems “ Member: Lavanya Loganathan (455840) Project: WIFI MESH NETWORK Date: 2017-06-26
  • 2. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 2 of 20 TABLE OF CONTENT 1. Objective…..…………………….………………………………...................3 2. Members Responsibility……………….………………………………….….3 3. Introduction...………………………………………………….......................3 4. Hardware…......…………………………………….……………………...…4 4.1.ESP32 Features…………………………………………………...4 5. Software for Development……………………………………..…………….5 5.1.Arduino Installation…………………………………………...….5 5.2.Installing Python 2.7.x…………………………………………5 5.3.Gitbash…………………………………………………………5 5.4.Preparing the ESP32 board in in Arduino IDE………………………7 5.5.Uploading Codes into ESP-WROOM-32……………………….8 6. MQTT Protocol……………….……………………………………………..9 7. Development Flow Chart…...………………………………………………10 8. Used Keys and Syntaxes……………………………………………………11 9. Implemented Network Topology using cloud service…...…………………13 9.1.Star Topology …………………………………………………13 9.2.Mesh Topology………………………………………………...14 10.Conclusion…………………………………………………………………..15 11.References…………………………………………………………………..15 12.Arduino Software Codes……………………………………………………..16
  • 3. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 3 of 20 Figure1: ESP32 WROOM 1. Objective Create a WiFi Network with ESP-WROOM-32 and Share data with different network Topologies (Mesh and Star) using cloud service via MQTT protocol. 2. Member Responsibilities Lavanya Loganathan Mac address detection, Receive Packets Raziuddin Khazi Mqtt, Star network topology Vivek Anand WiFi scan, Send Packets 3. Introduction The project WiFi mesh network is aimed to build a platform for wireless communication between multiple ESP32 devices. ESP32 is dual core high performance, low cost. Integrated WiFi dual mode Bluetooth microcontroller device. Each Esp32 device can interface with sensors (Like temperature, humidity, pressure etc.) and the sensors data are shared among them via different network topologies (Star, mesh etc.). In this project, devices communicate via a server called MQTT (Message Queue Telemetry Transport) which is a light weight machine-machine protocol built over TCP/IP. The sensor information is shared through a broker via publish and subscribe messaging pattern. Here Broker is mediator which receives message packet from one ESP device(publishing) and send/forward it to the other subscribed devices. The advantage of using MQTT is its lightweight and auto reconnecting feature when disconnected. MQTT is popular in many educational institutions and the Facebook messenger app also uses some features of MQTT. This portable device (wireless communication in such a small size) can be purchased for less than €15. The Open source Arduino software compatibility for ESP32 setup makes it more interesting and attractive. Wifi device at this price is a completely satisfying reward! There are many possibilities when it comes to building projects with ESP-WROOM-02. It can be deployed in Home and Industrial automation, also can be integrated with IoT devices.
  • 4. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 4 of 20 Figure 2: Pin Layout of ESP32 4. Hardware ESP-WROOM-32 ESP32 is a 2.4 GHz dual-core with inbuilt Tensilica LX6 microprocessor with a performance of 600 DMIPS (Dhrystone million instruction per second). In addition; this small device comprises 520 KB of SRAM, 16 MB of flash on board memory. This chip can be operated between -40° C to 125° C temperature with operating voltage around 2.2 to 3.6 V hence makes it more suitable for industrial use. In deep sleep mode, the ESP32 consumes 2.5 µA according to the manufacturer which is quite good for industrial purpose. 4.1 ESP32 Features • 2.2V to 3.6V operating voltage • 32 GPIO pins: o 3x UARTs, including hardware flow control o 3x SPI o 2x I2S o 12x ADC input channels o 2x DAC o 2x I2C o PWM/timer input/output available on every GPIO pin o Supports external SPI flash up to 16 MB o SD-card interface support
  • 5. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 5 of 20 5. Software for Development 5.1 Arduino Installation 5.2 Installing Python 2.7.x 5.2.1 Go to Python website and download the 2.7.x version https://www.python.org/downloads 5.2.2 Open the downloaded file and follow the installation instructions 5.2.3 Select the option “Install for all users” 5.2.4 In Customize Python 2.7.X, enable the last option “Add python.exe to Path” 5.2.5 Complete the further installation 5.3 Gitbash 5.3.1 Download and install Git and Git GUI git-scm.com https://git- scm.com/download/win 5.3.2 Install Git GUI and select the Clone Existing Repository option. Figure 3: Python Installation Figure 4: GUI Clone
  • 6. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 6 of 20 5.3.3 Then, choose the source and destination: Source Location: https://github.com/espressif/arduino-esp32.git Target Directory: Your_Arduino_IDE_Folder_Path/hardware/espressif/esp32 (in my case, it looks like: C:Program Files (x86) Arduino hardware espressifarduino-esp32) 5.3.4 Press the “Clone” button 5.3.5 Open the folder: Your_Arduino_IDE_Folder_Path/hardware/espressif/esp32/tools 5.3.6 Open the “get.exe” file and wait for it to download/prepare the files Figure 5: GUI Source and destination selection Figure 6: get.exe download window
  • 7. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 7 of 20 5.4 Preparing the ESP32 board in Arduino IDE 5.4.1 Adding Libraries to Arduino Download ESP-32 Library: https://github.com/espressif/arduino-esp32 and copy to the following path C:Program FilesArduinohardwareespressif 5.4.2 Libraries are available to use for Arduino and ESP32 separately, but both are not much suitable for ESP32 operation, so download a combined library from GitHub to execute further. Issue: When we used separate libraries, and tried to run some example codes of arduino with ESP32, we found an error of “Wifi mode class not defined”. Reason: The Class Wifi is defined in both libraries (arduino and esp32) and Figure 7: ESP32 Library Download Figure 8: Aurduino- ESP32 Library issue
  • 8. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 8 of 20 while executing default Arduino library was selected not the ESP 32. Solution: Rename Wifi.h to any other name (eg. Wifi_arr.h) and execute again and this time it selects ESP32 WiFi class. 5.4.3 Run any available sample program and analyze 5.5 Uploading Codes into ESP-WROOM-32 To write Arduino programs to the ESP-WROOM, we need an USB serial adapter to connect it to a PC. For the Arduino UNO we’ve been using, a normal USB cable is fine but the ESP-WROOM-02 requires serial conversion to connect to a PC. There are several types of this adapter: 3.3v only, 5v only, and a 3.3v/5v jumper select type. The ESP-WROOM requires 3.3v supply so we need either the 3.3v or the 3.3/5v selection jumper. 5.5.1 Select your board in Tools > Board menu (in my case it’s the ESP32 Dev Module) 5.5.2 Select the COM port 5.5.3 To make your ESP32 go into Downloading/uploading mode: hold the BOOT button and press the EN button to reboot your ESP32 Figure 9: USB Serial Communicator Figure 9: COM port selection
  • 9. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 9 of 20 Publish (Topic, Data) Publish (Topic, Data) Subscribe (Topic, Data) 5.5.4 Press the Upload button in the Arduino IDE and wait a few seconds while the code compiles and uploads to your board. 5.5.5 If everything goes right this what you should see: 5.5.6 Restart your ESP32 to run the newly uploaded code 6. MQTT protocol MQTT stands for Message Queue Telemetry Transfer protocol which is developed by IBM. It’s a light weight message publish/subscribe protocol that is built on top of TCP/IP which send/receive data over a broker. The MQTT client library for arduino can be added from the GIT hub, after installation it can be seen in the example libraries. Figure 10: ESP WROOM 32 Figure 12: MQTT Protocol Figure 11: Uploading Codes to ESP32 Publisher SubscriberBroker
  • 10. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 10 of 20 No Yes Yes No No Yes ReceiveSend No Yes 7. Development Chart publish „Topic“ Send Send Decode Packet with MAC Address and data Send Display data information nd Print connected network SSID Form Packet with MAC Address and sensor data Client Connected MQTT ? Publish to “topic” Client Connected MQTT ? Detect and Display MAC Start Connect to local Wifi network (ssid & password) Subscribe to „Topic“ Receive Define MQTT and Wifi Client Wifi & MQTT Client Serial print „connecting..“ SSID Client Connected to Server ? Wifi.status () = Connected ? Client connect to server "iot.eclipse.org"
  • 11. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 11 of 20 8. Used Keys and Syntaxes 8.1 Client: ESP32 modules are used as a MQTT client, it can be configured as a publishing or subscribing node or both to a broker/network. However, in real time, MQTT client can be any microcontroller with TCP/IP protocol to a fully-fledged server that has a MQTT library running. Arduino syntax: MQTTClient <space> <client name>; Example: MQTTClient client; This command defines the ‘client’ as a MQTTClient name which communicates with MQTT server. 8.2 Broker A MQTT protocols, which handle publish and subscribe commands of clients. A broker is primarily responsible for client authentications, authorizations and integration to the backend systems also receiving the entire message and filtering them accordingly to the clients. • ESP32 microcontroller acts as a client and iot.eclipse.org as a broker. The MQTT connection is between ESP32 microcontroller and eclipse broker. Multiple ESP32 modules are subscribed and publish to broker. • Always the connection is initiated by the client ESP32 by sending “CONNECT” message and upon receiving the “CONNACK” back from the eclipse the connection gets established. Once the connection establishes it cannot be disconnected unless the client disconnects itself. • After establishing the WiFi network, begin the WiFi client connection with MQTT broker using the arduno command. Arduino syntax : <client name> .begin(“MQTT broke ”, WiFiClient name); Example : client. begin("iot.eclipse.org", net); Figure 13: MQTT Protocol
  • 12. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 12 of 20 This will begin communicating once the WiFi is established. After connecting WiFi client to MQTT broker, thereafter it checks wifi status. If status is connected then proceed, otherwise reconnect the WiFi network and also reconnect WiFiClient to the MQTT broker. Arduino syntax: <client name> .connect(Client ID, username, password); Example : client. Connect(“arduino_tx”, "try", "try"); [Note: Here username and password are optional.] • Username and password (optional): This is an optional parameter but it is recommended to use them to authenticate and authorize the client. 8.3 Client ID An Identifier for each MQTT client, connecting to MQTT broker. It is unique per broker. 8.4 Clean Sessions(optional) It is the optional part, setting the clean session to true (1) means that the broker will not store any information of the client, and setting it to false (0) will store all the missed messages of the client. 8.5 TOPICS A topic is a UTF-8 string which is used by broker to filter the message for each connected client. A topic can have one or more levels which define the depth of the communication. Example: Sensor/Temp_node1/Temp_node2 Here Temp_node2 is second layer that can be accessed by first layerTemp_node1 only.A ‘+’ operator also called as wildcard is used to create a single layer whereas ‘#’ is used to create multilayered topics. 8.6 PUBLISH Publish is a keyword using which an ESP32 can send its message to the broker in string format. Arduino syntax- Publish (Topic name, Payload) Example: Publish (Temprature_sensor, 100); 8.7 SUBSCRIBE An ESP32 can subscribe to a single layer to multiple layered topics such that any changes/ updated information can be received to the subscribed client.
  • 13. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 13 of 20 Publish Publish PublishPublish Subscribe Arduino syntax: Subscribe(Topic_name); Example: Subscribe(Temprature_sensor); 8.8 Message Received The message Received will be in string format hence ESP32 decodes the string packet and take appropriate actions. Arduino syntax: messageReceived(String <Topic name>, String <payload>, char *<size>, unsigned int <length>) Example: void messageReceived(String Temprature_sensor, String payload, char * bytes, unsigned int length) • String Topic compares the topic name with the subscribed topic, if topic matches then it accepts the payload otherwise not. • String payload contains the string data received over the MQTT broker which can be extracted later. • Char *bytes contains the data received in bytes. • Length contains the length of the string. 9. Implemented Network Topology 9.1 STAR Topology In star topology, multiple ESP slave devices publish to the broker (iot.eclipse.org) using “/esp_star” ID and one master ESP hub is subscribed to the same broker by “/esp_star” ID. The ESP hub is the central node and all other ESP slave nodes are connected to the central hub node. . Figure 14: WiFi Star Connection of ESP32 Modules via MQTT
  • 14. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 14 of 20 Note: Here all the nodes Publish & Subscribe both Whenever sensor packet is published by the slave ESP to the broker, the subscribed ESP hub receives the message. Features of Star Topology • Every node publishes withthe same client ID but at different time. • Hub is subscribed to the same Client ID and receives message at different time. Advantages of Star Topology • Adding slave nodes is easier • Easy to setup and modify • Only that node is affected which has failed, rest of the nodes can work smoothly Disadvantages of Star Topology • Expensive to use • If the hub fails then the whole network is stopped because all the nodes depend on the hub. 9.2 MESH Topology In the mesh topology, every ESP device has a direct point-to-point connection to every other node. Because all connections are direct, the network can handle very high-volume traffic. It is also robust because if one connection fails, the others remain intact. Security is also high since data travels along a dedicated connection Figure 15: WiFi Mesh Connection of ESP32 Modules via MQTT
  • 15. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 15 of 20 In Mesh topology, each node publishes and subscribe to “/esp_mesh” ID, when a device sends the sensor packet it is received by all other nodes. In other words, every node acts as a star node. All nodes subscribe and publish to the same client ID. Features of Mesh Topology • Fully connected. • Data routing is possible. Advantages of Mesh Topology • Each connection can carry its own data load. • Provides security and privacy. • Data routing can extend to multiple nodes. Disadvantages of Mesh Topology • Installation and configuration is difficult. • Complex design 10. Conclusion Implementation of Star and Mesh network topologies using ESP32 via MQTT communication protocol is successful and data packets are shared among the devices. 11. References • Kolban-ESP32, Neilkoblan book on Esp-32, May 2017 • esp32_datasheet (www.esp32.net) • http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide- windows-instructions/ • https://espressif.com/en/esp-wroom-32 • http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection- establishment • http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices • http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide- windows-instructions • https://github.com • https://espressif.com • https://www.arduino.cc • https://www.python.org • https://iot.eclipse.org • http://mqtt.org • https://www.sparkfun.com
  • 16. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 16 of 20 12. Arduino Software Codes #include<WiFi.h> #include<MQTTClient.h> const char ssid[] = "TP-LINK_KHAZI"; const char pass[] = "khazi1234"; byte mac[6]; WiFiClient net; MQTTClient client; unsigned long lastMillis = 0; void connect(); void setup() { // select the baudrate and begin the wifi communication Serial.begin(115200); WiFi.begin(ssid,pass); delay(100); // Connect WiFi client to the MQTT broker client.begin("iot.eclipse.org",net); connect(); } void connect(){ // Check WiFi status,if not connected the try reconnecting Serial.print("Connecting.. "); while(WiFi.status()!=WL_CONNECTED){ Serial.print("."); delay(1000);
  • 17. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 17 of 20 } // Displays connected access point name(SSID name) Serial.println(""); Serial.print("Connected to "); Serial.println(WiFi.SSID()); // Connecing from local server to the IoT.eclipse.org // If not connected to the MQTT server then wait till reconnects Serial.print("nConnecting...."); while(!client.connect("arduino_rx","try","try")){ Serial.print("."); } // Displays the MAC address of the device WiFi.macAddress(mac); Serial.println(""); Serial.print(mac[5],HEX); Serial.print(":"); Serial.print(mac[5],HEX); Serial.print(":"); Serial.print(mac[4],HEX); Serial.print(":"); Serial.print(mac[3],HEX); Serial.print(":"); Serial.print(mac[2],HEX); Serial.print(":"); Serial.print(mac[1],HEX); Serial.print(":");
  • 18. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 18 of 20 Serial.print(mac[0],HEX); //client subscribes to the topic name "esp_star" client.subscribe("/esp_star"); } void loop() { // this should always be in loop, to keep MQTT active/alive client.loop(); delay(10); if(!client.connected()) { connect(); } } void messageReceived(String topic, String payload , char *bytes, unsigned int length) { // Predefined MAC address of the devices for decoding the incomming messages String sub_temp,sub_temp1; String esp_r1 = "64"; String esp_r2 = "72"; String esp_r3 = "244"; String esp_r4 = "252"; String esp_green = "156"; // Extraction of 2 digit or 3 digit MAC address into temporary variables sub_temp = payload.substring(0,2); sub_temp1 = payload.substring(0,3);
  • 19. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 19 of 20 // Decoding the Message and segregating based on the MAC ID of the device // If MAC ID match the predefined MAC ID then displays the information on the screen // Its prior known tha, // Temperature sensor is connected to esp_r1, // Pressure sensor is connected esp_r2 // Humidity sensor is connected to esp_r3 // Hall effect sensor connected to esp_green if(sub_temp == esp_r1){ Serial.print("Temp : "); Serial.println(payload.substring(2)); } else if(sub_temp == esp_r2){ Serial.print("Pressure : "); Serial.println(payload.substring(2)); } else if((sub_temp == esp_r3)||(sub_temp1 == esp_r3)){ Serial.print("Humidity : "); Serial.println(payload.substring(3)); } else if((sub_temp == esp_r4)||(sub_temp1 == esp_r4)){ Serial.print("Accelerometer : "); Serial.println(payload.substring(3)); } else if((sub_temp == esp_green)||(sub_temp1 == esp_green)){ Serial.print("Halleffect sensor : "); Serial.println(payload.substring(3));
  • 20. Technische Universität Chemnitz Chair of Measurement and Sensor Technology Prof. Dr.-Ing. Olfa Kanoun Group 18: Wi-Fi Mesh Network Page 20 of 20 } //If any MAC ID did not match then display "some problem" else{ Serial.println("Some problem.."); } } To Send data from nodes to hub in star topology: void loop() { client.loop(); delay(10);// <- fixes some issues with WiFi stability String pld = ""; pld += mac[5]; if (!client.connected()) { connect(); } // publish a message roughly every second. if (millis() - lastMillis > 2000) { lastMillis = millis(); //float sen_val = analogRead(5); float x = 19.45; pld += x; //publish sensor packet(pld)to the mqtt broker client.publish("/esp_star",pld); } } Note: Rest of the code remain same as previous code, only change in void loop() function.