Code Monkey home page Code Monkey logo

enviro-phat's Introduction

Enviro pHAT

https://shop.pimoroni.com/products/enviro-phat

The Pimoroni Enviro pHAT boast a plethora of sensors and connectivity for measuring your environment.

Enviro pHAT includes:

  • An LSM303D accelerometer/magnetometer for detecting orientation, motion and heading
  • A BMP280 temperature/pressure sensor
  • A TCS3472 colour sensor, for detecting the amount and colour of light
  • An ADS1015 analog sensor with four 3.3v tolerant channels for your external sensors
  • A 5v power supply pin for powering your sensors, which you can regulate or divide to 3v if needed
  • Two LEDs connected to GPIO #4 for illuminating objects over the colour sensor

Note: for Enviro and Enviro Plus see: https://github.com/pimoroni/enviroplus-python/

Installing

Full install (recommended):

We've created an easy installation script that will install all pre-requisites and get your Enviro pHAT up and running with minimal efforts. To run it, fire up Terminal which you'll find in Menu -> Accessories -> Terminal on your Raspberry Pi desktop, as illustrated below:

Finding the terminal

In the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:

curl https://get.pimoroni.com/envirophat | bash

Alternatively, on Raspbian, you can download the pimoroni-dashboard and install your product by browsing to the relevant entry:

sudo apt-get install pimoroni

(you will find the Dashboard under 'Accessories' too, in the Pi menu - or just run pimoroni-dashboard at the command line)

If you choose to download examples you'll find them in /home/pi/Pimoroni/envirophat/.

Manual install:

Library install for Python 3:

on Raspbian:

sudo apt-get install python3-envirophat

other environments:

sudo pip3 install envirophat

Library install for Python 2:

on Raspbian:

sudo apt-get install python-envirophat

other environments:

sudo pip2 install envirophat

Development:

If you want to contribute, or like living on the edge of your seat by having the latest code, you should clone this repository, cd to the library directory, and run:

sudo python3 setup.py install

(or sudo python setup.py install whichever your primary Python environment may be)

In all cases you will have to enable the i2c bus.

Documentation & Support

enviro-phat's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enviro-phat's Issues

Importing from envirophat fails with a TypeError

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!

Loading script on boot: [Errno 25] Inappropriate ioctl for device

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.

OLD vs NEW enviro pHAT

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)

Installation command rejected?

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?

Importing from envirophat fails on zero

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()

Migrate Enviro pHAT library to new breakout packages

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.

Enviro phat not conecting.

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?

light sensor: division by zero

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 :) ).

QNH defined

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.

'Sudo python' for use

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).

OSError: [Errno 121] Remote I/O error 3

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

Remote I/O Error

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?

Error when passing unit kwarg into pressure(self, unit=None)

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.