I have been dabbling with the Galileo for a while now, trying to come up with ways of using it, and thought that it might be useful for others if I shared what I have put together in one place and, hopefully, get some feedback on how to improve on what I have done.
I decided to use the Wiring-x86 as the other options don't really fit my needs as well.
Wiring_x86 from Emutex Ltd works on the Edison, Galileo Gen 1 and Galileo Gen2 boards, but only with the standard Intel and AlexT's uClibc versions of Yocto for the Galileo, as hasn't been ported to the XDK IoT version (see https://communities.intel.com/message/241845#241845 for a discussion of different versions). It includes examples for analog and digital reading and writing and Jack Pien created an example using PWM to control servos. Also, thanks to help of AlexT. Sergey's blog and Alexander Merz I have been able to use Raspberry Pi libraries to control I2C and SMBbus LCDs, and have been able to port a Raspberry Pi Grove LCD library from Dexter Industries.
Setting up to use Python on Galileo
1. Install Emutex library (https://github.com/emutex/wiring-x86)
Download, uncompress and copy to the Galileo. I suggest creating a “wiring” directory on /media/realroot so as to not use up the limited space on the virtual Busybox partition.
Look at examples to see how to use the library to control the GPIO pins. For Galileo Gen 1 boards you need to change the references from GPIOEdison to GPIOGalileo.
2.Install smbus and i2cTools
You need to make sure you have python-dev installed prior to doing the following
opkg install python-dev
The following is from Alexander Merz's message at https://communities.intel.com/thread/52982
Download i2c-tools-3.1.1.tar.bz2, from http://www.lm-sensors.org/wiki/I2CTools
Uncompress the file and rename the uncompressed directory to i2ctools
Copy contents to /media/realroot/i2ctools
Edit smbusmodule.c in py-smbus directory. Around line161, change the constant I2C_SLAVE to I2C_SLAVE_FORCE
Go back to the i2cTools directory
run# make EXTRA="py-smbus"
This will create the i2c-tools, then install them:
then run# make install
This will install tools i2cdetect and i2c
Go back to the py-symbus directory
run# python setup.py install
You should now have SMBus installed and can call it from Python programs
To use a I2C backpack adapter for a 16x2 or 20x4 LCD, you need to activate the i2c bus and install i2c LCD library
Sergey's blog http://www.malinov.com/Home/sergey-s-blog shows how to set the MUX for the GPIO . You can use echo commands to export GPIO29, set the direction to “out” and set the value to 0 or run the following Python program.
with open("/sys/class/gpio/export","w") as fh:
with open("/sys/class/gpio/gpio29/direction","w") as fh:
with open("/sys/class/gpio/gpio29/value","w") as fh:
You can now run i2cdetect -r -y 0 to see the i2c devices. If you leave off the -y you will get a warning message about accessing an SMBbus and running i2cdetect may cause problems, so you may have to reboot.
3. Set up Raspberry Pi library to access i2c LCD
Go to http://www.recantha.co.uk/blog/?p=4849
Copy and create
The Raspberry Pi uses I2C bus 1, so you need to change the reference to 0.
In the file i2c_lib.py
change the line: def __init__(self, addr, port=1):
4. Set up Raspberry Pi Library to access the Grove RGB LCD
My university also received some Galileo Grove kits, so I am seeing if I can use the sensors and LCD screen. The sensors are standard analog and digital sensors, so don't really need anything special that isn't already in the Wiring library. The LCD screen is, however, a bit different. It uses SMBBus commands, not I2C, so needs a different library than the I2C backpack LCD described earlier.
I found a few libraries for the Grove LCD, but the best seems to be the one made by Dexter Industries for the Raspberry Pi
See more at the the GrovePi Site (http://dexterindustries.com/GrovePi/)
Attached is my hack of the Dexter Industries' library and a sample program.
You need to run the python program mentioned above to access the I2C bus for the library to work
Hope this is helpful to someone
Attached is the Wiring directory from my Galileo that includes the examples from Emutex Ltd modified to run on a Galileo 1 (I haven't tested them all, but unless I made a typo changing Edison to Galileo, they should work. There are also the libraries for I2C, the backpack LCD (lcddriver.py) and for the Grove LCD, plus a few others example programs using a DFRobot motor shield, PIR sensor, servos, the I2C LCD and Grove RGB LCD, that I have been dabbling with.
Message was edited by: Richard Bradley Forgot to mention that python-dev has to be installed, corrected
wiring.zip 20.7 K