Boss lady
DIIDevHeads IoT Integration Server
•Created by iamnarendrans on 6/14/2024 in #edge-networking
Does anybody worked on Quectel EC200 series SIM module for establishing an MQTT connection to cloud
#include <PubSubClient.h>
#include <QuectelMQTT.h>
const char* mqtt_server = "your_mqtt_server";
const int mqtt_port = 1883;
const char* mqtt_username = "your_username";
const char* mqtt_password = "your_password";
const char* mqtt_topic = "your_topic";
QuectelMQTT quectel_mqtt("your_apn", "your_username", "your_password", "your_simcard_pin");
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
quectel_mqtt.PowerOn(); // Power on the Quectel module
quectel_mqtt.InitializeGPRS(); // Initialize GPRS connection
Serial.begin(115200);
delay(100);
WiFi.begin("your_ssid", "your_password"); // Connect to WiFi network
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
quectel_mqtt.InitializeMQTT(client, mqtt_server, mqtt_port, mqtt_username, mqtt_password); // Initialize MQTT connection
quectel_mqtt.ConnectMQTT(client);
}
client.loop();
// Publish a message to the MQTT broker
char message[50];
snprintf(message, 50, "Hello from Quectel SIM module!");
client.publish(mqtt_topic, message);
delay(5000); // Publish message every 5 seconds
}
#include <PubSubClient.h>
#include <QuectelMQTT.h>
const char* mqtt_server = "your_mqtt_server";
const int mqtt_port = 1883;
const char* mqtt_username = "your_username";
const char* mqtt_password = "your_password";
const char* mqtt_topic = "your_topic";
QuectelMQTT quectel_mqtt("your_apn", "your_username", "your_password", "your_simcard_pin");
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
quectel_mqtt.PowerOn(); // Power on the Quectel module
quectel_mqtt.InitializeGPRS(); // Initialize GPRS connection
Serial.begin(115200);
delay(100);
WiFi.begin("your_ssid", "your_password"); // Connect to WiFi network
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
quectel_mqtt.InitializeMQTT(client, mqtt_server, mqtt_port, mqtt_username, mqtt_password); // Initialize MQTT connection
quectel_mqtt.ConnectMQTT(client);
}
client.loop();
// Publish a message to the MQTT broker
char message[50];
snprintf(message, 50, "Hello from Quectel SIM module!");
client.publish(mqtt_topic, message);
delay(5000); // Publish message every 5 seconds
}
5 replies