Is it possible to auto update the Thingspeak Channel data at certain time?

lou yu on 16 Jun 2021
Latest activity Edit by Christopher Stapels on 16 Jun 2021

I want to use a microcontroller and esp8266 to control the relay and home appliance. For example, my water pump needs to be "ON" from 6 am to 10 pm and "OFF" from 10 pm to the next day at 6 am. In this case, I want the thingspeak channel's field to auto-update "1" at 6 am and auto-update "0" at 10 pm. I wonder if there a possibility. If it can be achieved, my esp can receive the latest data to control the relay and appliance.

Christopher Stapels
Christopher Stapels on 16 Jun 2021 (Edited on 16 Jun 2021)

I recommend using the TimeControl app linked to a MATLAB analysis that uses thingSpeakWrite() to update the channel value. The getting started tutorial shows you how to set up a recurring time control. You might have to use two time controls, one at 6 and one at 10. Alternatively, you could run the timeControl every hour and check the time and use a conditional to decide what to do if the time is correct.

    if hour(datetime('now')==6)
    %pump on
    end
    if hour(datetime('now')==10)
    %pump off
    end

By the way, If you are going to put the esp to sleep in between actions, Ive found the ESP32 to be a lot more reliable in this kind of application.

Ramakrishna Narasimha Swamy
Ramakrishna Narasimha Swamy on 16 Jun 2021

Very much possible. Timer function of the controller needs to be used for generating the trigger. Also, a RTC is required for getting the real time information. It is a straightforward task.