Internet of Things with Intel Edison Led sensor lab Pierre Collet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com Intel Software 2014-10-14 Libmraa Libmraa Libmraa Mraa is a library which is going to help us to communicate with the pins on the board. How to install Today we are using a package for Yocto, the linux proposed by default on Edison. ~# echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf ~# opkg update ~# opkg install libmraa0 How to compile with mraa When you compile just link with the –lmraa flag LedSensor lab with Libmraa Hardware For this example, you need : A LED, a resistor, a sensor and four cables. Plug the LED Plug in a serial way one cable to the resistor, to the LED, to the other cable. Let’s plug the cables on the Digital pin 8 and the other on the ground (GND) Plug the sensor Plug the sensor between the analog input 0 (A0) and the 5V pin. Libmraa Ledsensor with mraa Libmraa Sources and Binaries Go to the directory named : mraaLedSensor. In this directory, there is three examples of controlling the board with mraa. blinkled: It makes the the LED blink getanalog: It displays the value receive on the analog input 0 Ledsensor: It light up the LED if the value received on A0 is above a given threshold The value of the threshold and the pin number are define thank to some #define at the top of each file. You can change those numbers as you wish. In order to compile all these examples, just enter “make” when you are in the directory which contains the .c files. Conclusion Low level direct access You can access GPIO directly from the command line. Libmraa But it’s a LOT easier to use a library like mraa. With mraa, GPIO is simple. And with mraa sample binaries, you can create scripts in various languages to access GPIO data. License Creative Commons – By 3.0 You are free: • to Share — to copy, distribute and transmit the work • to Remix — to adapt the work • to make commercial use of the work Under the following conditions: • Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). With the understanding that: • Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. • Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. • Other Rights — In no way are any of the following rights affected by the license: – – – • Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights; Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page. http://creativecommons.org/licenses/by/3.0/