Smart stove top in C++

0
53

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Introduction

This smart stove top application is part of a series of how-tos for Internet of Things (IoT) code sample exercises using the Intel® IoT Developer Kit, Intel® Edison board, Intel® IoT Gateway, cloud platforms, APIs, and other technologies.

From this exercise, developers will learn how to:

  • Connect the Intel® Edison board or Intel® IoT Gateway, computing platforms designed for prototyping and producing IoT and wearable computing products.
  • Interface with the Intel® Edison board or Arduino 101* (branded Genuino 101* outside the U.S.) board IO and sensor repository using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore the IoT and implement innovative projects.
  • Run these code samples in the Intel® System Studio IoT Edition (Eclipse* IDE for C/C++ and Java* development) for creating applications that interact with sensors and actuators, enabling a quick start for developing software for the Intel® Edison board or the Intel® Galileo board.
  • Set up a web application server to set the temperature and store this temperature data using Azure Redis Cache* from Microsoft*, Redis Store* from IBM Bluemix*, or Elasticache* using Redis* from Amazon Web Services (AWS)*, different cloud services for connecting IoT solutions including data analysis, machine learning, and a variety of productivity tools to simplify the process of connecting your sensors to the cloud and getting your IoT project up and running quickly.
  • Connect to a server using IoT Hub from Microsoft Azure*, IoT from IBM Bluemix*, IoT from Amazon Web Services (AWS)*, AT&T M2X*, Predix* from GE, or SAP Cloud Platform* IoT, different cloud-based IoT platforms for machine to machine communication.

What it is

Using an Intel® Edison board or Intel® IoT Gateway, this project lets you create a smart stove top that:

  • monitors the temperature using the sensor and gives an audible notification when your food reaches the desired temperature and you need to turn down the heat.
  • can be accessed with your mobile phone via a built-in web interface to set the desired temperature.
  • monitors for a possible fire, by using the attached flame sensor, and gives an urgent audible warning.
  • keeps track of the cooking temperature using cloud-based data storage.

How it works

This smart stove top sensor has a number of useful features designed to help you monitor the temperature of the food you are cooking on your legacy stove top.

You can set the target temperature for a pot on your range top using a web page served directly from the Intel® Edison board or Intel® IoT Gateway, using your mobile phone.

When the target temperature is reached, the speaker gives an audible notification. If an open flame from a pot boiling over is detected, an alarm sounds.

Optionally, data can be stored using your own Microsoft Azure*, IBM Bluemix*, AT&T M2X*, AWS*, Predix*, or SAP* account.

Hardware requirements

Grove* Home Automation Kit containing:

  1. Intel® Edison board with an Arduino* breakout board
  2. Grove Base Shield V2
  3. Grove IR Temperature Sensor
  4. Grove Flame Sensor
  5. Grove Speaker

DFRobot* Starter Kit for Intel® Edison platform, containing:

  1. Intel® Edison module with an Arduino* breakout board
  2. Analog Temperature Sensor
  3. Flame Sensor
  4. I/O Expansion Shield

Software requirements

  1. Intel® System Studio (Eclipse IDE for C/C++ and Java* development)
  2. Microsoft Azure*, IBM Bluemix*, AT&T M2X*, AWS*, Predix*, or SAP* account (optional)

How to set up

This sample is already one of the IoT examples included in Intel® System Studio. To start using it, follow these steps:

  1. From the main menu, select Intel® IoT > Import IoT Examples.
  2. Expand the tree view for C++ > How To Code Samples > Smart Stovetop and click Import Example.
  3. Select your developer board from the selection window then select Next.
  4. Select Intel® IoT C/C++ project from the Select a project type window then click Next.
  5. Select Yocto from the Selct target OS dropdown menu then click Next.
  6. The next tab will ask for connection name and target name. If you do not know these click Search Target.
  7. Select your Edison from the dropdown list. Select OK.
  8. Your connection name and target name should be filled in. Select Finish.
  9. A new window will open for you and you will need to choose a name for your project and click Next.
  10. Your project source files will now be available on the on the upper left of your IDE by default.

Connecting the Grove* sensors

You need to have a Grove* Base Shield V2 connected to an Arduino* compatible breakout board to plug all the Grove devices into the Grove Base Shield V2. Make sure you have the tiny VCC switch on the Grove Base Shield V2 set to 5V.

  1. Plug one end of a Grove cable into the Grove IR Temperature Sensor, and connect the other end to the A0 port on the Grove Base Shield V2.
  2. Plug one end of a Grove cable into the Grove Flame Sensor, and connect the other end to the D4 port on the Grove Base Shield V2.
  3. Plug one end of a Grove cable into the Grove Speaker, and connect the other end to the D5 port on the Grove Base Shield V2.

Connecting the DFRobot* sensors

