About this project
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 a 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.
Figure 2: Sensor Kit
Components and supplies
- Intel Galileo Gen 1
- Grove Starter Kit Plus Intel IoT Edition
- Temperature Sensor
- Shield
- Wire
- Power Supply (5 Volts)
- USB Cable
- Memory card and Memory Card reader if you want to make the program run on startup (Optional).
Schematics
Figure 3: Connections
Code
-
- #include < Wire.h > #include "rgb_lcd.h"
- const int pinTemp = A0;
- rgb_lcd lcd;
-
- int colorR = 255;
- int colorG = 255;
- int colorB = 0;
- const int b = 3975;
- float resistance;
- float temperature;
- void setup() {
- lcd.begin(16, 2);
- lcd.setRGB(colorR, colorG, colorB);
- delay(1000);
- }
- void loop() {
- lcd.clear();
- delay(1000);
- int val = analogRead(pinTemp);
- resistance = (float)(1023 - val) * 10000 / val;
-
- temperature = 1 / (log(resistance / 10000) / b + 1 / 298.15) - 273.15;
- if (temperature < 27) {
-
- colorR = 0;
- colorG = 0;
- colorB = 255;
- lcd.setRGB(colorR, colorG, colorB);
-
- lcd.print("It's cool at: ");
- lcd.print(temperature);
- } else {
-
- colorR = 255;
- colorG = 0;
- colorB = 0;
- lcd.setRGB(colorR, colorG, colorB);
-
- lcd.print("It's warm at: ");
- lcd.print(temperature);
- }
- delay(5000);
-
- }
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, the 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:
- 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.
- 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.
Figure 4: Code in the IDE
- 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).
- As soon the Temperature Sensor senses the room temperature, which it checks for every 5 seconds, the following 2 conditions take place:
- Temperature is less than 27 degrees.
Figure 5: Temperature is less 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.