An AllThingsTalk Experiment using a light sensor to measure environmental lumosity and show the result in a widget on your computer, displaying and interpreting the value in a lux scale.
For this experiment we use the Grove light sensor. It’s an ideal starter project to become familiar with the board, Grove and more importantly using the AllThingsTalk Maker to monitor and interpret real-time sensor values.
Basic knowledge of Raspberry Pi, if you’ve never used an Raspberry Pi before we suggest the setup guide.
First we need to create our device. Log in to AllThingsTalk Maker and navigate to the ground in which you want to create your device. Next follow these instructions.
If you just created a new account, you will have a default ground called playground setup for you. You can use this ground to create your devices.
When you have executed the previous task, an example of the lightsensor python application is already present on your Raspberry Pi.
sudo nano lightsensor.py
1 | IOT.DeviceId = "" |
Copy and paste these credentails from the AllThingsTalk Maker into the script.
You find the device credentials under the SETUP tab of your device settings, which you can find behind the gear icon.
The Raspberry Pi will use C# applications which you write and modify on your computer.
You can find the light sensor
application in the experiments folder of the libraries you downloaded to your computer.
MainPage.xaml.cs
file in your project1 | _device = new Device("your client id", "your client key", _logger); |
You find the device credentials under the SETUP tab of your device settings, which you can find behind the gear icon.
Run the motionDetector script with the command sudo python lightsensor.py
If everything went ok, you should see some lines appear in the shell and after the python script has been executed, you should now see the assets created under your device in the AllThingsTalk Maker (you may need to refresh your screen).
To run the C# application, make sure you set the target device correctly in Visual Studio. Do this by entering the IP-address of your device as seen below.
Now simply hit Run and your application will start. You should now see the assets created under your device in AllThingsTalk Maker.
To visualise our date, we will create a pinboard. For more information on pinboards, please check how to use pinboards.
Now we will pin a control (visual representation) for our Light sensor asset.
Note that you can pin the same asset multiple times. For example, pin the above asset again, this time using a label control. For some extra options to customise your controls, please check the Controls page.