Intro: Weather Monitoring With IntelGalileo and Thingworx Cloudplatform
IoT is all about connecting devices at the Edge with Applications in the Cloud.Our project demonstrates on how to connect the sensors to the cloud (thingworx platform )and get stimulated data readings then and there.
Step 1: What You Will Need :
- Intel galileo board(Arduino compactible)
- temperature and humidity sensor
- bread board
- jumping wires
- PC or a laptop
- Internet and Wifi connection.
(note : Make sure you have a thingworx account to work on.)
Step 2: Set Up the Hardware Part( HTU21D Temperature and Humidity Sensor )
- First unplug the USB cable and then the power supply and proceed to connecting the HTU21D sensor.
- The HTU21D Temperature and Humidity sensor has 4 pins, Ground, 3.3 V Voltage, SDA (Serial Data Line), SCL (Serial Clock Line), that need to be connected to the Intel Galileo.
- Place the HTU21D sensor on the solderless breadboard with the description of the pins towards you.
- Install a SD-Card Linux Image (Intel Galileo already has a preinstalled Linux like operating system, but its functionalities are quite limited due to its tiny size, only 8 MB stored on the build-in flash memory of the Intel Galileo board. To enable your IoT project you will need to use a more powerful Linux image)
- Plug the micro SD card in your Intel Galileo micro SD card slot
- .Connect the Ethernet cable. See the section below to learn how to use a Wi-Fi connection instead of an Ethernet cable.
- Connect the power supply.Wait for a few seconds so that the USB LED lights up and the board has booted from the SD card.Connect the USB cable between your board and your PC
Step 3: How to Read Temperature and Humidity Data
- download the Rest_API_Arduino_Uno.ino file from the ThingWorx site, you will find it in your downloads folder.
- To open it, launch the Arduino IDE and click File-> Open. Then locate the downloaded file and click Open.
- Now move to the thingworx composer in your PC
- Next, modify the following variables:
- 1. server variable : Give it the name of your ThingWorx hosted instance. Let’s say you are using this link to access ThingWorx. http://thingworx-academicstaff.ptcmscloud.com/Thi... Then, your server variable will be: char server = "thingworx-academic-staff.ptcmscloud.com"; Port variable: Leave it 80 if you are using http or set it to 443 if you are using https.
- 2. appKey variable. (The App key is a ThingWorx created object that is used in the authentication into the ThingWorx Server process. Application keys are used whenever one would like to interact with a ThingWorx Application outside of the actual ThingWorx Web Application. To get this value go to your ThingWorx Composer home tab and locate Application Key in the Security section).
- Click it and click the +New Button.Enter a name, for example: ArduinoUnoKey and select your User in theUserName Reference field.
- Choose the Vocabulary in which you want to create it and give the term a name. For example ArduinoUnoWeatherProject.
Step 4: To Create a Thing on Your ThingWorx Platform
- Go to Things and click New.
- Name the Thing HTU21DThing. Tag it with your ArduinoUnoWeatherProject tag .
- Select GenericThing as a Template. Next click Save and go to the Properties Section of your Thing.
- Here make sure your Thing is in edit mode and click Add My Property.
- Start with the Temperature property. Type Temperature (Make sure you keep the upper case too, because the REST call is case-sensitive) in the Name field and select Number as Base Type.
- Next, click Done and Add to add also the Humidity property.
- Click Done and go to the Services section. Click Add My Service and call the new Service setTempAndHumid
- Click the Inputs/Outputs tab and add two String inputs. Name them : Temp and Humid (Make sure you use this exact names and Base types because this is taken into account when building the HTTP Post Request in your Arduino sketch.)
- In the script area paste in the following code that sets your HTU21DThing properties values to the values of the input parameters of your setTempAndHumid service.
- me.Temperature = parseFloat(Temp) ;
- me.Humidity = parseFloat(Humid) ;
Step 5: Bind the Data Into Thingworx for Intel Galileo
- To be able to see the data coming from the sensor to Thingworx you will need to bind this information to a Remote Thing that you will name HTU21DThing because this is the thing name you used in the code to register properties and bind in Thingworx.
Step 6: .
- Next, go to Thingworx Composer and create a Remote Thing. In Thingworx on the home tab, select Things under the Modelling section and click +New.
- Name the Thing HTU21DThing, Tag it with the IntelGalileoWeatherProject tag and select RemoteThing as Thing Template.
- Next, click Save. We will now bring in the remote properties. Press edit and go to the Properties Section. Click Manage Bindings.
- Next, click Add All Above Properties.Next click Done and Save the Thing.
- You should now see values for Temperature and Humidity being regularly updated when you click the Refresh Properties button.
Step 7: You Are Done.
- now you can design your mash up as you wish,create new entities and display it in your thingworx composer homepage.
Have a nice day :-)