Skip to content

ERaTimer

Quốc Hùng edited this page Dec 20, 2022 · 1 revision

ERaTimer

Timer feature to send data in intervals. It allows you to send data intervals. This is an example, how to send data(uptime) every second with a timer.

/* Create the timer object */
ERaTimer timer;

/* This function send uptime every second to Virtual Pin 1 */
void timerEvent() {
    ERa.virtualWrite(V1, millis() / 1000L);
}

void setup() {
    /* Connecting to ERa */
    ERa.begin(ssid, pass);

    /* Setup timer called function every second */
    timer.setInterval(1000L, timerEvent);
}

void loop() {
    /* Run ERa */
    ERa.run();
    /* Run ERaTimer */
    timer.run();
}

Check example here

Clone this wiki locally