Hello again!

I released a live temperature display for the intel edison a couple of days ago and it seemed to go rather well,

I have been tinkering around with the edison a bit more and have managed to get my head around the coding language and how things work.

It was all new to me, I had never touched an arduino before so I had no idea how it all worked or how to go about doing things. However since I released that I have been flicking through the examples that Seeedstudio provide with the grove kits and have worked out some pretty cool code.

Got a little sidetracked there, whoops!

This instructable will make a lot more sense if you have a read through my Live temperature display, this project is based on the code from the live display and I have given a brief introduction into the Edison in case you’re unaware of what it is, what it can do and why. You can see it here

The idea behind this instructable is to build on the skills that we learned in my previous ‘ible and do some pretty cool things in the process.This project does the following :

1. Checks the temperature every second

2. Displays the temperature on the LCD display

3. If the temp is above a set temp then enable a relay and led

3. if not over the set temp then keep led and relay off, and loop to start

I have commented all my code to make it easier for you to understand and change it to your use or application.

Time to go part collecting!

For this bit you’re going to need the following,

(remember I am using modules from the grove kit from seeedstudio)

1* Intel Edison

1* Edison Arduino Expansion Board

1* LED driver board

1 * LED of your choice (I used a green)

1* relay board / relay

1* temperature sensor

4* Module connect cables

If you need to buy them you can get the kits here

before we get stuck in I am assuming you have your edison set up as per Intels guide, If not you can view it here.

Before connecting it all up I suggest you disconnect the power from the edison, it helps prevent any short circuits and other issues.

The temperature probe needs to connect to port A0 on the expansion board

The Relay needs to connect to D4 on the expansion board

The LED connects to D3 on the board

and the LCD hooks up to the I2C on the left hand side

Once connected up, power on your Edison, and connect it to your computer,


It’s time to code! (and yes, the gif was needed  )

All connected up? time to get stuck in to the code,

Launch up the Arduino IDE and make a new project / sketchbook, and we can get coding!

I’ll talk through my code below but you can download the whole thing here to save you copying and pasting bits of it together.

Anything with a “//” before it is a comment

This is the start of the code, just loading the libraries

// including required libraries
#include <Wire.h>
#include "rgb_lcd.h"

This next bit sets the variables that the main loop requires. As you can see in the comments; it is telling it that the temp sensor is on A0, the Relay is attached to D4 and the LED on D3

//setting var's

const int pinTemp = A0;      // pin of temperature sensor
float temperature;
int B=3975;                  // B value of the thermistor
float resistance;
rgb_lcd lcd;
const int relaypin =  4;   //the Relay is attached to D4
const int ledpin   =  3;    //The LED module is attached to D3

Now we run the setup section, this code is only ran once on the startup of the Edison, there’s no need for the code in here to be run over and over again in a loop.

It sets the pins D3 and D4 to output and sets the LCD screen size (in my case 16*2)

// the setup part

void setup()
    pinMode(relaypin, OUTPUT); //sets relay to output
    pinMode(ledpin, OUTPUT);   //sets led board to output
    lcd.begin(16, 2);          // lets the main loop know that the lcd is 16 by 2

Now for the main loop of code :

This section calculates the raw output of the temp sensor into degrees celsius, which is a lot easier for us humans to read.

void loop() // start of the main loop of code
    int val = analogRead(pinTemp);                               // get analog value
    resistance=(float)(1023-val)*10000/val;                      // get resistance
    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;     // calc temperature

Now this bit prints out to the LCD, only for visual reasons, it’s handy to have, in the future you may want to remove the LCD as it’s not an essential part of the project .The comments explain it for you

// Print out to the LCD 
    lcd.print("It is ");    
    lcd.print(temperature); //print the output of the above calculations
    lcd.print(" *C");       
    delay(1000);            // delay 1 second, adjust this to affect the rate that the device polls the temp
    lcd.clear();	    // refreshes the LCD

Now for the interesting part, This bit constantly reads the value of the temperature probe, checks to see if the value is over 25, if it is it then activates the relay and LED (connect a fan to it for a good cooler). If the value is under 25 then it leaves the LED and Relay off.

 //If temperature is over 25 degrees then enable relay and LED
    if (temperature > 25) //if the temp is more that 25 then action the below 
        digitalWrite(relaypin, HIGH); // turns on the relay if temp above 25
        digitalWrite(ledpin, HIGH);   // also turns on the LED
      else			     // if it isn't 25 then keep the relay and led off
        digitalWrite(relaypin, LOW); //turn the relay off
        digitalWrite(ledpin, LOW);   //turn the LED off


Thats the code done  time for a tea break..

Well, thats the code done and dusted,

Time to send the code over from the arduino IDE, just whack the right facing arrow on the toolbar,

The edison should then leap into life and start showing temperatures on the display, if it does just grab the temp sensor and hold it in your hands, maybe breathe on it,

you should then see the temps rising on the LCD, here is mine at room temperature (sorry about the bad pic quality – had to use my phone)

and after I warm it up :

When it hit the 25 degrees mark, the relay activated and the LED came on, my hands warmed it all the way to 31 degrees and the relay stayed on as planned.

The LED:

The relay:

I didn’t have anything connected to the relay, but you could have a fan connected or maybe another circuit, the point of a relay is to turn things off and on whilst using a low power activator (in my case the edison)

Here’s a video of it all in work :https://web.archive.org/web/20200927163958if_/http://www.youtube.com/embed/COpjRJ7XaHg

So, all up and running! good eh?

You can adjust the temperature that the relay acts at, just change the line of code (it has a comment next to it). It also may be a good idea to adjust the rate of the temperature readings as you’ll see in the video it can flick the relay on / off quite a lot at the 24 / 25 / 26 mark as it hops in and out of above / below the 25 degrees.