WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Python libraries from ABElectronics  (Read 2204 times)

Offline cnpdk

  • Newbie
  • *
  • Posts: 4
Python libraries from ABElectronics
« on: December 13, 2015, 05:14:14 PM »
I am quite new to TCL on RP2 so that probably explains why I can't seem to get my head around doing this but I wouldn't be surprised if the solution is quite simple.

I've bought a IO Pi Plus 32 card and fitted it onto the RPI2. Now I only need to add the Python library from ABElectronics to start playing with the many IOs.

The instruction on ABElectronics' website https://www.abelectronics.co.uk/products/17/Raspberry-Pi--Raspberry-Pi-2-Model-B/54/IO-Pi-Plus goes:

To download the Python 2 libraries to your Raspberry Pi type in terminal:
git clone https://github.com/abelectronicsuk/ABElectronics_Python_Libraries.git

Having worked a bit with tce I didn't really expect this instruction to work.

The question is what do to instead:
- What logical steps?
- If possible some detailed instruction?

Best regards
Claus

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Python libraries from ABElectronics
« Reply #1 on: December 13, 2015, 05:23:23 PM »
hi Claus,

Once you load git (something like tce-load -iw git.tcz), that instruction should work but... I think that will just be the beginning of you problems.

I'd master it on Raspbian first, then move over to piCore.

regards
Greg

Offline cnpdk

  • Newbie
  • *
  • Posts: 4
Re: Python libraries from ABElectronics
« Reply #2 on: December 22, 2015, 06:42:46 PM »
Thanks for your good advice Greg

Making this work on Raspbian is quite easy so I tried to find a similar route to make it work on TCL and here is what I came up with.


ABElectronics guide to Raspbian includes the following steps:

1. Enable I2C

2. Install python-smbus with 'sudo apt-get install python-smbus'

3. Install python3-smbus (I also tested it without this and it still works)

4. Install python-dev with 'sudo apt-get install python-dev'

5. Install python3-dev (I also tested it without this and it still works)

6. Install i2c-tools with 'sudo apt-get install i2c-tools'

7. Disable the lines 'blacklist spi-bcm2708' and 'blacklist i2c-bcm2708' in the raspi-blacklist.conf file (This was already done in the '2015-11-21-raspbian-jessie-lite' image I used or perhaps it was the work of raspi-config)

8. Add 'dtparam=i2c1=on' and 'dtparam=i2c_arm=on' in the config.txt file (I uncommented the lines already present)

9. Add 'i2c-dev' to /etc/modules (This was already done by the raspi-config)

10. Add the ‘pi’ user to the I2C group (This was already done by the raspi-config)

11. Download the pythin library from ABElectronics with 'git clone https://github.com/abelectronicsuk/ABElectronics_Python_Libraries.git' (I installed git 'Sudo apt-get install git-core' and downloaded the library)

12. Add the AB Electronics python library to the PYTHONPATH with 'export PYTHONPATH=${PYTHONPATH}:~/Desktop/ABElectronics_Python_Libraries/IOPi/'



So I did the following on TCL:

1. Having checked the TCL I came to the conclusion that I2C was already enabled in the 'piCore-6.1_v7-SSH' image I used

2. I did 'tce-load -wi py-smbus' as I could not find python-smbus for TCL

3. Here I relied on 2. as I could not find a python3 version of python-smbus and it worked fine in Raspbian without it

4. I did 'tce-load -wi python-dev'

5. Here I relied on 4. as I could not find a python3 version of python-dev and it worked fine in Raspbian without it

6. tce-load -wi i2c-tools

7. Here I did nothing as I could not find these lines disabled anywhere in TCL

8. Here I did nothing as these were already present in the config.txt file

9. Here I did nothing as i2c-dev was already present in 'bootlocal.sh'

10. Here I did nothing as I have no 'pi' user nor a 'I2C' group (This is probably the reason that I need to use 'sudo' when I execute python code involving the I2C-port)
 
11. I installed git as you suggested 'tce-load -wi git' and downloaded the python libraries from AB Electronics 'git clone https://github.com/abelectronicsuk/ABElectronics_Python_Libraries.git'

12. I added the pythin libraries with a command adjusted to fit the file structure on my TCL 'export PYTHONPATH=${PYTHONPATH}:~/ABElectronics_Python_Libraries/IOPi/'


I hope others can use this

Best regards
Claus

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Python libraries from ABElectronics
« Reply #3 on: December 22, 2015, 08:11:27 PM »
Hey Claus, looks like it was easier to install on piCore.  :D