Coder Social home page Coder Social logo

airpi's Introduction

AirPi

A Raspberry Pi weather station and air quality monitor.

This is the code for the project located at http://airpi.es

Currently it is split into airpi.py, as well as multiple input and multiple output plugins. airpi.py collects data from each of the input plugins specified in sensors.cfg, and then passes the data provided by them to each output defined in outputs.cfg. The code for each sensor plugin is contained in the 'sensors' folder and the code for each output plugin in the 'outputs' folder.

Some of the files are based off code for the Raspberry Pi written by Adafruit: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code

For installation instructions, see http://airpi.es/kit.php

Installation

Prerequisites

You will need to install the following dependencies:

sudo apt-get install git-core python-dev python-pip python-smbus libxml2-dev libxslt1-dev python-lxml i2c-tools

and

sudo pip install rpi.gpio requests

AirPi requires python-eeml. To install:

cd ~/git
git clone https://github.com/petervizi/python-eeml.git
cd python-eeml
sudo python setup.py install

i2c

To set up i2c, first add your user to the i2c group. For example, if your username is "pi":

sudo adduser pi i2c

Now, add the modules needed.

sudo nano /etc/modules

Add the following two lines to the end of the file:

i2c-bcm2708
i2c-dev

Exit by pressing CTRL+X, followed by y to confirm you want to save, and โŽ (enter) to confirm the filename.

Finally, unblacklist i2c by running the following command:

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Add a # character at the beginning of the line blacklist i2c-bcm2708. Then exit in the same way as last time.

Now, reboot your Raspberry Pi:

sudo reboot

Board Version

Let's check to see which board version you have. Run:

sudo i2cdetect -y 0

You should see this as the output:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77

If not, run:

sudo i2cdetect -y 1

and you should see the above. This tells you if your board is version 0 or 1. This is important for the next step.

Get The AirPi Code

Clone this repo into your git directory (or wherever you want):

cd ~/git
git clone https://github.com/tomhartley/AirPi.git
cd AirPi

Configuring

Edit the settings file by running:

nano sensors.cfg

The start of the file should look like this:

[BMP085-temp]
filename=bmp085
enabled=on
measurement=temp
i2cbus = 1

[BMP085-pres]
filename=bmp085
enabled=on
measurement=pres
mslp=on
i2cbus = 1
altitude=40

If your board version is "0" change both instances of i2cbus = 1 to i2cbus = 1

Press CTRL+X to exit the file, when prompted, press "y" to save the file.

If you want to push the data to Xively, edit the outputs.cfg file:

nano outputs.cfg

The start of the file should look like this:

[Print]
filename=print
enabled=on

[Xively]
filename=xively
enabled=on
APIKey=xxxxxxxxxx
FeedID=xxxxxxxxxx

If you have registered with https://xively.com - you can add your API Key and Feed ID here.

Running

AirPi must be run as root.

sudo python airpi.py

If everything is working, you should see output similar to this:

Success: Loaded sensor plugin BMP085-temp
Success: Loaded sensor plugin BMP085-pres
Success: Loaded sensor plugin MCP3008
Success: Loaded sensor plugin DHT22
Success: Loaded sensor plugin LDR
Success: Loaded sensor plugin MiCS-2710
Success: Loaded sensor plugin MiCS-5525
Success: Loaded sensor plugin Mic
Success: Loaded output plugin Print
Success: Loaded output plugin Xively

Time: 2014-06-04 09:10:18.942625
Temperature: 30.2 C
Pressure: 992.55 hPa
Relative_Humidity: 35.9000015259 %
Light_Level: 3149.10025707 Ohms
Nitrogen_Dioxide: 9085.82089552 Ohms
Carbon_Monoxide: 389473.684211 Ohms
Volume: 338.709677419 mV
Uploaded successfully

airpi's People

Contributors

edent avatar mattcanty avatar nocturnal42 avatar rjlanc avatar

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

airpi's Issues

BMP085 not calculating

Dear all, first of thank you so much for this project, i just got and built mine and im loving it!!
I have an issue though i hope someone here can helpo me fix.

The Pressure and Temperature readings are not being calculated, they stay stuck to some value since the first time i got it running.
I triple checked the soldering and its all fine.
I also get around 15-20 lines of : Error Accessing 0x77: Check your I2C address, every time after uploading succesfully, but that is set just fine in the cfg, as its working for the other sensors, and the i2cdetect confirms i got a Rev2 board.
The bmp085Backend.py does have a line reading i2c = none near the beginning, but im assuming thats some sort of initialization right ? (sorry im not that good with Python yet. .)

You can check the live feed here, and you will notice pressure and temperature are not working> https://xively.com/feeds/1547432953

Im about to order a new BMP085 as i have to assume this one is busted, but if anyone had encountered this error, or knows what might be causing this please let me know, i would really like to finish this asap so i can move to the projects other parts ..

Thank you in advance,

Luka

No PCBs or Kits to order

Dear all, unfortunately i have been waiting for too long on a Tindie order for the Board, so i was wondering if you would be kind enough to share the Eagle file of the latest board (0.4+) so i can have some printed myself on Seeedstudio.
The version you have shared now is an old one, and as i already have a case for it, i would really appreciate having the latest design.

Thank you in advance,

Luka

Add moving averages for certain readings

Ideally, should have configurable duration for the window, as well as ability to control which sensors you want it for. Most probably the Air Quality ones, but maybe also the UV sensor and others. Potentially upload the raw values to Cosm as well.

Break out all settings to config file