You need to have a LCD Keypad Shield connected to an Arduino* compatible breakout board to plug all the DFRobot* devices into the LCD Keypad Shield.

  1. Plug one end of a DFRobot* cable into the Analog Temperature Sensor, and connect the other end to the A3 port on the LCD Keypad Shield.

  2. Plug one end of a DFRobot* cable into the Buzzer, and connect the other end to the A1 port on the LCD Keypad Shield.

  3. Plug one end of a DFRobot* cable into the Flame Sensor, and connect the other end to the A2 port on the LCD Keypad Shield.

IoT cloud setup

You can optionally store the data generated by this sample program using cloud-based IoT platforms from Microsoft Azure*, IBM Bluemix*, AT&T M2X*, AWS*, Predix*, or SAP*.

For information on how to connect to your own cloud server, go to:

https://github.com/intel-iot-devkit/iot-samples-cloud-setup

Data store server setup

Optionally, you can store the data generated by this sample program in a back-end database deployed using Microsoft Azure*, IBM Bluemix*, or AWS*, along with Node.js*, and a Redis* data store.

For information on how to set up your own cloud data server, go to:

https://github.com/intel-iot-devkit/intel-iot-examples-datastore

Configuring the example for your hardware kit

To configure the example for the specific hardware kit that you are using, either Grove* or DFRobot*:

  1. From the main menu, select Project > Properties dialog box is displayed.
  2. Expand the section C/C++ General.
    Click on the Paths and Symbols sub-section, and click on the Symbols tab.
  3. Now click on GNU C++, and click on the Add button.
  4. In the Name field, enter “INTEL_IOT_KIT”. In the Value field, enter either “GROVEKIT” (this is the default) or “DFROBOTKIT”, depending on which hardware kit you wish to use.
  5. Your new name symbol and value will now be displayed. Click OK.
  6. Another dialog box will appear asking to rebuild project. Click OK.

Connecting your Intel® Edison board or Intel® IoT Gateway to Intel® System Studio

  1. On the Target SSH Connections tab, right-click your device and select Connect.

If prompted for the username and password, the username is root and the password is whatever you specified when configuring the Intel® Edison board.

Running the example with the cloud server

To run the example with the optional back-end data store, you need to set the SERVER and AUTH_TOKEN environment variables. You can do this in Eclipse as follows:

  1. From the Run menu, select Run Configurations.
    The Run Configurations dialog box is displayed.

  2. Under C/C++ Remote Application, click doorbell.
    This displays the information for the application.

  3. In the Commands to execute before application field, add the following environment variables so it looks like this, except using the server and authentication token that correspond to your own setup:


    <code> chmod 755 /tmp/smart-stovetop;export API_KEY="YOURKEY"; export SERVER="http://intel-examples.azurewebsites.net/counter/logger/smart-stove"; export AUTH_TOKEN="YOURTOKEN"
    </code>

  4. Click Apply to save your new environment variables.

Now when you run your program using the Run button, it should be able to call your server to save the data right from the Intel® Edison board or Intel® IoT Gateway.

Running the code on the Intel® Edison board or Intel® IoT Gateway

When you’re ready to run the example, click Run at the top menu bar in Intel® IoT Gateway to Intel® System Studio.

This compiles the program using the Cross G++ Compiler, links it using the Cross G++ Linker, transfers the binary to the Intel® Edison board or Intel® IoT Gateway, and then executes it on the board itself.

After running the program, you should see output similar to the one in the image below.

Intel® IoT Gateway setup

You can run this example using an Intel® IoT Gateway connected to an Arduino 101* (branded Genuino 101* outside the U.S.).

Make sure your Intel® IoT Gateway is setup using Intel® IoT Gateway Software Suite, by following the directions on the web site here:

https://software.intel.com/en-us/getting-started-with-intel-iot-gateways-and-iotdk

The Arduino 101* (branded Genuino 101* outside the U.S.) needs to have the Firmata* firmware installed. If you have IMRAA installed on your gateway, this will be done automatically. Otherwise, install the StandardFirmata or ConfigurableFirmata sketch manually onto your Arduino 101* (branded Genuino 101* outside the U.S.).

Regenerating HTML and CSS

If you make any changes to either the index.html or styles.css file, you need to regenerate the .hex file used to serve up the assets via the built-in Crow* web server.

For help using the shell script, go to this link:

how-to-run-the-shellscript.md

Setting the temperature

The target temperature is set using a single-page web interface served up from the Intel® Edison board or Intel® IoT Gateway while the sample program is running.

The web server runs on port 3000; if the Intel® Edison board or Intel® IoT Gateway is connected to Wi-Fi on 192.168.1.13, the address to browse to if you are on the same network is http://192.168.1.13:3000.

IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.

LEAVE A REPLY