Monday, August 31, 2015

Cabin Fever Part 4: New Plans For How The Unit Will Work

In Part 3 of this "Cabin Fever" project, we were able to get a Temperature reading sent by email.

We realized that it was quite a lot of work for this little computer (technically a microcontroller) to send email. Now, we wanted it to receive emails too.

Revisiting the Original Plans
Our original plans were to:
1. Read a Temperature
2. send an email when the temperature was below some setpoint (like 32 degrees Fahrenheit which is the same as Zero degrees Centigrade, the freezing point of water).
3. Send an email every day with the past 24 temperatures that were read for each of the past 24 hours so we know that the unit is still working
4. Take a command from an email that tells the until to report temperature
5. Maybe, just maybe, also report when power failed

We have realized now that we need to simplify this a bit to allow it to fit into the small RAM memory (1K) on the Arduino Uno we are using.

New Plan
So, the new plan is as follows:
1. Read a Temperature
2. send an email (and copy the email address for the cell phone) when the temperature was below some setpoint (This will orignally be set to 40 degrees Fahrenheit because that is what was requested by the person I'm doing this for).
3. Send an email every week (and copy the email address for the cell phone) with the temperature so we know that the unit is still working
4. Take a command from an email that tells the until to report temperatures  (it will tell how often and how many times)
5. Forget about reporting when the power failed, it's just not practical at this time.

Detailed Requirements
This is what we decided when thinking about the details of the above:

1. When it starts up, it will send the temp once just to let you know it's working (and if it comes back from a power failure)
2. It will send the temp once a week just so you know it's still working
3. When it senses a temp below some setpoint (originally 40 degrees F) then it will send the temp.

It will work in 15 minute increments.
If the temp remains below the setupoint, it will send the temp every hour for the next 24 hours
Then it will send the temp only once a day.
(note: to use the email sending service on temboo that I selected, they only allow a certain number of free "calls" to their routines per month: 250, otherwise you need to pay )

Of course, if the temp goes above the setpoint, it will send one email to show the temp was above the setpoint , then it will stop sending emails again.

4. We can send an email to cause it to send some temps.
The subject of the email message must have the following characters, then it will send the temp according to the parameters:
CFRxx,yy
Where CF means "Cabin Fever" (the name I gave this project)
and
Where R means "Report"
and
where xx is the number of readings you want it sent (01 to 99)
and
where yy is a two digit number of the multiple of 15 minutes (01 to 99)
So, for example,  The following command:
CFR08,12
will cause it to send 8 temp readings that would each be 3 hours apart (12*15minutes)

5. If there is enough memory, I would also suggest we support a command to set the setpoint
CFTzz
where zz is a two digit setpoint temp in Fahrenheit

Issues with Oauth
In order to use Tembo to get gmail emails,we need to set up Oauth. You've probably seen it before, it's usually used when you allow a website to use your facebook or email login to login to some third party website. Oauth (Open Authorization) is used a lot for this. You can read more on it here on wikipedia and technical info here on the Oauth.net website.
This isn't all that complicated, there are instructions, but I ran into a problem that used up 3 to 4 hours because my temboo password had a backslash in it and that was causing issues with the temboo website. It took about a dozen emails  back and forth over 3 days with the temboo support staff to figure out that the password I had used was the issue.

New Issues with Temboo
Once I got past that obstacle, I started looking into the Temboo "choreo" that allowed me to get emails.  I realized that Temboo only allows 250 free "calls" per  month. I want the "Cabin Fever" until to check for an email and when there is on, use the information in the email to tell the "Cabin Fever" unit how often to report temperatures.  Well, since checking for email is a "call" that counts toward the 250 free calls per month, that limits how often I can check for emails.   Using a little math:
24 hours / day X  30 days / Month  / 250 Calls /month =  2.88 hours/call.
So, we would only be able to check email every 2.88 hours. Not good.
We need a new solution.

IBM Bluemix and the Internet of Things Foundation
So, I am now looking into IBMs Internet of Things Foundation and Bluemix programming on the cloud.

An account for Bluemix is free for 30 days and I understand it's also free after that as long as you stay under certain limits.
So, I am following this tutorial and I'll be posting more info about this next.
"Build a cloud-ready temperature sensor with the Arduino Uno and the IBM IoT Foundation, Part 1: Build the circuit and set up the environment"

See part 5







No comments: