Home Temperature Monitor


#1

Hello everyone! First time posting.

After receiving an S3A7 IoT Fast Prototyping Kit, I followed the instructions for the Smart Chef demo. Once that was running, I followed the ‘Getting Started Guide’ which I found to be quite helpful http://renesas-docs.mediumone.com/. Finally, I looked through the workflow libraries here: http://renesas-docs.mediumone.com//?libraries/introduction. Those three resources gave me enough information to begin.

As a ‘hello world’ project for this system, I plan to reconfigure the Smart Chef demo code so that the S3A7 board functions as a home temperature monitor. Several commercially available IoT thermostats have this functionality. Another example of a product with this functionality is a freeze alarm. Freeze alarms monitor temperature and send out a warning by SMS, push, or phone call etc. when the temperature falls below a certain threshold. This is important where outside temperatures drop below freezing, and you need to make sure water pipes don’t freeze.

Here is the project definition:

Schedule temperature readings from the ENS210 temperature and humidity sensor every hour.
Store the readings in persistent memory.
Email each day’s formatted data log every 24 hours.

The real purpose of this project to gain familiarity with the IoT sandbox development environment and the associated hardware. I also need to learn some Python. In the past I have worked with Java and C, but this my first time writing Python.

There are plenty of other functions that I may add later, after the basic project is complete. Threshold warnings by SMS or push are an obvious feature. Another thing I’d like to add would be the ability to remotely request a temperature reading. I’ll also add humidity (which you get automatically every time you request a read from the ENS210).

I’ve actually got most of this working. Much of the code already exists in the various Smart Chef workflows. I had to write several new workflows and turn off most of the Smart Chef functionality. There’s enough substance here to learn a great deal about the system. Once the project is done, I’ll post all of the details.


Connecting Renesas S7G2 to Arduino Shields
#2

This is fantastic. Would love to see this up and running. The freeze alert is a cool feature. I remember my friend’s condo in Tahoe had a plumbing failure and flooding due to freezing.

I’ve been having a lot of fun with the board and with Medium One. They’ve built a fairly comprehensive system with a lot of pre-built modules. I really like that they used Python.


#3

I would be very interested in this functionality, too. Taking a sensor reading when I want, not just at set intervals, would be really useful. I’ll be looking into this myself, but if/when you get that built and are willing to share, that would be great.


#4

Jesse, maybe you can go through this blog and just document one notification from the mobile app to the dashboard?

http://renesas-blog.mediumone.com/renesas-iot-sandbox-mobile-app-quick-start-guide/

This section looks like a good section to start with. If you can send a notification from your Mac to Medium One, that’s a good start. I would probably try using the switch first.

I have not tried it yet.

LET’S CREATE SAMPLE DATA FROM CURL TO THE CLOUD

This curl example is based on Mac OS linux. Refer to renesas-docs.mediumone.com on Windows example.

TIP: Make sure you have write access in your directory, the curl command creates and saves a cookie file.

Open terminal and type the following (substitute your username, password and API key from the previous step):

curl -c cookies.txt -X POST -k -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -i ‘https://api-renesas-na-sandbox.mediumone.com/v2/login’ -d ‘{“login_id”: “mobile“, “password”: “9243>73kA“, “api_key”: “ABXTEM2R5KCCNZDBXTFBIAJQGQ4DCNRRHA2GENJYGQ3TAMBQ“}’

If successful, it will return true at the command line.

Next, we are going to send an event.

curl -b cookies.txt -k -i -H “Content-Type: application/json” -H “Accept: application/json” -X POST “https://api-renesas-na-sandbox.mediumone.com/v2/events/raw/mobile” -d ‘{“event_data”:{“gps”:”37.354107 -121.955238″,”temperature”:110,”notification”:”Fire! Fire!”}}’

This event includes 3 data points: gps, temperature, and notification. These will translate to “tags” in the Renesas IoT Sandbox.


#5

@jcasman I got so excited thinking about this, that I dropped the curl syntax into bash script and tried it myself.

In the Real Time Events Log, I can now see the data sent from my curl script to the dashboard! So cool!

With this simple http request, you should be able to send a single or text string to medium one to control the board. Notice that i edited the text message in the example above.

This stuff is so cool. Medium One did a great job.


#6

I also found curl to be very helpful. When I first started this project, I used it to send triggers in order to debug code. That was before I was aware that you could do the same thing with the debugger! The home temperature monitor is working well enough to post, so I just need to write it up after cleaning and commenting the code.

I talked to Jesse about this tonight, and I plan to configure an app on my phone with a button I can push to retrieve the current temperature wherever the sensor is. I haven’t done anything with the mobile app other than what is included with the Smart Chef demo. Hopefully it is easy to send an event as you’ve done above. In any case, I’ll learn a bit about using this system’s mobile capability.


#7

Very cool. I’m enjoying reading about other projects and feel motivated to keep working myself every time I read what other people are doing. This community sharing is a great inspiration to keep learning.

