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

Dht22 Temp/humidity Sensor Dht22 Temp/humidity Sensor x 1
Arduino Is An Open-source Physical Computing Platform Based On A Simple I/o Board And A Development Environment That Implements The Processing/wiring Language. Arduino Can Be Used To Develop Stand-alone Interactive Objects Or Can Be Connected To Soft Arduino Is An Open-source Physical Computing Platform Based On A Simple I/o Board And A Development Environment That Implements The Processing/wiring Language. Arduino Can Be Used To Develop Stand-alone Interactive Objects Or Can Be Connected To Soft x 1
Sim7070g Arduino Nb-iot / Lte / Gnss / Gprs / Gps Expansion Shield (global) Sim7070g Arduino Nb-iot / Lte / Gnss / Gprs / Gps Expansion Shield (global) 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...