NodeMCU + I2C LCD1602 Погодная станция
- Войдите на сайт для отправки комментариев
Чт, 18/04/2019 - 11:49
Всем привет. Сделал погодную станцию, самую простейшую (парсер json с выводом на экран).
Суть проблемы.
При обновлении данных спустя некоторое время на экран выводятся старые значения температуры и влажности хотя в мониторе порта видно что приходят новые с другими значениями. + спустя 8 циклов обновления данных модуль уходит в ребут. Как это можно решить?
Скетч:
#include <ESP8266WiFi.h> #include <LiquidCrystal_I2C.h> #include <ArduinoJson.h> #include <Wire.h> const char* ssid = ""; const char* password = ""; String APIKEY = ""; String CityID = ""; //Your City ID WiFiClient client; const char *weatherHost = "api.openweathermap.org"; int counter = 15; String weatherDescription =""; String weatherLocation = ""; String Country; float Temperature; float Humidity; String result; LiquidCrystal_I2C lcd(0x27, 16, 2); // Address of your i2c LCD back pack should be updated. void setup() { Wire.begin(2,0); Serial.begin(115200); int cursorPosition=0; lcd.begin(16, 2); lcd.init(); lcd.backlight(); lcd.print(" Connecting"); Serial.println("Connecting to " + String (ssid)); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); lcd.setCursor(cursorPosition,2); lcd.print("."); cursorPosition++; } lcd.clear(); lcd.print(" Connected!"); Serial.println("Connected to " + String (ssid)); Serial.println(WiFi.localIP()); delay(1000); } void loop() { if(counter == 15) //Get new data every 10 minutes { counter = 0; displayGettingData(); delay(1000); getWeatherData(); }else { counter++; displayWeather(weatherLocation,weatherDescription); delay(5000); displayConditions(Temperature,Humidity); delay(5000); } } void getWeatherData() //client function to send/receive GET request data. { if (client.connect(weatherHost, 80)) { //starts client connection, checks for connection client.println("GET /data/2.5/weather?id="+CityID+"&units=metric&APPID="+APIKEY); client.println("Host: api.openweathermap.org"); client.println("User-Agent: ArduinoWiFi/1.1"); client.println("Connection: close"); client.println(); } else { Serial.println("connection failed"); //error message if no client connect Serial.println(); } while(client.connected() && !client.available()) delay(1); //waits for data while (client.connected() || client.available()) { //connected or data available char c = client.read(); //gets byte from ethernet buffer result = result+c; } client.stop(); //stop client result.replace('[', ' '); result.replace(']', ' '); Serial.println(result); char jsonArray [result.length()+1]; result.toCharArray(jsonArray,sizeof(jsonArray)); jsonArray[result.length() + 1] = '\0'; DynamicJsonBuffer json_buf; JsonObject &root = json_buf.parseObject(jsonArray); if (!root.success()) { Serial.println("parseObject() failed"); } String location = root["name"]; String country = root["sys"]["country"]; float temperature = root["main"]["temp"]; float humidity = root["main"]["humidity"]; String weather = root["weather"]["main"]; String description = root["weather"]["description"]; weatherDescription = description; weatherLocation = location; Country = country; Temperature = temperature; Humidity = humidity; } void displayWeather(String location,String description) { lcd.clear(); lcd.setCursor(0,0); lcd.print(location); lcd.print(", "); lcd.print(Country); lcd.setCursor(0,1); lcd.print(description); } void displayConditions(float Temperature,float Humidity) { lcd.clear(); //Printing Temperature lcd.print("T:"); lcd.print(Temperature,1); lcd.print((char)223); lcd.print("C "); lcd.print(" H:"); //Printing Humidity lcd.print(Humidity,0); lcd.print(" %"); } void displayGettingData() { lcd.clear(); lcd.print("Getting data"); }
Вывод в мониторе порта:
09:43:33.441 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ 09:46:05.622 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 09:48:37.887 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 09:51:10.087 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 09:53:42.416 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 09:56:14.739 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 09:58:47.179 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 10:01:19.570 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 10:03:52.073 -> {"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":9.62,"pressure":1029,"humidity":61,"temp_min":8,"temp_max":10.56},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569110,"sys":{"type":1,"id":8903,"message":0.0047,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0052,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.006,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮{"coord":{"lon":30.52,"lat":50.43},"weather": {"id":800,"main":"Clear","description":"clear sky","icon":"01d"} ,"base":"stations","main":{"temp":10,"pressure":1029,"humidity":61,"temp_min":10,"temp_max":10},"visibility":10000,"wind":{"speed":1},"clouds":{"all":0},"dt":1555569000,"sys":{"type":1,"id":8903,"message":0.0054,"country":"UA","sunrise":1555556329,"sunset":1555606528},"id":703448,"name":"Kiev","cod":200}⸮ 10:03:59.212 -> 10:03:59.212 -> ets Jan 8 2013,rst cause:4, boot mode:(1,6) 10:03:59.212 -> 10:03:59.212 -> wdt reset 10:10:41.988 -> sd
Вы никогда не чистите переменную result. Вы всё накапливаете и накапливаете данные в ней, а выбрасывать их дяд будет.
Вот и выходит, что сначала она у Вас покащывает первые разобранные данные, а потом (по мере того, как переменная result) перестаёт помещаться в память) сдыхает совсем.
Вы никогда не чистите переменную result. Вы всё накапливаете и накапливаете данные в ней, а выбрасывать их дяд будет.
Вот и выходит, что сначала она у Вас покащывает первые разобранные данные, а потом (по мере того, как переменная result) перестаёт помещаться в память) сдыхает совсем.
добавил обнуление строки result = ""; в loop, вроде бы сработало.. или есть правильный способ?
Ну, если работает, то и ладно.
А правильный, ну, как говорил известный сантехник, там систему менять надо.
Ну, для начала, само описание Вашего result можно перенести в loop (чего она делает в глобальном пространстве?). Тогда и обнулять не нужно. В строке 114, как минимум, надо добавить & после слова Sting (после обоих). Ну, и там много чего. Если "по уму", то там надо всё переписывать.
Почитайте мои этюды про работу с памятью. Они в разделе "программирование" в начале "прибиты".
этот писал какой-то индус, я просто немного под себя переделал..
что-то не могу этой строки найти у себя
этот писал какой-то индус
Это заметно.
что-то не могу этой строки найти у себя
Чего???? Откройте код в стартовом посте этого топика. Там слева стоят номера строк. Вы не можете найти строку №114? Ну, если не можете, то, боюсь, "медицина бессильна".
этот писал какой-то индус
Это заметно.
что-то не могу этой строки найти у себя
Чего???? Откройте код в стартовом посте этого топика. Там слева стоят номера строк. Вы не можете найти строку №114? Ну, если не можете, то, боюсь, "медицина бессильна".
я смотрел сначала в IDE, там 114 строка String location = root["name"];, а потом понял что что-то не то. Приношу извинения :)
Добавил ещё чтобы на oled экран выводилось время, но только показания секунд обновляются только через 15 сек.
Подскажите, пожалуйста, где я допустил ошибку
Строки №№ 171, 173 и 175 - как раз задержка на 15 секунд.
в строках 165, 171, 173, 175
Строки №№ 171, 173 и 175 - как раз задержка на 15 секунд.
в строках 165, 171, 173, 175
с погодой как раз таки всё нормально.. проблема с "опозданием" отображения времени на oled экране
Так вот из-за этого и проблема. Вы там сидите 15 секунд в задержке, а потом удивляете, почему 15 секунд в программе ничего не происходит
Так вот из-за этого и проблема. Вы там сидите 15 секунд в задержке, а потом удивляете, почему 15 секунд в программе ничего не происходит
теперь дошло. а как же тогда сделать плавный переход между показаниями погоды спустя пару секунд, но без ущерба для показаний времени?
а как же тогда сделать плавный переход между показаниями погоды спустя пару секунд, но без ущерба для показаний времени?
Дак это программировать нада.
а как же тогда сделать плавный переход между показаниями погоды спустя пару секунд, но без ущерба для показаний времени?
Дак это программировать нада.
можно пример?
можно пример?
От меня - нет, это ж нада трудица, а у мня тут трэш и угар.
Так вот из-за этого и проблема. Вы там сидите 15 секунд в задержке, а потом удивляетесь, почему 15 секунд в программе ничего не происходит
теперь дошло. а как же тогда сделать плавный переход между показаниями погоды спустя пару секунд, но без ущерба для показаний времени?
Научиться делать неблокирущие задержки. Т.е. писать так, чтобы действие задержалось, но программа при этом продолжала исполняться. В частности, экран обновлялся и т.п.
Пример такого программирования подробно разобран, например, вот здесь. Там во время задержки между включением и выключением светодиода программа продолжает исполняться и делать то, что ей нужно.