In this Instructable, I will walk you through the steps to build an ED-E (EDison-Esp8266, pronounced Eddie). ED-E is a Home Automation and Monitoring System Built with the Intel Edison and Esp8266. ED-E consists of two parts:
- The Base Unit
- Wifi Units
The Base Unit consists of an Intel Edison, six grove sensors for keeping your home safe, a OLED display and four push buttons for user input/output, and an emergency buzzer all enclosed in a 3D printed case. The Intel Edison logs data from the sensors and stores it in a local MySQL database and pushes it to Intel IoT Analytics Dashboard so you can see real time graphs of the data. In an emergency ED-E will sound its buzzer plus send you an email if you are not home. The Base Unit includes the following sensors:
- Gas (H2, LPG, CH4, CO, Alcohol, Smoke, Propane)
- Air Quality (carbon monoxide, alcohol, acetone, thinner, formaldehyde)
The WiFi Units are small portable transmitters to keep you notified of happenings around the home and give control of things when you are away. There are two types of WiFi Units that ED-E supports:
- WiFi Sensors
- WiFi Actuators
The WiFi sensors contain a detection circuit, most likely a switch. When the detection circuit is triggered, the WiFi sensor sends the press back to the base unit which transmits it to the IoT Analytics cloud. The WiFi sensors can be placed in front of doors, windows, mailboxes, and then be used to notify the user of changes in the doors state.
The WiFi Actuators are the opposite: When you press a button on the Intel IoT Analytics site the base unit picks up that press and sends it on to the Actuator. Then the unit triggers an event, most likely a relay. WiFi Actuators can be used to turn on lights, coffee pots, or even open your garage door from anywhere in the world.
ED-E supports an infinite* number of WiFi Units, so the possibilities are endless. In this Instructable I will show you how to build a WiFi sensor button and a WiFi Actuator Relay.
You can find more information on how this project works on hackaday.io.
*Your network service provider or WiFi router probably don't support that many devices.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Materials
Before we begin, let's gather the materials we are going to use.
For the base unit, we will need:
- Intel Edison with Arduino Breakout
- Adafruit Permaproto Half-sized breadboard
- Grove Air Quality Sensor
- Grove MQ2 Gas Sensor
- Grove DHT22 Temperature and Humidity Sensor
- Grove Sound Sensor
- Grove Flame Sensor
- Grove 96x96 OLED Display
- Grove Buzzer
- 0.1" Male Headers
- DC Barrel Jack
- 10K Resistors
- 6mm Tactile Pushbuttons
- Lots of wire
For the WiFi Sensors you will need:
For the WiFi Actuators you will need:
- Adafruit HUZZAH Esp8266
- Grove Relay (SPDT)
- 5V Power Supply (Like a phone charger)
- Short power strip (On the cheap side, you will destroy it)
Note: I don't reccomend using that setup for the acuators, it is quite dangerous having mains voltages in a Altoids tin. Please use a Power Switch Tail instead.
Step 2: 3D Print the Base Unit
The Base Unit of ED-E consists of three 3D Printed parts.
- The left side
- The right side
- The buttons
If you don't own a 3D printer, you can pay a service to do the printing for you. I used Shapeways Black Strong and Flexible Plastic and it turned out great. 3D Hubs is another great service that connects you with local makers that have a 3D printer. Cost is lower but print resolution is obviously not as good.
.stls can be found on thingiverse.
If you are interested in Customizing ED-E, all CAD files are located in its Github repository. Maybe you could try making it easier to mount the buttons?
Step 3: Connecting Sensors to the Base Unit
Lets continue construction of the Base Unit by connecting the sensors to the Intel Edison board. For this step you will need all the sensors (But not the OLED display, we'll attach that in the next step) and the half sized perma proto board along with some wire.
All Grove Sensors use the same 4 wire connector. As you can tell from the image above there is a wire for ground, power, and a signal line. The white wire is also a signal line, but is not used in the base unit sensors (air quality, MQ2 gas, sound, temperature and humidity, buzzer, and flame) Cut one end of the cable off so it can be soldered to the perma proto board.
Lets begin by cutting the perma proto into two pieces roughly the size of the ones in the above image. Next, solder a 1x6 0.1" male header to one side of the board, skip a hole and solder on. another 1x8 male header. Make sure it fits the North side of the arduino expansion board ( the side with the MicroSD slot) just like if you were making half of a arduino shield. You can also solder a 1x8 male header to the other piece of perma proto. This piece of perma proto connects to the female header closest to the Intel Edison Module.
Next you can solder all 8 sensor's red wires to the + rail on the perma proto. Also solder all the black ground wires to the - rail on the bigger perma proto. Now connect the positive rails together from both boards as well as the negatives. On the bigger protoboard solder a jumper wire from the 5V rail to the pin connected to the Edisons 5V as well as one from ground to the ground pin.
Now that you have the power lines all connected, lets connect the signal lines (Yellow wires). They connect as follows:
- Air Quality >A0
- Flame > D2
- MQ2 Gas > A1
- Sound > A2
- Buzzer > D3
- Temperature > D8
Note that the software does not yet support the temperature sensor. See issue 3.
Double check your connections and then continue on! In the next step, we will be connecting the OLED display.
Step 4: Adding a OLED to the Base Unit
Unlike the other sensors, the OLED display does make use of the white signal wire and uses 3.3V logic instead of 5. Lets begin.
- Connect the red power wire to 3.3v
- Connect the black ground wire to ground.
- Connect the yellow signal wire (SCL) to A5
- Connect the white signal wire to (SDA) A4
Your OLED is now ready for use!
Step 5: Add Buttons and Power Jack to the Base Unit
We are almost done with the Base Unit's hardware! For this step you are going to need four pushbuttons, four 10K resistors, and some ribbon cable. You will also need another piece of perma proto.
- Position the four pushbuttons all right next to each other and as close as possible to one side of the protoboard.
- Solder one leg of the top button to D4
- Solder one leg of the select button (Under the top button) to D5
- Solder one leg of the back button (Under the select button) to D6
- Solder one leg of the down button to D7
- Connect four 10K resistors to the same legs used above.
- Connect the other end of each resistor to the 5V power line.
- Connect the other unconnected button legs to ground.
Finally, lets connect the DC barrel jack.
Simply Solder a Wire from ground to the ground pin on the barrel jack, and a wire from VIN to the positive terminal on the barrel jack. Be extra careful nothing is shorted out, as you wouldn't want 12 volts wandering into the Edison where it doesn't belong.
Step 6: Install the Base Units Software
Before we put the Hardware into it's case, we need to install and test the software.
Start by flashing the latest edition of the Edison firmware to your Intel Edison board. More detailed instructions can be found here.
Next, we need to install some of ED-E's dependencies.
1. Open the opkg config file with
2. Add three lines to the file and save it:
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
3. Update the package list with:
4. Finally install dependencies with:
opkg install boost boost-dev libmysqlclient-dev mariadb python-pip
Setup IoT Analytics
Now lets setup the software that allows you to view the sensor data real time in the "cloud" otherwise known as your web browser.
1. Start by updating iotkit-agent with the command:
npm update -g iotkit-agent
2. Go to https://dashboard.us.enableiot.com/ and create an account.
3. Once logged in, put in the name of your system (I put in ED-E) and click create.
4. Click the menu icon in the upper left corner and then click "Account"
5. Open the details tab and get the activation code and run the command below on your Intel Edison:
iotkit-admin activate activation_code
6. Next click on the "Catalog" tab and click "Add New Catalog Item" towards the bottom of the screen.
7. In the component name field type air, set the type to sensor, set the Data type to number, the format to integer, Unit of measure to Air Quality, and display to Time Series. Leave Min and Max blank and click Save.
8. Do the exact same for the other sensors but change the name field and unit of measure to the following:
- sound and sound (db) for the sound sensor
- gas and Gas Level for the MQ2 Gas Sensor
- flame and Fire for the flame sensor
You don't need to catalog the temperature sensor as Intel already created one for you.
1. Download ED-E's software with the command:
2. Rename the package with:
mv 0.1.0.zip ED-E.zip
3. Unzip with:
3. Change to the install directory with:
4. Run the installation script with:
The script should run with no errors.
5. Test the software with:
The display should start clearing and then show the main menu. After a little while the sensors should poll and then upload the data to Intel IoT Analytics. To view the data, go to the "Charts" tab, select your device and the sensor you wish to view the data on. The data is also stored in a MySQL database called "EDE" so you can use it for your own purposes See Exporting Data to Excel.
Run Software On Boot
Now lets set ED-E to run on power up so no terminal is required.
1. Change to the /etc directory.
2. Create init.d directory:
3. Enter it:
4. Create file called ED-E.sh with the following two lines:
#!/bin/sh python ~/ED-E/base/src/main.py
5. Give it execute permissions:
chmod +x ED-E.sh
6. Update with:
update-rc.d ED-E.sh defaults
Reboot and ED-E should start on boot. Now we can continue on to putting it in the case!
Step 7: Base Unit Final Assembly
We are now ready to put everything together. Lets start with the buttons.
1. Carefully glue the button protoboard into place with the 3D printed button rig wedged between the model and board. This is a one line step but the hardest to put together since no bracket or standoffs are present for mounting. I used some perfboard as a brace and made sure to add three coats of plastic cement.
2. Carefully screw in the Air Quality, flame, and sound sensor to the half with the button mount. This should use 6 of your M2x5mm screws.
3. Using two more M2 screws, screw in the OLED display. Be careful.
4. Using four 4-40 screws, attach the Intel Edison + Arduino Breakout to the big standoffs. Be careful not to break them.
5. Connect your protoboard to the Edison. Did I mention be careful?
6. Take some more M2 screws and attach the buzzer, gas, and temperature sensors to the other half.
7. Hot glue the power jack to the base.
8.Screw the two halves together with six 4-40 screws.
9. Power it up and log into it via SSH. You now have a home monitoring unit and automation hub!
Step 8: Analyzing the Data
The data that the base unit stores is not only uploaded to Intel IoT Analytics but is stored in a local MySQL database. You can access it by typing:
Select the E-DE database with the command:
To show data from a sensor use a command like the following:
select * from air;
This should print out all the data every taken from the Air Quality Sensor. The same goes for the gas, sound, temp, and flame sensors. To exit MySQL type:
Export Data to Microsoft Excel
To export the data to a Excel document, go to the data on the Intel Analytics site, select the sensor data and time frame you wish to export, and click the "export" button. Use the picture about as reference. Save, the file and open it in your favorite data analyzing program.
Step 9: Adding Email Notifications
Intel IoT Analytics also supports email notifications. Lets add some.
- In your Intel IoT Analytics account, open the left tab and select "rules"
- Click add rule.
- Put the name and description of the notification to whatever you wish.
- Set the type to "email"
- Select your email (It will be the one associated with your account)
- Click next.
- Check the box of your device (There should only be one)
- Click next.
- Check the "Enable automatic reset" box.
- Set the Monitored Measure field to the sensor you wish to recieve notifications from (for example select fire)
- Set Trigger When to basic condition.
- Set the next drop down to "Equal"
- Set the value to 1.
Now you will be notified by email when your house is burning down! (Or when someone holds a match in front of the sensor to freak you out)
Step 10: Building WiFi Sensors
Building WiFi sensors are simple. All they require are a power circuit and a detector circuit. Lets get started.
1. Connect the Negative terminal on the JST connector to ground on the Huzzah board.
2. Connect the positive terminal on the JST connector to vbat on the Huzzah board.
4. Connect one terminal on the switch to ground.
5. Connect the other terminal to rst.
6. Open the sensor.ino file in the Arduino IDE (Must be version 1.6.4 or higher)
7. Change the SSID and password to your network settings.
8. Change the HOST variable to the base units ip address. This can be viewed in the settings menu on the OLED when ED-E is running or by typing ifconfig in the terminal.
9. Change the device ID to the name of your sensor (for example "Front_Door")
9. Make sure the Adafruit Huzzah board is installed and selected (More info)
10. Flash the code and connect the 500mah battery.
11. Enclose the way you wish. I used an Altoids Mini tin spray painted brown.
12. Catalog the sensor on Intel IoT Analytics with the name field the device ID you put in step 9 and the units category what ever you wish. Set the other fields to the same as you did with the base units sensors.
If the base unit is operating properly and so is the esp8266, whenever the switch is closed the huzzah should send data to ED-E, which should store the press in its MySQL database, and then output it to Intel IoT Analytics.
Each sensor should get pretty long battery life, but when the device does die, you can recharge the batteries with a Micro Lipo Charger.
Step 11: Building WiFi Actuators
WiFi Actuators are the opposite if sensors: The receive data from the web and and change their current state according to that data. Lets build a device that turns on a small power strip when a button is pressed in Intel IoT Analytics.
1. In a terminal on the base unit, activate the actuator with:
iotkit-admin register Lamp powerswitch.v1.0
2. In order for actuation to work, we need to change the protocol from REST to websockets:
iotkit-admin protocol rest+ws
Now that the base unit is set up for actuation, we can build a Actuator Unit.
- Connect GND on the esp8266 to the GND on the Grove Relay.
- Connect V+ on the esp8266 to VCC on the Grove Relay.
- Connect pin 13 on the esp8266 to sig on the Grove Relay.
Lets connect the power supply to the esp8266.
- Connect the GND on the power supply to ground on the esp8266.
- Connect the power wire on the power supply to Vbat on the esp8266.
Now lets connect the power strip to the relay.
- Cut one of the two wires in the center of the cord.
- Strip away the plastic and connect one end to COM and the other to NC (This time its Normally Open, not Not Connected)
- Neatly organize everything in a full sized Altoids tin.
- You will want this tin painted on both the outside and the inside to avoid a short circuit. Before powering anything on be 100% sure the high voltage circuit will NEVER come into contact with the low voltage circuit. Make sure to use insulating tape too, as the paint could easily scratch away and cause mayhem.
- Flash the actuator.ino code to the esp8266. The code is in the ED-E/esp8266/actuators directory. You will need to change the SSID and password to your network settings like you did in the last step.
Reboot the base unit, and then whenever you send a request from the control panel in Intel IoT Analytics, the power strip should turn on whatever is connected to it!