Nb-iot Sim7000e With Mqtt Communication
About the project
NB-IoT sensors using MQTT protocol Connected to Cloud
Project info
Difficulty: Moderate
Platforms: Arduino, PlatformIO
Estimated time: 2 weeks
License: Apache License 2.0 (Apache-2.0)
Items used in this project
Hardware components
Story
This project is to aim at how to use NB-IoT SIM7000E with IoT MQTT protocol standard. I wrote code in Arduino IDE and use Pubsubclient and Tinygsmclient to send the data to the cloud. It has been successfully sent to AWS and Thingsboard cloud.
#define TINY_GSM_MODEM_SIM7000#include <TinyGsmClient.h>#include <PubSubClient.h>TinyGsm modem(SerialAT);TinyGsmClient client(modem);PubSubClient mqtt(client);
All data could be visualized at the dashboard or mobile apps to monitor the real-time condition of the environment. Arduino Mega and SIM7000E communicate in Serial (Rx, Tx) interface, and using JSON packet data by MQTT pubsubclient library to publish the data to the cloud every minute.
const size_t capacity = JSON_OBJECT_SIZE(2);DynamicJsonDocument doc(capacity);float ph = random(100, 700)/100.0;float turbidity = random(100, 300000)/100.0;doc["ph"] = ph;doc["turbidity"] = turbidity;char payload[256];serializeJson(doc, payload);long now = millis();if(now - lastData > 60000){lastData = now;mqtt.publish(publishTopic, payload);Serial.println(payload);}
I used Telkomsel IoT which is a provider of NB-IoT Simcard that I set up APN for the connectivity of NB. NB-IoT is a low power device.
Leave your feedback...