Intro to Intel XDK IoT Edition Using a Temperature Display
by Frowney001 in Circuits > Wireless
5320 Views, 28 Favorites, 0 Comments
Intro to Intel XDK IoT Edition Using a Temperature Display
![DSC_4078.jpg](/proxy/?url=https://content.instructables.com/F5X/5AVP/I42MHCFK/F5X5AVPI42MHCFK.jpg&filename=DSC_4078.jpg)
Welcome back! In this instructable I will be guiding you in making your own digital thermometer with a button-controlled temperature "hold" feature. This instructable uses parts from the Intel Edison IoT Dev Kit, which was very generously given to me from Intel and Instructables. Specifically, the parts used are as follows:
- Intel Edison w/ Arduino Breakout
- Grove Base Shield v2
- Grove RGB Backlight LCD
- Grove Temperature module
- Grove Push-button module
- 3D printed mount (optional)
In my other Instructables, and in many others, people are using the Arduino part of the Edison to do things. This Instructable is written to show the use of Intel's XDK IoT Edition software.
Before going any farther, I want to thank Intel and Instructables for being awesome by selecting me along with 249 others to receive a Dev Kit. That was very surprising to me, and I am very grateful for it. Thank you!
Get Connected!
![Get Connected.png](/proxy/?url=https://content.instructables.com/F1S/1748/I42MHCFS/F1S1748I42MHCFS.png&filename=Get Connected.png)
![Connected over WiFi.png](/proxy/?url=https://content.instructables.com/F8F/W3OL/I42MHCEJ/F8FW3OLI42MHCEJ.png&filename=Connected over WiFi.png)
This instructable assumes you already have XDK IoT Edition set up on your computer and Edison. If you do not, check out the tutorial from Intel.
Wiring everything up is simple, and it is explained in one of my other Instructables.
To connect to your Edison through the XDK:
- Turn on your Edison
- Connect to the same WiFi network as the Edison
- In the bottom left of the XDK, pull down the drop-down menu
- Select your Edison (or manually add) (see the first image)
That's it! You should see a popup similar to that in image 2. If you don't, check out what it says and fix what's wrong. The only message I've gotten otherwise was a whitelist issue. It tells you how to do what you need to.
Now you can program it!
Write the Code!
Programming with the XDK is a little different from programming with Arduino. Arduino is in C, while the XDK is with JavaScript. Some experience with programming is necessary to understand what is going on here, though none is needed to get this to work. I, personally, have experience in many languages, so all I generally need to pick up a new one is the keywords. I tried documenting what I felt was necessary/helpful, but if you need something explained just ask me!
/*jslint node:true,vars:true,bitwise:true,unparam:true */ /*jshint unused:true */ // Those above are required by javascript. var mraa = require("mraa"); // A new object of class "mraa" //Grove Temperature module, plugged into Analog pin 0 var temperature = new mraa.Aio(0); var B = 3975; var button = new mraa.Gpio(5); var buttonState = 0; var clearString = " "; // Will be called when we want to clear a line on the LCD var Screen = require('jsupm_i2clcd'); // A new object of class "jsupm_i2clcd" (lcd class) var Lcd = new Screen.Jhd1313m1 (0, 0x3E, 0x62); //Initialize Jhd1313m1 at 0x62 (RGB_ADDRESS) and 0x3E (LCD_ADDRESS) // These are the 2 methods of Lcd. setCursor(row,column) and write(string) Lcd.setCursor(0,0); Lcd.write("Temperature:"); // start the functions checkButton(); tempDisplay(); function tempDisplay() { // If the button is not being pressed, display the temperature... if(buttonState == 0) { var fahrenheit_temperature = getTemp(); // ask for the temperature Lcd.setCursor(1,0); Lcd.write(clearString); // clear the "HOLD" string, in case it was there Lcd.setCursor(1,0); Lcd.write("F: " + parseInt(fahrenheit_temperature*100,10)/100); // This shows the temperature to 2 decimal places } setTimeout(tempDisplay,1000); // ... every second } function getTemp() { var a = temperature.read(); var resistance = (1023 - a) * 10000 / a; // get the resistance of the sensor; var celsius_temperature = 1 / (Math.log(resistance / 10000) / B + 1 / 298.15) - 273.15; // convert to temperature, based on Grove's datasheet var fahrenheit_temperature = (celsius_temperature * (9 / 5)) + 32; // convert to fahrenheit return fahrenheit_temperature; // return the temperature } function checkButton() { buttonState = button.read(); // Let the user know the temperature display is being HELD if(buttonState == 1) { Lcd.setCursor(1,10); Lcd.write("HOLD"); } setTimeout(checkButton,10); // call this function every 10 milliseconds }
I wrote a few other Instructables with this temperature display as the example setup. In them, I had the button activate the backlight for a few seconds. This is slightly different because I have the button "holding" the current temperature. I do not know, and cannot find any references on how to, turn on/off or change the color of the RGB backlight.
Upload and Enjoy!
![DSC_4079.jpg](/proxy/?url=https://content.instructables.com/FN2/PAQJ/I42MHCFL/FN2PAQJI42MHCFL.jpg&filename=DSC_4079.jpg)
![DSC_4080.jpg](/proxy/?url=https://content.instructables.com/FY3/1EFV/I42MHCFO/FY31EFVI42MHCFO.jpg&filename=DSC_4080.jpg)
Uploading with the XDK can be done over the network, which makes is very nice. This is one of the great things about the Internet of Things. In the XDK, save the file you are going to be uploading. Then, in the bottom taskbar, click on the hammer icon. This has it "build" the program, then uploads it. After it's uploaded and you want to run it, click on the icon with the green "play" button. To stop the program, click on the icon with the red "stop" button.
That's it! Now you can browse through the demos in the XDK and hopefully make some neat projects!