Помогите (возможно за деньги), с установкой значения срабатывания сервомотора через телеграм бот, esp8266. Не могу разобраться как присвоить значение переменной “ust” отправленному с телеграмм чата числу. Я хотел бы задавать значения срабатывания сервомотора через телеграмм чат.
int ust = 0;
int sost = 0;
#include "DHT.h"
DHT dht_5(5,DHT11);
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#define WIFI_SSID "Red7"
#define WIFI_PASSWORD "5555577777"
#define BOT_TOKEN "5887712112:AAEh4qBsVMpI5XFnXqdhJWgORRWjg3D4lBo"
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 == "start"){
bot.sendMessage(chat_id, "/temp", "");
bot.sendMessage(chat_id, "/zadat", "");
}
if(text == "/temp"){
bot.sendMessage(chat_id, (String("текущая температура ") + String("д.1 ") + String(String(temp)) + String(" C* ")), "");
}
if(text == "/zadat"){
bot.sendMessage(chat_id, (String("введи температуру")), "");
delay(5000);
ust = text;
bot.sendMessage(chat_id, (String("установлено значение ") + String(String(ust))), "");
}
}
}
void setup() {
dht_5.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() {
temp = dht_5.readTemperature();
if (temp >= ust & sost == 0) {
for (int count = 0; count < 15; count++) { pinMode(4, OUTPUT);
digitalWrite(4, 1);
delayMicroseconds((7 * 150 + 500));
pinMode(4, OUTPUT);
digitalWrite(4, 0);
delay(20);
}
sost = 1;
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();
}
bot.sendMessage("1997349678", "открыто", "");
}
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();
}
} ```