Здравствуйте! Подскажите как исправить ошибку при опросе контроллера.
Поиск подсказывает что ошибка в аргументах, но что нужно сделать.
Программа набрана в блочной среде программирована, скомпилирована в IDE.
В схеме DHT11, Wemos D1 R2 mini, LCD1602
Спасибо всем!
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
int Hum = 0;
float Temp = 0;
float Press = 26;
String openWeatherMapApiKey = "f6b223ab7e2526445b0651781eec28d9";
String city;
String country_code;
String location;
String country;
String icono;
String weather;
String description;
float temperature;
float humidity;
float pressure;
int sunrise;
int sunset;
float temp_min;
float temp_max;
float feels_like;
float Cloud;
float visibility;
float wind_speed;
float wind_angle;
int id;
String jsonBuffer;
#include "DHT.h"
DHT dht_0(0,DHT11);
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#define WIFI_SSID "XiaoBC53"
#define WIFI_PASSWORD "uthfcbvj"
#define BOT_TOKEN "6283503717:AAFMr59mwcbAafQzT6nbFPnBBEtpqugDdFI"
const unsigned long BOT_MTBS = 100;
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
unsigned long bot_lasttime;
int ledStatus = 0;
void handleNewMessages(int numNewMessages)
{
for (int i = 0; i < numNewMessages; i++)
{
String chat_id = bot.messages[i].chat_id;
String text = bot.messages[i].text;
String from_name = bot.messages[i].from_name;
if (from_name == "")
from_name = "Guest";
if(text == "Hello"){
bot.sendMessage(chat_id, "Hi!", "");
}
if(text == "Humidity"){
bot.sendMessage(chat_id, (String("Humidity is ") + String(String(Hum)) + String("%")), "");
}
if(text == "Temperature"){
bot.sendMessage(chat_id, (String("Temperature is ") + String(String(Temp)) + String("°C")), "");
}
if(text == "Pressure"){
bot.sendMessage(chat_id, (String("Pressure is ") + String(String(Press)) + String("hpa")), "");
}
if(text == "Weather"){
bot.sendMessage(chat_id, (String("Weather") + String(weather)), "");
}
if(text == "Goodbye"){
bot.sendMessage(chat_id, "Bye!", "");
}
}
}
String httpGETRequest(const char* serverName) {
HTTPClient http;
http.begin(serverName);
int httpResponseCode = http.GET();
String payload = "{}";
if (httpResponseCode>0) {
payload = http.getString();
}
http.end();
return payload;
}
void GetValuesWeather (String jsonBuffer)
{
jsonBuffer.replace('[', ' ');
jsonBuffer.replace(']', ' ');
char jsonArray [jsonBuffer.length()+1];
jsonBuffer.toCharArray(jsonArray,sizeof(jsonArray));
jsonArray[jsonBuffer.length() + 1] = '\0';
DynamicJsonDocument root(1024);
DeserializationError error = deserializeJson(root, jsonArray);
if (error)
return;
location = (const char *)root["name"];
country = (const char *)root["sys"]["country"];
temperature = root["main"]["temp"];
humidity = root["main"]["humidity"];
weather = (const char *)root["weather"]["main"];
description = (const char *)root["weather"]["description"];
pressure = root["main"]["pressure"];
sunrise = root["sys"]["sunrise"];
sunset = root["sys"]["sunset"];
feels_like = root["main"]["feels_like"];
temp_min = root["main"]["temp_min"];
temp_max = root["main"]["temp_max"];
Cloud = root["clouds"]["all"];
visibility = root["visibility"];
wind_angle = root["wind"]["deg"];
wind_speed = root["wind"]["speed"];
icono = (const char *)root["weather"]["icon"];
id= root["weather"]["id"];
}
void setup() {
dht_0.begin();
Serial.begin(9600);
Serial.println();
configTime(0, 0, "pool.ntp.org");
secured_client.setTrustAnchors(&cert);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
Serial.print("WiFi connected. IP address: ");
Serial.println(WiFi.localIP());
Serial.print("Retrieving time: ");
time_t now = time(nullptr);
while (now < 24 * 3600)
{
delay(100);
now = time(nullptr);
}
}
void loop() {
if(WiFi.status()== WL_CONNECTED){
city="Miass";
country_code="RU";
String serverPath = "http://api.openweathermap.org/data/2.5/weather?q="+city+","+country_code+"&lang=ru&APPID="+openWeatherMapApiKey;
jsonBuffer = httpGETRequest(serverPath.c_str());
GetValuesWeather (jsonBuffer);
}
Hum = dht_0.readHumidity();
Temp = dht_0.readTemperature();
if (millis() - bot_lasttime > BOT_MTBS)
{
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages)
{
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
bot_lasttime = millis();
}
}