Nb-iot Sim7000e With Mqtt Communication

About the project

NB-IoT sensors using MQTT protocol Connected to Cloud

Project info

Difficulty: Moderate

Platforms: ArduinoPlatformIO

Estimated time: 2 weeks

License: Apache License 2.0 (Apache-2.0)

Items used in this project

Hardware components

Dht22 Temp/humidity Sensor Dht22 Temp/humidity Sensor x 1
Arduino Mega 2560 R3 Arduino Mega 2560 R3 x 1
Sim7000e Arduino Nb-iot/lte/gprs/gps Expansion Shield Sim7000e Arduino Nb-iot/lte/gprs/gps Expansion Shield x 1

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.

Code

NB-IoT SIM7000E with MQTT Communication

Credits

Photo of radhyahmad

radhyahmad

IoT Engineer and Master Student in ITB Indonesia

   

Leave your feedback...