The curl example above is a bit funky due to the weird single and double quotes that got formatted when I copied and pasted it from the Medium One blog.

If anyone has problems with the curl example above due to the quotes, here’s the bash scripts that I used. It was simply easier to edit a file than to have everything on the command line.

This creates the cookie.txt file

#!/bin/bash
# change the values below to your username, password and API Key
# from Medium One. Values must be in double quotes
APIKEY="your_api_key_from_medium_one"
USERNAME="mobile"
PASSWORD="your_password"
#############################
# Do not edit below this line
# Add quotes
APIKEY="\"$APIKEY\""
USERNAME="\"$USERNAME\""
PASSWORD="\"$PASSWORD\""
DATA="{\"login_id\":$USERNAME,\"password\":$PASSWORD,\"api_key\":$APIKEY}"
HEADERS="-H Content-Type:application/json -H Accept:application/json"
URL="-i https://api-renesas-na-sandbox.mediumone.com/v2/login"
CURLARGS=" -c cookies.txt -X POST -k $HEADERS $URL"
# run curl
curl $CURLARGS --data $DATA

This sends the event. You need to create the cookie.txt file with this script prior to running the script below to send events.

#!/bin/bash

HEADER="-H Content-Type:application/json -H Accept:application/json"
POST_URL="-X POST https://api-renesas-na-sandbox.mediumone.com/v2/events/raw/mobile"
CURLARGS="-b cookies.txt -k -i $HEADER $POST_URL"

curl $CURLARGS -d '{"event_data":{"gps":"37.354107 -121.955238","temperature":110,"notification":"Hey Jesse, it works! Just do it!"}}'

When you run the second script, you can see the real time event.

I’m not lovin’ all the quotes when putting curl into a bash script, but it does make it easier to test. I’m getting old and have to squint to see the double and single quotes when they’re next to each other. :frowning:

The Smart Chef Demo and the Medium One blog post above both have some excellent examples of the mobile app. I think you’ll be able to test it in minutes and be on your way to getting the workflow working, which may take a while depending on what you want to happen with the trigger. Though, I think it’ll be a fun ride.

There’s a lot of fun learning going on with these IoT projects for me since there’s a nice physical component of the sensors and screen. Also, I get to force myself to learn more about IT or systems tools like bash scripts and curl, which I hear about all the time, but never dug into too deeply.


#8

As second script to send events had everything on one line, I edited it to put the variables at the top. I also decided to use a double-single-double quote syntax instead othe escaped doubled quotes.

#!/bin/bash

## Edit the test data below
POSITION="37.354107 -121.955238"
TEMPERATURE=110
MESSAGE="Put your test message here"
#################################
#### Do not edit below this line

## Run curl
curl -b cookies.txt -k -i \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-X POST https://api-renesas-na-sandbox.mediumone.com/v2/events/raw/mobile \
--data '{"event_data":{"gps":"'"$POSITION"'","temperature":'$TEMPERATURE',"notification":"'"$MESSAGE"'"}}'

After I learned about bash, I got the mobile alerts working as well.

The pre-built toggle switch seems like it could be the basis of the application.

Click on the mobile phone, I’m getting nearly instant events on my dashboard:


#9

Thanks for figuring this all out. The mobile app opens up all kinds of very cool possibilities. I can’t wait to get started!


#10

Hi @Dan, @craig and @jcasman, I’m very excited seeing what you’ve done so far!

I have a SK-S7G2, and I’ll start developing a sample for it based on the Smart Chef demo of the S3A7.
I’m inspired in your tutorial “Home Temperature Monitor” - Home Temperature Monitor with S3A7.
You did a great job with this connected thermostate tutorial.

The Smart Chef demo / sample is a quick start showing how to collect data and react with a given cloud workflow of processed data.
IoT is that. It is sense at the sensor itself, think at the cloud, react at the environment (I also have a mote: “sense, think, react”)

The fact that the Renesas IoT Sandbox at Medium One has such capabilites turn possible to integrate a complex set of devices.

As I am an Android developer, I’m very curious to develop an Android application using the Sandbox API (link here: http://renesas-docs.mediumone.com//?mobile)

I’m thinking about getting some of my sensors here and develop a system capable of notifying fire and gas leakage.

Next from this one, I plan to be a UV sensor to notify UV data all day, alerting users to protect themselves of high UV.

What do you think, guys?

Thanks,
Andre


#11

This is great. As you’re an Android developer, you can use the REST-like API for the Renesas IoT Sandbox to have your mobile app communicate with the sandbox. This is a good tutorial:

RENESAS IOT SANDBOX MOBILE APP – QUICK START GUIDE

Also, if you’re not already using bash and curl, here’s another article that might be useful:

3 Strategies for Using Bash On Windows With Medium One Real Time Events

The developer of the mobile app is active in this forum and she’s super smart. It’s possible she may even give you some tips on building Android apps with the Medium One API if you have questions.

Can the Renesas AMS Sensor board detect UV or do you need to buy a UV sensor? Have you identified a sensor to use?