Introduction: Intel Edison Sun Station (UV and Temp) With Python #IntelMakerMx
We are gonna use our Intel Edison with an Arduino shield and a grove shield to connect as many sensors as you want.
GitHub : https://github.com/Kurtz1993/iot-roadshow
Step 1: Communicate With Our Edison Through a Serial COM
First, let’s communicate with our Edison through a Serial COM. Install correct drivers for Edison (https://software.intel.com/es-es/iot/library/edison-getting-started) .
Then open your fav Term software, we are gonna use Tera Term (https://ttssh2.osdn.jp/index.html.en) and set correct COM PORT for Edison and BaudRate to 115200. And that’s it, you are now talking with your Edison board.
If nothing appears on your TeraTerm screen, just tap enter. Then just write: root, for loggin into your Linux Yocto.
Step 2: Installing a Repo
We are gonna use an unoficcial Repo for Intel Edison, please just follow the next instructions from the next link: http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html
Once you complete the steps from the link, use your fav text editor on Linux, I’m using “nano”, to install it just write: opkg Install nano.
Step 3: Sensors
UV sensor that we used it’s a Grove UV sensor. You can see the wiki here: http://www.seeedstudio.com/wiki/Grove_-_UV_Sensor.
We totally recommended to check this ebook to know more about Edison programming in Linux Enviroment : https://theiotlearninginitiative.gitbooks.io/internetofthings101/content/documentation/PythonProgrammingLanguage.html take a look on the libraries rmaa and upm.
You can find amazing examples in the next link for Python environment: https://github.com/intel-iot-devkit/upm/tree/master/examples/python.
In additional we’re gonna use a Grove Temperature sensor, just to provide more information to the user. Wiki: http://www.seeedstudio.com/wiki/Grove_-_Temperature_Sensor
Step 4: Connecting Sensors to Edison Boards
So, let’s start to connect our Edison and sensors.
-Be carefull with the way that you connect your wires to the shield, I recommend to pair GND pin with Black wire, so it will be easier identify each pin on the shield and your sensor.
-Both are analog sensors, so you have to connect it to Analog Inputs, something like this.
-If you want to add a status led you can do it, I added a RGB Led, and connected in this way, each pin it’s a diffetent color, and the largest pin its Ground.
So, you will have something like this:
a new python file with: nano exe.py and paste the next code:
import time, sys, signal, atexit
import mraa #Lib for UV Sensor import pyupm_guvas12d as upmUV #Lib for Temp Sensor import pyupm_grove as upmTemp #Statys Led Variables RedLed = mraa.Gpio(3) GreenLed = mraa.Gpio(4) #Init sensors myUVSensor = upmUV.GUVAS12D(0); temp = upmTemp.GroveTemp(1) #Operating voltage for UV sensor GUVAS12D_AREF = 5.0; SAMPLES_PER_QUERY = 1024;
#Set to OUTPUT Led Pins RedLed.dir(mraa.DIR_OUT) GreenLed.dir(mraa.DIR_OUT) #Handler for error exit def SIGINTHandler(signum, frame): raise SystemExit
#Handler for ctrl+c def exitHandler(): RedLed.write(0) GreenLed.write(0) print "Exiting" sys.exit(0)
#Init our Handlers atexit.register(exitHandler) signal.signal(signal.SIGINT, SIGINTHandler)
#Read of temp sensor
celsius = temp.value()
#Read of UV sensor
s = myUVSensor.value(GUVAS12D_AREF, SAMPLES_PER_QUERY)
#Turn on GreenLED if UV is OK
#Turn on RedLed if UV its not OK
#You can set your owns
Run your exe.py file with: python exe.py
Step 6: Results
Now you have a little sun station that it will indicate with a red led if the sun its getting rude, or green led if the sun its happy!
We take information about UV recommendations from the National Weather Services from the US: http://www2.epa.gov/sunsafety/uv-index-0
Try it and tell me your results.
BTW… INTEL ROCKS!
We have a be nice policy.
Please be positive and constructive.