Things which should probably be in the config file:

  • LCD on/off
  • ADC pins for analogue sensors
  • DHT22 pin
  • I2C bus number
  • enabled/disabled state of all sensors
  • ADC connections from Pi GPIO
  • API key for Cosm
  • Feed ID for Cosm
  • Watchdog enabled/disabled
  • Restarting Internet enabled/disabled
  • Pull up resistor sizes for MiCS sensors
  • Base resistance for MiCS sensors

Not sure what format it should be in yet.

Add LICENSE

I find this project very useful and I am developing this further however I need the LICENSE so I can give credit.
Thanks!

Custom Sensor

I am not sure if you still are using the AirPi?!

I try to add a new sensor based on your template (SHT31 temperature and humidity sensor) with no luck so far.

Could you please give some advice?

`#!/usr/bin/python

import sensor
import time
import smbus

class SHT31(sensor.Sensor):
requiredData = []
optionalData = []

def __init__(self,data):
    """
    Initialisation.
    Any initialisation code goes here.
    """
    self.readingtype = "temperature"
    self.sensorname = "SHT31"
    self.valname = "Temperature"
    self.valunit = "Degrees Celsius"
    self.valsymbol = "C"
    self.description = "SHT31 Sensor for Temperature and Humidity."
    return

def getval(self):
    try:
        bus = smbus.SMBus(1)
        bus.write_i2c_block_data(0x44, 0x2C, [0x06])
        time.sleep(0.5)
        data = bus.read_i2c_block_data(0x44, 0x00, 6)
        ctemp = data[0] * 256 + data[1]
        temp = -45 + (175 * ctemp / 65535.0)
    except TypeError as terr:
        pass
    return temp`

Forking this to input data into MySQL?

I'm trying to figure out a way to use this code without uploading it to the internet, probably by way of a MySQL database controlled by Python. Does anyone know the best way to do this?

Error on raspbian buster

Hello,

i made a fresh install with RaspberryPi B+ and my AirPi PCB 1.4 and get the following error. On Debian Jessie it runs great.
All configs checkt, no sensor problem

DEBUG:main: ERROR: Failed to obtain data from these sensors: DHT22-hum, DHT22-temp
ERROR: Failed to obtain data from these sensors: DHT22-hum, DHT22-temp
DEBUG:main: Dataset to output to <outputs.print.Print object at 0xb62eeaf0>:
DEBUG:main: [{'description': 'A combined temperature and humidity sensor.', 'symbol': '%', 'value': None, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-hum', 'unit': '% Relative Humidity', 'name': 'Relative_Humidity'}, {'description': 'A combined temperature and humidity sensor.', 'symbol': 'C', 'value': None, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-temp', 'unit': 'Celsius', 'name': 'Temperature-DHT'}]
Time : 2021-02-06 14:10:00
DEBUG:main: ERROR: Exception during output: Unknown format code 'f' for object of type 'str'
DEBUG:main: ERROR: Failed to obtain data from these sensors: DHT22-hum, DHT22-temp
ERROR: Failed to obtain data from these sensors: DHT22-hum, DHT22-temp
DEBUG:main: Dataset to output to <outputs.print.Print object at 0xb62eeaf0>:
DEBUG:main: [{'description': 'A combined temperature and humidity sensor.', 'symbol': '%', 'value': None, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-hum', 'unit': '% Relative Humidity', 'name': 'Relative_Humidity'}, {'description': 'A combined temperature and humidity sensor.', 'symbol': 'C', 'value': None, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-temp', 'unit': 'Celsius', 'name': 'Temperature-DHT'}]
Time : 2021-02-06 14:10:20
DEBUG:main: ERROR: Exception during output: Unknown format code 'f' for object of type 'str'

It is the third sensor i have tested, sumtimes its ok

Time : 2021-02-06 14:45:01
DEBUG:main: ERROR: Exception during output: Unknown format code 'f' for object of type 'str'
INFO:main: Success: Data successfully obtained from all sensors.
DEBUG:main: Dataset to output to <outputs.print.Print object at 0xb62eeaf0>:
DEBUG:main: [{'description': 'A combined temperature and humidity sensor.', 'symbol': '%', 'value': 45.400001525878906, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-hum', 'unit': '% Relative Humidity', 'name': 'Relative_Humidity'}, {'description': 'A combined temperature and humidity sensor.', 'symbol': 'C', 'value': 22.700000762939453, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-temp', 'unit': 'Celsius', 'name': 'Temperature-DHT'}]
Time : 2021-02-06 14:45:21
Relative Humidity : 45.40 % (sample)
Temperature-DHT : 22.70 C (sample)

INFO:main: Success: Data output in all requested formats.
INFO:main: Success: Data successfully obtained from all sensors.
DEBUG:main: Dataset to output to <outputs.print.Print object at 0xb62eeaf0>:
DEBUG:main: [{'description': 'A combined temperature and humidity sensor.', 'symbol': '%', 'value': 45.400001525878906, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-hum', 'unit': '% Relative Humidity', 'name': 'Relative_Humidity'}, {'description': 'A combined temperature and humidity sensor.', 'symbol': 'C', 'value': 22.700000762939453, 'breach': False, 'readingtype': 'sample', 'sensor': 'DHT22-temp', 'unit': 'Celsius', 'name': 'Temperature-DHT'}]
Time : 2021-02-06 14:45:41

Greetings from Bavaria

Update for Tindie kits (board version 1.2)

Hi,
I've just assembled my board I got from the indie campaign and I've noticed that the software is still reporting UV sensor and has no value for microphone. Also, the CO reading seems to be stuck on 40ppm - is this a also a software issue or is something wrong with the sensor?

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.