Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include <ESP8266HTTPClient.h>
- #include <WiFiClient.h>
- const char* ssid = "converge-2.4g";
- const char* password = "Sierra911";
- //Your Domain name with URL path or IP address with path
- const char* serverName = "https://us-central1-floodmonitor-474e0.cloudfunctions.net/devices";
- void setup() {
- Serial.begin(115200);
- WiFi.begin(ssid, password);
- Serial.println("Connecting");
- while(WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.print("Connected to WiFi network with IP Address: ");
- Serial.println(WiFi.localIP());
- }
- void loop() {
- WiFiClient client;
- HTTPClient http;
- // Your Domain name with URL path or IP address with path
- http.begin(client,servername);
- // If you need an HTTP request with a content type: application/json, use the following:
- http.addHeader("Content-Type", "application/json");
- int httpResponseCode = http.POST("{\"deviceId\":\"3\",\"lat\":\"14.627656\",\"long\":\"121.070773\",\"waterLevel\":\"16\",\"flooded\":\"true\"}");
- Serial.print("HTTP Response code: ");
- Serial.println(httpResponseCode);
- // Free resources
- http.end();
- delay(5000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement