Scroll Phat, smbus and UbuntuMate


#1

Hi folks,
I have set up a RPi3 with Ubuntu Mate 2 weeks ago and I am very pleased with the OS and its polished development so far. However I recently bought a Scroll Phat and would like to use it for live updates from my WWWServer+Weather station. I have had trouble trying to get it to install and run with Python3 in this environment.

Here is the crash report the “test-all.py” program produces when run

Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type “copyright”, “credits” or “license()” for more information.

====== RESTART: /home/rob/RPi3/scroll-phat-master/examples/test-all.py ======
Traceback (most recent call last):
File “/home/rob/RPi3/scroll-phat-master/examples/test-all.py”, line 7, in
import scrollphat
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 664, in _load_unlocked
File “”, line 634, in _load_backward_compatible
File “/usr/local/lib/python3.5/dist-packages/scrollphat-0.0.6-py3.5.egg/scrollphat/init.py”, line 16, in
controller = IS31FL3730(smbus, font)
File “/usr/local/lib/python3.5/dist-packages/scrollphat-0.0.6-py3.5.egg/scrollphat/IS31FL3730.py”, line 17, in init
self.bus = self.bus.SMBus(1)
FileNotFoundError: [Errno 2] No such file or directory

I have attempted to build and install the smBus for python3 and also enable the i2c on start up. However to no avail.
Am I likely to get help here or would it be best pursued in the Ubuntu-Mate forums?
I have been playing with RPi for a year or two but thsi is my first serious hardware experiment, so I apologise in advance if this request is unreasonable or unclear. Most of the advice I have so far read is for “raspbian”, so sorry to eb contrary and use U-Mate.

Cheers, Rob


#2

Can I suggest you stick to python 2 in the first instance? The reason for this is that you can install python-smbus for Python 2 directly from the Ubuntu repo, saving you to build smbus from source, which may or may not be where things went south for you.

Besides that you’ll also need to enable i2c by making sure your /boot/config.txt file includes:

dtparam=i2c_arm=on

then after rebooting:

sudo modprobe i2c-dev

It should work from there onwards and you should be able to probe the i2c bus to confirm the Scroll pHAT can be seen with:

i2cdetect -y 1

If that works, then you can add the i2c-dev module to /etc/modules-load.d/modules.conf to force-load it when the Pi boots up.

Good luck!


#3

Hi RogueM,

I will probably appear stubborn, but I have written all my weather station server, data collection, processing and graphing in python3 so I am very keen to get it to work in that version. I intend to add my version of Scroll PHat driver into this program, so python3 compatibility is very important.

I am pleased that it now seems to be working, as I can run any of the supplied examples under python3 and they are all good (very good in fact!). It seems I have been able to recompile the critical module after following the instructions on Dipto Pratyaksa post.
In essence this is what I found useful:

> Older versions:
> Here are the steps to install it:

> sudo -i
> apt-get install python3-dev
> apt-get install libi2c-dev
> cd /tmp
> wget http://ftp.de.debian.org/debian/pool/main/i/i2c-tools/i2c-tools_3.1.0.orig.tar.bz2 # download Python 2 source
> tar xavf i2c-tools_3.1.0.orig.tar.bz2
> cd i2c-tools-3.1.0/py-smbus
> mv smbusmodule.c smbusmodule.c.orig # backup
> wget https://gist.githubusercontent.com/sebastianludwig/c648a9e06c0dc2264fbd/raw/2b74f9e72bbdffe298ce02214be8ea1c20aa290f/smbusmodule.c # download patched (Python 3) source
> python3 setup.py build
> python3 setup.py install
> exit

This was done last night, but did not seem to work at the time. Hence I contacted you guys. However after applying your commands this morning I have found that without any further commands the PHat is OK.

> rob@U-Mate:~$ sudo modprobe --first-time i2c-dev
> [sudo] password for rob: 
> modprobe: ERROR: could not insert 'i2c_dev': Module already in kernel
> rob@U-Mate:~$ i2cdetect -y 1
>      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
> 00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
> 70: -- -- -- -- -- -- -- --                         
> rob@U-Mate:~$ 

I have already added the reference to the i2c module in boot up so that did not worry me so much, however the i2cdetect -y 1 command put a smile on my face, it worked!

This program…

 print ("start----------------")
 import RPi.GPIO as GPIO
 import sys
 import smbus

 rev = GPIO.RPI_REVISION
 print ("GPIO.RPI_REVISION=", rev)
 bus = smbus.SMBus(1)
 print ("Success")
 print ("end ----------------")

Produced this…

Results:
Python 3.5.2 (default, Jul  5 2016, 12:43:10) 
[GCC 5.4.0 20160609] on linux
Type "copyright", "credits" or "license()" for more information.
>>> 
================== RESTART: /home/rob/RPi3/tester_SMBus.py ==================
start----------------
GPIO.RPI_REVISION= 3
Success
end ----------------
>>>

My last request today is at the end of your post you mention “If that works, then you can add the i2c-dev module to /etc/modules-load.d/modules.conf to force-load it when the Pi boots up.” I am not sure that I have done this, would you mind spelling out the syntax of the command for me? I am not clear even to what the module name might be.

Thank you for your prompt answer, it seems to have some sort of kama effect and made a lot of what I had previously tried work. I am very appreciative of your comments and assistance. I hope you can check the above out and maybe use the information I have supplied above in return.

Cheers, Rob


#4

You need to open /etc/modules-load.d/modules.conf and add ‘i2c-dev’ on one line, if not already there.


#5

Hi RogueM,
Thank you for your assistance. It is now working as expected and can be auto run on boot under a cron job and the modules and drivers all kick in. I am very pleased!
I have checked the file contents at /etc/modules-load.d/modules.conf and found i2c-dev is present, and it is also present at etc/modules.
Is the latter inclusion required, or does the OS mirror that from the previous modules.conf file? Should I delete the i2c-dev from /etc/modules ? Is it unnecessary in that location?
I now have a real time “front panel” indicator on the state of my web server and weather station, thanks again!!
Rob


#6

I don’t think it is necessary in /etc/modules as MATE uses systemd, but it won’t hurt there. I strongly suspect there is a syncing mechanism under the hood too so it might well be that if you delete it will come back anyhow.

Either way, it really does not matter, if i2c works then leave the configs as they are now.


#7

I’ve just checked on my test system, and yes, those files are kept in sync*, so if you remove entries from one, you will in effect be back to square one.

Whether that will be true in future Ubuntu LTS I don’t know but until then don’t try to clean up either of those files, unless you intend to disable modules.

Incidentally, we’ll be gradually opening up some of our installers specifically in view of MATE support. Nothing is currently live but some will likely be in the next few weeks as the ground work has been done.

What does work already though, or should is our i2c enabling script:

curl -sS https://get.pimoroni.com/i2c | sudo bash

… so if you set up another Pi with MATE at some point it’s worth trying the above, or the Scroll pHAT script for that matter, it may save you the hassle to get it to work again from scratch.

EDIT*: actually it is merely a symbolic link from /etc/modules to /etc/modules-load/modules.conf


#8

Hi RogueM,
Hehe that explains why it had a ‘perfect’ copy of the comments I had made as well. I had tried a lot of things but could not remember cutting and pasting that one.
The installers for U-Mate sound a very good investment as I am really pleased with the polish and ‘completeness’ of the U-Mate distro. From the range of OS tools to the GUI options, it is a lot better organised than Raspbian (imho) and I think it will be rapidly accepted as a very good ‘alternative standard’ interface to begin with.
To give Raspbian due credit it was THE pioneer and best supported with experimenters’ installations like Scroll PHat, but still seem to have kept that thrown together feel.
Finally let me thank you and company for well designed and supported products, I am happy to suggest this problem “solved”.
Cheers, Rob .


#9

I recently had to overcome the "restricted boot partition size " problem (ie no serious updates possible) when updating Ubuntu Mate on the Raspberry Pi3 and after shrinking the main ROOT partition to create room for a new bigger partition for BOOT. After finally catching up on all my long overdue updates, my pHat drivers were broken and would not work. Repeating what I had hacked together last time was very daunting, so I simply ran your latest supplied script and it worked first go, fixing stuff as it went. Very impressive. Great support guys 👍😉