Hi my idea is show in the dashboard temperature outside (open weather) and inside from sensor, i do not found how to send the temperature
What is working ? i can see the weather data in serial monitor, and I´ve mills() send from ESP to the dashboard.
But i try several ways to send the openweather data to dasboard and always get an error.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Arduino_JSON.h>
#include <ThingerESP8266.h> // Thinger
#include <NTPClient.h> // Thinger
#include <WiFiUdp.h> // Thinger
#define USERNAME “and***” // Thinger
#define DEVICE_ID “node***” // Thinger
#define DEVICE_CREDENTIAL “Nxb$dw*******” // Thinger
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
const char* ssid = “TP-";
const char password = "no***”;
String my_Api_Key = “e1e11b7969e4ea11abad3e947ba****”;
String my_city = “Buenos Aires”; //specify your city
String my_country_code = “AR”; //specify your country code
unsigned long last_time = 0;
unsigned long timer_delay = 30000;
String json_array;
WiFiClient wifiClient;
unsigned long timert = 0;
void setup() {
// digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) // thinger.io
thing[“led”] << digitalPin(LED_BUILTIN);
// resource output example (i.e. reading a sensor value) // thinger.io
thing[“millis”] >> outputValue(millis());
thing[“timert”] >> outputValue(timert);
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println(“Connecting to WIFI…”);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
Serial.println(“First set of readings will appear after 10 seconds”);
}
void loop() {
timert = (millis() - last_time);
if ( timert > timer_delay) {
if(WiFi.status()== WL_CONNECTED){
String server = "http://api.openweathermap.org/data/2.5/weather?q=" + my_city + "," + my_country_code + "&APPID=" + my_Api_Key + "&units=metric";
json_array = GET_Request(server.c_str());
Serial.println(json_array);
JSONVar my_obj = JSON.parse(json_array);
if (JSON.typeof(my_obj) == "undefined") {
Serial.println("Parsing input failed!");
return;
}
// Serial.print("JSON object = ");
// Serial.println(my_obj);
Serial.print("Temp: ");
Serial.println(my_obj["main"]["temp"]);
Serial.print("Pres: ");
Serial.println(my_obj["main"]["pressure"]);
Serial.print("Hum: ");
Serial.println(my_obj["main"]["humidity"]);
Serial.print("S.ter: ");
Serial.println(my_obj["main"]["feels_like"]);
Serial.print("T.min: ");
Serial.println(my_obj["main"]["temp_min"]);
Serial.print("T.max: ");
Serial.println(my_obj["main"]["temp_max"]);
Serial.print("Press: ");
Serial.println(my_obj["main"]["pressure"]);
}
else {
Serial.println("WiFi Disconnected");
}
last_time = millis();
}
}
String GET_Request(const char* server) {
HTTPClient http;
http.begin(wifiClient,server);
int httpResponseCode = http.GET();
String payload = “{}”;
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
payload = http.getString();
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
http.end();
return payload;
thing.handle(); // thinger.io
}