boeeerb / piglow Goto Github PK
View Code? Open in Web Editor NEWControlling the PiGlow from Python
License: Other
Controlling the PiGlow from Python
License: Other
Hi, my test runs fine and I have managed to run clock.py successfully, but I get the following error message when I try to get the cpu monitoring program running instead:
pi@raspberrypi ~ $ from piglow import PiGlow
from: can't read /var/mail/piglow
I checked that psuutil was installed correctly (it was), see below:
pi@raspberrypi ~ $ sudo apt-get install python-smbus python-psutil -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-psutil is already the newest version.
python-smbus is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 177 not upgraded.
What am I missing here?
Hello,
thanks for your PiGlow Python Script :) Works like a charm.
I noticed a beep sound (like a high frequency humming) which gets stronger and louder as the brightness increases. Is it normal? Or is my PiGlow broken?
I deattached it and the sound was gone. Also, when i don't run anything so the led are off theres no noise.
BTW: Its a Raspberry Pi 2
Thanks in advance,
Manu
On my Raspbian installation on a Model B Pi, I need to tell the SN3218 to enable output before any of the
functions work. If I don't then all python code runs without errors but none of the leds
light up.
So I need to run
piglow.bus.write_i2c_block_data(0x54,0x00,[0x01])
then everything works fine. In fact, any leds that have previously been activated will then light up.
Example:
pi@raspberrypi ~/PiGlow $ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from piglow import PiGlow
piglow = PiGlow(1)
piglow.orange(50)nothing happens - the leds don't light
piglow.bus.write_i2c_block_data(0x54,0x00,[0x01])
the 3 oranges leds light up
piglow.arm1(45)
all subsequent functions work straight away
You should only need to run this line of code once after each cold start of the Pi. The
SN3218 should remain enabled until power is removed.
Also, the psutils package on raspbian (which I reckon a lot of people will be using) is
called python-psutil.
Thanks for these great scripts!
Just a heads up (which you probably already know).. this class does not work in a Pi2 due to the RPi.GPIO library not supporting the Pi2 currently. I have heard there is a Dev version of RPi.GPIO available. I have not yet tried that.
Thanks!
-Liam
I entered each command as you entered on the step by step to configure an auto start for the clock in binary on boot for the Piglow. It stops the boot at
[ ok ] Starting OpenBSD Secure Shell server: sshd.
please help me
I found that after a recent firmware update, I would get this error when attempting to use any PiGlow i2c python script:
IOError: [Errno 2] No such file or directory
I found the solution to be to add the line dtparam=i2c1=on
to my /boot/config.txt
You may want to add this to the readme.
I have now tested this repository with Stretch-lite install, I have found two issues which are easily resolvable.
First issue:
ImportError: No module named piglow
sudo apt install python-piglow python3-piglow
On it's own this will not resolve the problem and leads us to the second issue which is that, you also need edit each of the python files and replace two of the entries listed, the majority of the code is still valid so in the case of arm.py for example simply replace.
Second issue:
Code itself example from arm.py.
from piglow import PiGlow
from time import sleep
piglow = PiGlow()
replace with:
import piglow
from time import sleep
piglow.auto_update = True
This should work whether the base OS is Stretch-lite or Stretch-desktop, however for clarity I will provide for those who are interested an Install procedure for Stretch-lite which should work equally well for Desktop version. I wish to acknowledge the author of code in Pimoroni github site as I am not smart enough to resolve the issue detected without looking at their code. However the base install script supplied by Pimoroni as of the date of this article out of date and has not been updated from jessie OS so script might not work on Stretch OS
ref: https://github.com/pimoroni/piglow
sudo apt install python-pip python3-pip
sudo apt install python-smbus python3-smbus
sudo apt install python-psutil python3-psutil
sudo apt install python-piglow python3-piglow
sudo apt install python-numpy python3-numpy
sudo raspi-config
select option 5 = Interfacing Options
select option p5 = I2C please enable if not already done so
Then modify all of boeeerb's fine code to include the top and bottom changes to the code itemised above. These are literally the only changes I made to run this fine selection of programs. Perhaps Boeeerb will update their post at post at some point. I hope this article will help someone else discover to discover the joys of piglow.
I can confirm the above works on Raspberry Pi version B (very old but still works)
Remember to use python piglowappname.py or
python3 piglowappname.py
The file arm.py is not included in the inventory for this project.
HI there
I am getting an _init_ error when trying to run your python scripts on a Model B+ Pi.
sudo python cpu.pyUnable to determine Raspberry Pi revision.
Traceback (most recent call last):
File "cpu.py", line 13, in
piglow = PiGlow()
File "/home/pi/piglow/piglow.py", line 30, in init
self.bus = SMBus(i2c_bus)
UnboundLocalError: local variable 'i2c_bus' referenced before assignment
Can this be added to the *.py files?
Sal
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.