pimoroni / enviro-phat Goto Github PK
View Code? Open in Web Editor NEWPython libraries and examples for the Pimoroni Enviro pHAT
Home Page: https://shop.pimoroni.com/products/enviro-phat
License: MIT License
Python libraries and examples for the Pimoroni Enviro pHAT
Home Page: https://shop.pimoroni.com/products/enviro-phat
License: MIT License
The README.md say: "An ADS1015 analog sensor with four 3.3v tolerant channels for your external sensors"
Pinout.xyz say: "ADS1015 4-channel 5v tolerant 12-bit ADC (0x49 on the i2c bus)
(3.3v 12-bit ADC at address 0x48 in first production run of the board)"
Maybe more information about this would be needed.
(I don't own a enviro-phat, I was just looking for ADS1015 source code)
This is the error I'm getting it is a brand new install on a raspberry zero.
Thanks
Scott
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
from envirophat import weather
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/envirophat/init.py", line 12, in
light = tcs3472(bus)
File "/usr/lib/python3/dist-packages/envirophat/tcs3472.py", line 37, in init
self.i2c_bus.write_byte_data(ADDR, REG_ENABLE, REG_ENABLE_RGBC | REG_ENABLE_POWER)
OSError: [Errno 5] Input/output error
from envirophat import light
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/envirophat/init.py", line 12, in
light = tcs3472(bus)
File "/usr/lib/python3/dist-packages/envirophat/tcs3472.py", line 37, in init
self.i2c_bus.write_byte_data(ADDR, REG_ENABLE, REG_ENABLE_RGBC | REG_ENABLE_POWER)
OSError: [Errno 5] Input/output error
exit()
Am I missing something here - I am at a loss to understand why you have defined QNH as 1020 hPa when the ISO standard atmosphere has 1013.25 hPa as the average pressure at msl at 15 degrees C.
Sure you can provide the local QNH if known, but if you use the default 1020 hPa your altitude will be off by around 61.5 m or 202 feet. Explain please.
Many issue!
The envirophat
module is missing a dependency on smbus
.
When trying to run this example on a Raspberry Pi Zero with EnviroPhat, it successfully starts, runs a couple of seconds but then dies with the following output:
Traceback (most recent call last):
File "./test.py", line 21, in <module>
analog_values = analog.read_all()
File "/usr/local/lib/python3.5/dist-packages/envirophat/ads1015.py", line 89, in read_all
return tuple([self.read(channel=x) for x in range(4)])
File "/usr/local/lib/python3.5/dist-packages/envirophat/ads1015.py", line 89, in <listcomp>
return tuple([self.read(channel=x) for x in range(4)])
File "/usr/local/lib/python3.5/dist-packages/envirophat/ads1015.py", line 71, in read
self.i2c_bus.write_i2c_block_data(self.addr, REG_CFG, [(config >> 8) & 0xFF, config & 0xFF])
OSError: [Errno 121] Remote I/O error 3: 0.582
Hi, I just took delivery of a shiny new (white!) enviro phat, and am having problems getting it to work.
I'm using a Pi Zero W:
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 9000c1
Serial : 00000000e4780010
Model : Raspberry Pi Zero W Rev 1.1
with apt-get update
and apt-get upgrade
all up to date, and I can see i2c devices attached when the phat is in place:
pi@raspberrypi:~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
Yet, when I try and follow the tutorial, or run any of the examples
, I get the same error:
pi@raspberrypi:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from envirophat import light
>>> light.light()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/envirophat/tcs3472.py", line 80, in light
return self.raw()[CH_CLEAR]
File "/usr/lib/python2.7/dist-packages/envirophat/tcs3472.py", line 88, in raw
self.setup()
File "/usr/lib/python2.7/dist-packages/envirophat/tcs3472.py", line 44, in setup
self.i2c_bus.write_byte_data(ADDR, REG_ENABLE, REG_ENABLE_RGBC | REG_ENABLE_POWER)
IOError: [Errno 121] Remote I/O error
Am I missing anything or doing anything wrong? I'd love to get started with this module!
Is this repo still viable for the newer white version of this board?
Hi,
my enviro phat is not able to be seen on my RaspberryPi. I can't do anything with it, since I don't even see it on I2C bus.
What should I do about it?
I am trying to run my custom script as background daemon which is being loaded during startup via rc.local script. During execution any access to envirophat throws:
OSError: [Errno 25] Inappropriate ioctl for device
However, same script loaded as background daemon from command line does not raise mentioned exception. I have tried to run it as root and as regular user, but there is no difference. The only workaround I found is to defer loading library to function scope.
Please refer to script file for error reproduction. I am using RPi Zero W with latest Raspbian image, no other shields are connected.
When attempting to import from envirophat I get the following (note that this worked when I last tried it, maybe 3-4 months previously):
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from envirophat import weather
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/envirophat/__init__.py", line 12, in <module>
light = tcs3472(bus)
File "/usr/lib/python3/dist-packages/envirophat/tcs3472.py", line 35, in __init__
raise TypeError("Object given for i2c_bus must implement read_word_data and write_byte_data")
TypeError: Object given for i2c_bus must implement read_word_data and write_byte_data
Some details about the system:
python3-envirophat:
Installed: 0.0.6
Candidate: 0.0.6
Version table:
*** 0.0.6 0
500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
100 /var/lib/dpkg/status
root@pi-zero-1:~# lsmod | grep i2c
i2c_bcm2708 5740 0
i2c_dev 6578 0
root@pi-zero-1:~# 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I'm not really sure what else I can do to debug this; any suggestions are welcome!
Enviro pHAT builds in old, clunky versions of the ads1015, bmpe280 and lsm303d drivers which all have new versions (for Breakout Garden):
tcs3472 should also receive this treatment and be migrated over to an i2cdevice style driver.
Migrating over to these newer packages should ensure that Enviro pHAT shares any progress, maintenance and bugfixes applied to these libraries.
This probably warrants a new major version and updated examples that use these sensor libraries directly, since it would be counter-productive to maintain Enviro pHAT's hand-holdy, isolated way of doing things versus encouraging users to write portable code.
Enviro+ should be the benchmark for a rehash of this library- ie: it should largely be a thin-as-possible wrapper that installs the above libraries as dependencies.
Thanks for the great product with nice code!
I just noticed an issue on the learning guide. Sorry if this is not the right place to report.
https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-enviro-phat
And to read the pressure in hPa (hecto Pascals), type the following:
print(weather.pressure())
The code to report in hPa should specify unit argument
print(weather.pressure(unit='hPa')
When attempting to pass the kwarg 'unit' into the pressure function:
envirophat.weather.pressure(unit='hPa')
I got the following error:
TypeError: pressure() got an unexpected keyword argument 'unit'
Is this the expected behaviour or should the function handle the unit keyword?
Why are we needing to run python as sudo for use as per the instructions.
Nothing else I use needs to run as sudo, none of the various i2c devices/sensors I have need it.
What's the issues here ?
(So I know what not to use).
I did the following command for the installation on a new Pi 3 (after a apt-get update).
curl -sS https://get.pimoroni.com/envirophat | bash
The instructions appeared, saying that it needs I2C communication, and asks if I wish to continue. I type a 'y', and the following error appears:
Checking environment...
We can't connect to the internet, check your network!
I did a few checks, my nameserver is fine, i can ping www.google.com, I can open shop.pimoroni.com on the web browser. I don't think there is any firewall on pi 3.
Am I missing something on the installation?
Is there any alternate installation methods, or can you guide the prerequisites to get it to work?
Hi,
I left the pHat on for solid 24hours and spotted that during night time (presumably light=0, probably the same with rgb values) the readings would fail because of the bit in tcs3472.py lib:
File "/usr/local/lib/python2.7/dist-packages/envirophat/tcs3472.py", line 51, in rgb
return tuple([int(x * 255) for x in self.scaled()][:3])
File "/usr/local/lib/python2.7/dist-packages/envirophat/tcs3472.py", line 48, in scaled
return tuple([float(x) / rgbc[3] for x in rgbc])
ZeroDivisionError: float division by zero
I know I could wrap my code with try-except, but probably it might be worth introducing a bit of logic in the function scaled() to e.g. simply return 0 or split by 1 if rgbc[3]==0 ? (sorry, a bit of rookie here, don't take my idea for granted :) ).
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.