So here is what I want to do:
I want various sensors to recieve inputs (continuously or every few minutes) and then if the results go out of a certain range, I want it to alert me via twitter (e.g. if temp goes above 95*F), however although I want the loop to continue cycling to monitor, I would only like a twitter warning message posted every hour or so. Any thoughts on how to do this???
The only thing I could think of was to have a delay at the end of the entire loop sequence (say 5 minutes), and then set a twitter status parameter after it sends the first warning message (int twitter = 12; for example) and each time the loop runs every 5 minutes I subtract one from that value, and the twitter function is only allowed to post a message when twitter == 0 (after an ~1 hour has passed). But how would this work for multiple sensors? Because if at 3:30 i get an overheating warning, then at 3:45 a lighting problem occurs, I still want to be notified about this NEW incident.
Thoughts?
P.S. Anyone seen any good tutorials or projects around that use sending sensor data to twitter?
I don't think that you are the first person who wanted to twit anything... Have you made any attempt to search??? What did you find??? Do you even have an ethernet shield???
Don'''t the duplicate punctuation marks look silly???
Yes, I have searched and read all the documentation on Twitter use on the Arduino.
I am using a WiFi shield, and I already have all the twitter protocols integrated and have a fully functioning code that posts to twitter, however as I described the question I have is how to run the two different parts of my code (sensor readings, run frequently; and the twitter posting, run periodically) on two different time schedules.
I'm not asking how to send twitter posts, I already have that functioning. As I made clear in my primary post the thing I wanted input on is how to delay time between posts while maintaining a constantly cycling loop function.
Keep an unsigned long variable for each alarm. When the error condition occurs, check it against millis to see if enough time has passed that you can tweet again. If it has, store millis in the variable and send your tweet. Look at the blink without delay example to see how to safely use millis handling rollover.
Note that you'll need to initialize those unsigned longs appropriately (-60000UL) if you want to be able to tweet in the first hour (or whatever your limit is) of operation.
I'm not asking how to send twitter posts, I already have that functioning.
My reading comprehension skills were lacking. My apologies.
As I made clear in my primary post the thing I wanted input on is how to delay time between posts while maintaining a constantly cycling loop function.
You need to look at the blink with delay example, to see how to use millis() and a previous time (the last time you did something, whatever that something is) and an interval (how often that something should be done), to see if it's time to do it again.
wildbill:
Keep an unsigned long variable for each alarm. When the error condition occurs, check it against millis to see if enough time has passed that you can tweet again. If it has, store millis in the variable and send your tweet. Look at the blink without delay example to see how to safely use millis handling rollover.
Note that you'll need to initialize those unsigned longs appropriately (-60000UL) if you want to be able to tweet in the first hour (or whatever your limit is) of operation.