Introduction: Arduino Component Restarter With Temp Output Using Cayenne
Ok so what is the purpose of this device, I needed a easy way to restart network components. Sometimes the easiest way to fix buggy hardware is to hard reboot it. Right now i am using this for a Guest Router and my smartthings hub (they both need a reboot every now and again. This could be used to turn anything off for 10seconds and then back on automatically. As for the temp sensor the DS18B20 temp sensor is really cheap so you could use it to measure ambient temperature or make sure something in your network closet does not overheat.. Now that you know the devices purpose, here is how to make it.
Step 1: Gathering Your Materials
- Arduino UNO -Amazon $10 OR EBAY ABOUT $5
- Relay- I used This one because i had it and it has outlets- Amazon has them for $20
- Arduino 5100 Ethernet Shield -Amazon $10
DS18B20 Temp Sensor --Amazon 5 for $12!
4.7k Resistor x 1
- Uno power supply -- any 5v to 9v power supply should work, or u can purchase a specially made arduino power supply.
- Arduino IDE
- Cayenne ------- Cayenne is a free service that allows easy Internet Of Things programming and monitoring. If you have never used it, it is very easy to start using with either a raspberry pi or arduino.
Step 2: Prepare the Hardware
- solder the 4.7k resistor between the data (yellow on mine) and the positive (red on mine). Leave enough of a lead on the end so we can solder it to the arduino(or you can breadboard it).
- Solder the temp sensor to the uno, red to 3.3v, black to ground, yellow to digital 3 (D3)
- Solder the relay leads to the uno, one lead to ground and one to digital pin 2 (D2). If you are using a different relay that requires dc voltage you will need to connect a lead to the 3.3v or the 5v depending on the relay. But the data pin is the same.
- Attach the network shield to the uno.
- Connect the completed uno to the computer by USB.
- Find your Port # for your arduino. We will need the port # to connect to it later. This is done by going to the device manager in windows (see pictures).
Step 3: The Cayenne Dashboard
Ok, once you have a account with cayenne you will be at the dashboard, this is where we will start the lesson.
So this is the dashboard, your is probably empty if you just signed up. Click on the "add New" button on the upper left corner and then click on "Device/Widget"
A new list will open up on the right and we will click on the "Microprocessor" option, Then "Arduino". Then ignore the next page and click "next", it may as well say "blah blah blah".
Select Arduino UNO from the list that pops up, you can use any of the arduino boards listed but for this example we are going to use the arduino UNO. Once selected it will ask how we are connecting it to the internet, for this example we are going to use the "Ethernet Shield 5100"
Take note of the authorization token key (a monkey got in the way of mine :) you will need this later.
Click on "sketch" next to the ethernet connection option. this is the sketch to connect the arduino to your cayenne dashboard. we will not be using this sketch as we are adding a temp sensor and we need to modify the default relay code to make it turn back on after turning the router off.
Now it will tell us "waiting for the board to connect" go ahead and minimize the browser for now, now its time for Fun with Arduino IDE. YEAH
Step 4: Add Your Arduino to Your Cayenne Dashboard (The Arduino IDE Part)
- Ok, now for the arduino IDE part. Open arduino and select "tools" in the top menu.
- Change the port # to the correct port number as seen in the pictures.
- Make sure it says Arduino/ Genuino Uno under "Board", if not select that.
- Click on "sketch" on the top menu, then "Include Libraries" and then"Manage Libraries".
- this is the Library Manager, this will download the files needed to make arduino work with cayenne.
- Type "Cayenne" into the search box and click install to install the library.
- Type "onewire" into the search box and download the top two results, we will need these libraries to make the temp sensor work.
- Close the library manager and open the "router_restarter.ion file supplied.
- Erase the stars and enter your authorization key token thingy in here. This was supplied back in the cayenne steps before (the monkey).
- Verify and upload the code to the arduino (the check mark button and the arrow button on the main page of the arduino IDE).
Step 5: Finish on Cayenne (Almost Done)
Once the code is uploaded the arduino uno should show up in the cayenne dashboard. Now we will Click on the "Add New" button in the top left corner of cayenne, and click on "device/Widget" and then Temperature, then our sensor. here you wil have to select your device (Arduino Uno), the Vurtual Pin (V2 for relay and V3 for Temp), and a couple other options (see pictures).
Great, if done right, and no issues, you should have it all connected and be working. You could optionally create a case for it, but i didnt.