IoT Tutorial #23 [ NodeMCU Tutorials #8 ]
We have already seen how to flash Lua firmware on NodeMCU and Rum first Lua program for blinking LED on NodeMCU ESP8266.
Recommended Internet of Things (IOT) Courses:
- Udemy: Complete Guide to Build IOT Things from Scratch to Market
- LinkedIn: IoT Foundations: Fundamentals
- edX: Introduction to the Internet of Things (IoT)
- edureka: IoT Certification Training on Azure
- Coursera: An Introduction to Programming the Internet of Things (IOT) Specialization
- Eduonix: Internet Of Things (IOT) Bundle
In this post, we will write a Lua program for MQTT Publish-Subscribe communication over the internet.
Description:
MQTT Publish-Subscribe using LUA Program:
Board: NodeMCU (ESP8266)
MQTT Publish-Subscribe:
Steps:
- Flash Fresh Lua firmware using NodeMCU Flasher (Click here to Check how) > Close Flasher
- Open Chrome and Install and Launch "MQTT Box" (Chrome App)
Click on > "Create MQTT Client" > and Set Following things:
Click on Save
Click on Subscribe
then Type whatever msg you want to send/publish, write it in the "Payload" textbox and hit "Publish" to send.
- Keep NodeMCU connected > Open ESPlorer > A new ESPlorer window will open.
"Port" must be automatically detected there. Set Baud_rate = 9600
If PORT is not getitng detected then you need to install drivers:
https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
Click on "Open" to Check the firmware version of nodemcu.
then click "RST" button on NodeMCU.
It will show the Firmware version...
Eg.
NOTE:
If some program is already uploaded on the nodeMCU then It won't detect the firmware version.
In that case,
Flash default (Lua) firware (shown in step 3) of previous post and then try to detect it using above steps. - Copy following code and Place it in the left black window of ESPlorer and
Change wifi_name and wifi_password in the below code.
save it with .lua extention: - Then Click on "Send to ESP"
- Above Program will Subscribe to topic "mytopic/iot" and Publish following msg to the same topic
You can observe the same msg received by MQTT Box Subscriber (From step 2)
Similarlly, you can publish some messages from MQTT Box Publisher (From step 2) and
Observe those messages received by NodeMCU (In the right Black window of the ESPlorer)
NOTE:
Using this You can send messages from any place to another place.
I mean, It is NOT necessary to keep NodeMCU, MQTT Box in the same network.
For Better understanding you can watch the demonstration video given below:
For Better understanding you can watch the demonstration video given below:
Downloads:
Download link is given in the Description of the YouTube video shown below.
Download link is given in the Description of the YouTube video shown below.
Demonstration:
--------------------------------------------------------------------------------
Click here to see more codes for Raspberry Pi 3 and similar Family.
Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.
Feel free to ask doubts in the comment section. I will try my best to solve it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.
Thanks and Regards,
-Akshay P. Daga
which android apk used
ردحذف