Telegram Respond on ESP8266

Viewed 13

I'm currently working on IoT Anemometer using Telegram Bot (ESP8266). The only problem I get now is I don't know how to make telegram bot responds based on what my ask. Got a bit confuse on 'If' statement.

void loop()
{
  if((millis() - Start_Read_Timer) >= READ_TIME || millis() > lastTimeBotRan + botRequestDelay)
  {
    cli();

    WindSpeed = WIND_SPEED_20_PULSE_SECOND / ONE_ROTATION_SENSOR * (float) Rotations;
    float SpeedMPH = ((WindSpeed * 3600) / CONVERTMPH_FORMULA);

    int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    while(numNewMessages) 
    {
        Serial.println("got response");
        handleNewMessages(numNewMessages);
        numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    }

    Serial.print("Rotations: ");
    Serial.print(Rotations); 

    Serial.print("   |   "); 

    Serial.print("Wind Speed: ");
    Serial.print(WindSpeed); 
    Serial.print(" m/s");

    Serial.print("   |   ");

    Serial.print("Speed in MPH: ");
    Serial.print(SpeedMPH); 
    Serial.print(" mph");

    Serial.print("\n"); 
    
    sei();

    Rotations = 0;
    Start_Read_Timer = millis();
    lastTimeBotRan = millis();
  }
}

If I create another 'If' for "millis() > lastTimeBotRan + botRequestDelay", I get the telegram respond but the serial monitor will stop measuring wind speed. So I put '||' instead, but now telegram bot won't work.

Thanks.

0 Answers
Related