Room Temperature Detection with Galileo Gen 1 and Grove Kit

About this project

Cover Pic
Figure 1:
Cover Pic

Intel Galileo is the first in a line of Arduino - certified development boards based on Intel x86 architecture and is designed for the maker and education communities. Full technical details can be found on the Arduino site.

The GROVE - Starter Kit of GROVE System is a modular, safe and easy to use group of items that allow you to minimize the effort required to get started with microcontroller-based experimentation and learning. Although there are many choices available for microcontroller development environments.

Sensor Kit
Figure 2: Sensor Kit

Components and supplies

  1. Intel Galileo Gen 1
  2. Grove Starter Kit Plus Intel IoT Edition

    1. Temperature Sensor
    2. Shield
    3. Wire

  3. Power Supply (5 Volts)
  4. USB Cable
  5. Memory card and Memory Card reader if you want to make the program run on startup (Optional).

Schematics

Connections
Figure 3: Connections

Code

  1. //Check and display temperature  
  2. #include < Wire.h > #include "rgb_lcd.h"  
  3. const int pinTemp = A0;  
  4. rgb_lcd lcd;  
  5. // Assigning initial color that'll be seen once the Galileo boots  
  6. int colorR = 255;  
  7. int colorG = 255;  
  8. int colorB = 0;  
  9. const int b = 3975;  
  10. float resistance;  
  11. float temperature;  
  12. void setup() {  
  13.     lcd.begin(16, 2);  
  14.     lcd.setRGB(colorR, colorG, colorB);  
  15.     delay(1000);  
  16. }  
  17. void loop() {  
  18.     lcd.clear();  
  19.     delay(1000);  
  20.     int val = analogRead(pinTemp);  
  21.     resistance = (float)(1023 - val) * 10000 / val;  
  22.     //calculate the temperature  
  23.     temperature = 1 / (log(resistance / 10000) / b + 1 / 298.15) - 273.15;  
  24.     if (temperature < 27) {  
  25.         // display color blue  
  26.         colorR = 0;  
  27.         colorG = 0;  
  28.         colorB = 255;  
  29.         lcd.setRGB(colorR, colorG, colorB);  
  30.         //display temperature and  
  31.         lcd.print("It's cool at: ");  
  32.         lcd.print(temperature);  
  33.     } else {  
  34.         //display color red   
  35.         colorR = 255;  
  36.         colorG = 0;  
  37.         colorB = 0;  
  38.         lcd.setRGB(colorR, colorG, colorB);  
  39.         //display temperature  
  40.         lcd.print("It's warm at: ");  
  41.         lcd.print(temperature);  
  42.     }  
  43.     delay(5000);  
  44.     //display current temperature every reading 5 seconds  
  45. }  
Note: This program works in conjuction with 2 files - rgb_lcd.cpp and rgb_lcd.h for controlling the RGB LCD display.

We define 4 variables of type int – colorR, colorG, colorB and b & of type float – resistance, temperature.

We then go to the method loop(), where we find another variable called val, that stores the pinTemp via the method analogRead(). After this, we calculate resistance and temperature, using simple existing formulas.

Inside the loop, before displaying the temperature value, we set the color scheme that will be visible based on the temperature, in our case is "Below 27" and “Above 27”. With the print() method, value of the detected temperature as well as the corresponding message is displayed in Celsius.

The interesting part comes now, with the lcd.clear() and delay() methods, as while the former eliminates all the content currently visible in the display, the delay() method ensures that after every 5 seconds interval it checks the temperature via the Sensor and displays it on the LCD.

Steps:

 

  1. Start with downloading the Arduino IDE for Intel Galileo and the Temperature Sensor code from GitHub.

    Note: Fork the project from here.

    Transfer the .cpp and .h files into the Arduino folder -> Library folder -> Temperature_Sensor and save the .ino file into the same folder.

  2. Open the code in the IDE, select Board as Intel Galileo and Port based on the Port visible in Device Manager, accessed via Win+R and then write devmgmt.msc.

    Code in the IDE
    Figure 4: Code in the IDE

  3. Once the code is uploaded, the LCD shows an initial purple light (because of color R, color G, and colorB being set at 255 each).

  4. As soon the Temperature Sensor senses the room temperature, which it checks for every 5 seconds, the following 2 conditions take place:

    1. Temperature is less than 27 degrees.

      Temperature is less than 27 degrees
      Figure 5: Temperature is less than 27 degrees

    2. Temperature is greater than 27 degrees.

      Temperature is greater than 27 degrees
      Figure 6: Temperature is greater than 27 degrees

Conclusion

In this article, we were able to create a simple yet effective environment sensor for detecting temperature, using just 4 components. For the curious ones, you can easily replace the Temperature sensor with a combined Humidity and Temperature sensor and hence detect and display 2 parameters instead of one, or simply change the color scheme to integrate even more varying temperature limits than just below 27 degrees and above 27 degrees.

Up Next
    Ebook Download
    View all
    Learn
    View all