Skip to content

Commit

Permalink
included wifi example for ESP 8266
Browse files Browse the repository at this point in the history
  • Loading branch information
elpinjo committed Oct 9, 2020
1 parent dda0f62 commit aaa67a8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions examples/SendMeasurement/SendMeasurement.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <CumulocityClient.h>
#include <WiFi.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else //ESP32
#include <WiFi.h>
#endif

const char* ssid = "........";
const char* wifiPassword = "........";
Expand All @@ -17,7 +21,7 @@ CumulocityClient c8yClient(pubSubClient, tenant, username, c8yPassword, clientId
void setup() {

Serial.begin(115200);

WiFi.begin(ssid, wifiPassword);

Serial.print("Connecting to WiFi");
Expand All @@ -26,27 +30,27 @@ void setup() {
Serial.print(".");
}
Serial.println("connected to wifi");

c8yClient.connect();

Serial.println("Retrieving device credentials");

c8yClient.retrieveDeviceCredentials();
while (!c8yClient.checkCredentialsReceived()) {
Serial.print("#");
delay(1000);
}

c8yClient.disconnect();
c8yClient.connect();

c8yClient.registerDevice("ESP32 - Misja", "c8y_esp32");

}

void loop() {

delay(1000);
c8yClient.loop();
}

}

0 comments on commit aaa67a8

Please sign in to comment.