User Tools

Site Tools


c4ta:iot-workshop:mqtt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
c4ta:iot-workshop:mqtt [2024/09/11 20:02] harley.larac4ta:iot-workshop:mqtt [2024/09/13 18:10] (current) – [3. Our first MQTT Publish] harley.lara
Line 89: Line 89:
 <file c++ mqtt-publish.ino> <file c++ mqtt-publish.ino>
 #include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
-#include <WiFiClientSecure.h>+//#include <WiFiClientSecure.h> 
 +#include <WiFiClient.h>
 #include <PubSubClient.h> #include <PubSubClient.h>
 #include <ArduinoJson.h> #include <ArduinoJson.h>
  
-const uint16_t HTTP_PORT = 443; // Use 443 for HTTPS and 80 for HTTP+const uint16_t HTTP_PORT = 80; // Use 443 for HTTPS and 80 for HTTP
  
 // Replace with your WiFi credentials // Replace with your WiFi credentials
-const char* SSID = "Eutopiq"; // [USER INPUT] +const char* SSID = "iotlab-mobile"; // [USER INPUT] 
-const char* PASSWORD = "Eutopiq321"; // [USER INPUT]+const char* PASSWORD = "iotlab18"; // [USER INPUT]
  
 // Create an instance of WiFiClientSecure // Create an instance of WiFiClientSecure
-WiFiClientSecure wifi_client;+WiFiClient wifi_client;
  
 // =================== // ===================
Line 111: Line 112:
 const uint8_t PERIOD_MINUTES = 1; const uint8_t PERIOD_MINUTES = 1;
  
-const char* MQTT_SERVER = "broker.hivemq.com"; // [USER INPUT] +const char* MQTT_SERVER = "192.168.1.1"; // [USER INPUT] 
-const uint16_t MQTT_PORT = 8883; // TLS TCP PORT for HTTPS connections, otherwise use 1883 +const uint16_t MQTT_PORT = 1883; // TLS TCP PORT for HTTPS connections, otherwise use 1883 
-const char* MQTT_OUTPUT_TOPIC = "colmayor/workshop/2024/user1"; // [USER INPUT] +const char* MQTT_OUTPUT_TOPIC = "colmayor/workshop/2024/harley"; // [USER INPUT] 
-const char* MQTT_INPUT_TOPIC = "colmayor/workshop/2024/to-user1"; // [USER INPUT]+const char* MQTT_INPUT_TOPIC = "colmayor/workshop/2024/to-harley"; // [USER INPUT]
  
 PubSubClient mqtt_client(wifi_client); PubSubClient mqtt_client(wifi_client);
Line 140: Line 141:
  
   // Set the client to verify the server's certificate   // Set the client to verify the server's certificate
-  wifi_client.setInsecure();+  //wifi_client.setInsecure();
  
   // Give the client a chance to perform the handshake   // Give the client a chance to perform the handshake
c4ta/iot-workshop/mqtt.txt · Last modified: 2024/09/13 18:10 by harley.lara