MQTT on LinkIt ONE using GPRS/GSM
|In this blog we will see how to use MQTT on Linkit ONE using GPRS, i.e the internet connectivity will be provided by GPRS instead of WiFi. This will be help full where you don’t have access to WiFi Access point.
The MQTT code is very similar to that of WiFi , one few lines of code will change.
Linkit ONE Setup:
The First thing you need do before starting any GPRS based project is attaching antenna and inserting SIM card.
We will be publishing and analog data of few analog ports to the specified channel, and we be listing for messages on one channel, if any messages is published on the channel, we will simply display that in serial monitor, ideally you would want to process this message and take some decision based on this message.
I will be using cloudmqtt broker, you can see this for more details on setup. You can see arduino sending and receiving messages from MQTT broker below.
You need a MQTT client application to send messages to nodeMCU form your laptop, I am using mqtt-spy.
The code is very simple, the basic steps are
- Initialize GPRS
- Connect to MQTT Broker
- Subscribe to the channels you are interested (I will be using ‘/nodemcu/linkit50/v01/tod’)
- Send messages to the channels as required (I will be sending analog data to ‘/nodemcu/linkit50/v01/fromd/analog’)
Code is available here, please note that you need to install ArduinoJson library before compiling the code in Arduino.If you haven’t prepared development environment for LinkitOne follow this guide.
Thanks, it helped me