Author Options:

Read last feed value? Answered

Great Class, Becky! I loved it!

I would like to know how can I read the last value from a feed. I wanted to store a counter on a Arduino.io feed. Whenever I click a button, I want my ESP8266 module to read the last value from that feed, add 1 and save the value on the same feed. That way I won't lose the count if the ESP8266 is turned off for some reason.

Do you know how can I do that?

2 Replies

bekathwiaBest Answer (author)2017-10-02

Thanks! This last lesson code does basically what you describe. It writes to the same feed it reads from, but displays the feed data without the trigger of a button press. I won't write your project code for you, but I can point you my beginner Arduino class if you could use some help planning out that button and if statement: https://www.instructables.com/class/Arduino-Class/

Select as Best AnswerUndo Best Answer

IgorF2 (author)bekathwia2017-10-02

Thanks for your help! :D

I'm not sure it does exactly what I need. As far as I understood, it initializes the current state as 0 (int current = 0;). Whenever the states changes, it stores the new state value on the command feed (command->save(current);). Then the handleMessage function reads the data from the command feed and performs some actions. The handleMessage only runs when the feed is updated.

In my application, the initial state is unknown by the microcontroller. It is supposed to count the number of times a button was pressed, and store the count on a feed. If I reset the microcontroller, I want it to be able to read what was the last count on the feed (without setting my counter back to zero).

Select as Best AnswerUndo Best Answer