I've been creating a significantly updated version of the AirPi software, the results of which are stored over at Github: github.com/haydnw/AirPi I just thought I'd mention it on here in case anyone finds it useful.
The main features I've added are:
Control script to run sampling in different modes (e.g. SSH into the Pi, start sampling, then close the SSH session but the sampling continues).
Ability to output averaged data (e.g. read every 1 min for 10 mins, then just output the average for the 10 mins).
Ability to record metadata such as Raspberry Pi serial no. and operator name at start of run.
Ability to start sampling automatically at boot for headless operation (does not require any user interaction).
'Notifications' module which allow messages to be sent when errors occur. Includes email, SMS and tweet.
ThingSpeak integration added to 'outputs' module.
There are a few other changes too, all of which are detailed in the README file on Github. It's stable on v1.2 boards, but the next phase is a comprehensive testing program - if anyone spots any bugs then please feel free to open an 'issue' on Github so I can take a look! I"m sure I must have missed something somewhere. I'll also be making some documentation shortly too, and probably some general tidying of the code. There is also a branch which involves a move to Python3, but this isn't up-to-date and is missing some features, so expect that to change significantly in the medium term (once docs and testing for the Python2 version is complete).
Just built my first very basic AirPi with your version of the software.
From the looks of it, your additions make it into an almost-finalised product. It's a pity that the original developer has other things on his hands, maybe he should consider merging your branch into master?
There is one glitch I'm experiencing, however: whenever I enable the builtin http output, starting AirPi fails with the following:
<code> AirPi] Starting normal AirPi sampling. [AirPi] This run will end if you log out. [AirPi] Press Ctrl + C to stop. ========================================================== Loading SENSORS... Success: Loaded sensor plugin BMP085-temp Success: Loaded sensor plugin BMP085-pres Success: Loaded support plugin MCP3008 Success: Loaded sensor plugin LDR ========================================================== Loading OUTPUTS... Success: Loaded support plugin Calibration Success: Loaded output plugin Print Success: Loaded output plugin CSVOutput Success: Loaded output plugin HTTP ========================================================== Loading NOTIFICATIONS... Info: No Notifications enabled. ========================================================== Loading SETTINGS... Success: Loaded settings. ========================================================== Loading METADATA... Run started............18:25 on Monday 08 September 2014 Operator...............Dr. O. Perator Raspberry Pi name......raspi Raspberry Pi ID........0000000070c97085 Sample frequency.......Sampling every 10 seconds.
Traceback (most recent call last): File "/home/pi/AirPi/airpi.py", line 714, in <module> output_metadata(pluginsoutputs, METADATA) File "/home/pi/AirPi/airpi.py", line 688, in output_metadata plugin.output_metadata(meta) AttributeError: 'HTTP' object has no attribute 'output_metadata' </code>
Sorry for the delay in replying. That bug has been fixed in one of the commits since you posted, so if you clone the latest version from the repo you should be up-and-running again. Let me know if any problems.
thank you for the software. Here I am running an AirPi 1.0 board and tried several different version of software. So I made some small tweaks for my board and everything worked immediately. Good!
Tried the HTTP-output and got the same errors as described above. Got the new version from git but could not get the http-output working.
----- ------ Error: Did not import output plugin HTTP: 'HTTP' object has no attribute 'get_ip' Traceback .... File "airpi.py", line 939, in <module> pluginsoutputs = set_up_outputs() File "airpi.py", line 426, in set_up_outputs raise excep AttributeError: 'HTTP' object has no attribute 'get_ip' ----- ------ All ideas are welcome. Regards, lefty
Haydn; You are the FREAKING MAN! -- Nice job on this!!! You've totally resurrected this project and made it a really nice solution - thank you!
I'm a dad that is building a AirPI with my 12 year old daughter for her science project - she's a great kid and really digging into Science and Technology and since the board we ordered is v1.4 the old code just didn't work quite right and was lacking in many ways. This is fantastic -- the HTTP web server view with the charts is a HUGE value add and worked perfect the first time for me so your latest code seemed to have fixed the issues reported earlier in this thread.
Question: we are having a hard time getting any meaning out of the Light, Nitro, and CO2 readings. Do you have any variants of your code that produce Lumens for the light measurement, and Parts Per Million for the Nitro and CO2? -- this would be much appreciated
This may be a quick fix to run the program airpi.py without keeping an open terminal session. Log in to the RPi with a terminal session. Start the program as follows: sudo python airpi.py & This sends the process into the background and gives the PID in return. Log out and close the terminal session. The program is still running. A brief test: Open a terminal session and log in to your Rpi. Use the following: ps ax | grep airpi
That should show you that the program is still running or just try the web server.
If you have set CSV in outputs.cfg to "on" and love the CLI use tail -f <your-rpi>.csv and watch the program writing data. Stop "tail" with ctrl c
Hope this helps until the boot-problems have been solved.
Last Edit: Oct 1, 2014 5:08:11 GMT -5 by lefty: Typos
Thanks for kind words; I can't take the credit for the HTTP server though as that was Fred Sonnenwald. Glad the rest of it is proving useful though.
For the light readings, you should be able to enable the 'calibration' output plugin and then set calibration=on for the other outputs to get a reading in Lux (again, not my work so I have no idea if it's accurate or not). I haven't yet had chance to look into converting Lux to Lumen. Not that by default the resistance goes up in the dark and down in the light, so any graphs of raw (uncalibrated) data from the sensor basically show the inverse of what you'd expect. There is also a massive variation in the range of the readings over a whole day/night cycle.
There is no calibration or conversion function for CO and NO2 at present. I am doing some work with a university to calibrate against known standards, but it will be a few weeks before that is complete, and we will also have to take into account the temperature and humidity dependancy of the sensors. I'll post something here as soon as I get anything which might be useful to others, because it seems there is quite an appetite for this!
Just a point of note - you mention CO2 and Nitrogen in your posts but bear in mind it is CO (carbon monoxide) and NO2 (nitrogen dioxide) that the AirPi is sensing.
I'm not sure what's going on with the bootstart stuff - I'll take a look shortly and report back.
Anyway, I hope your daughter is enjoying the AirPi; I'll update this thread with more info as soon as I can.
This may be a quick fix to run the program airpi.py without keeping an open terminal session.
Thanks. The 'bootstart' feature is intended to allow automatic sampling on start up though, rather than just continuing a session after you log out. For example, if you take an AirPi out in the field with a battery pack, you could enable the 'bootstart' feature so that you can just switch it on without anything else plugged in (no monitor, keyboard, network), and it will start sampling without you having to do anything at all (well, until the battery dies!).
I pulled the new code and noticed that the system runs much longer before crashing now. It used to run about 12 to 15 hours before locking up. In fact it hasn't crashed or hung once with the new code and has been running for a couple days now.
I haven't been able to get it to boot on start yet however and really like this idea so it can just be plugged in headless anywhere in the field that it can reach the wifi access point it's been setup to use.
(and yes that was just a typo up above regarding the Nitrogen and Carbon Monoxide stuff - CO2 vs CO and NO vs NO2) - that's all working great. I used your new calibration switch to output the light readings in LUX - very nice!
Is there an easy way to convert the Celsius to Fahrenheit and also to adjust the temp readings for the heat that the RaspberryPi itself is giving off? If we use google to convert the Celsius readings from the two chips (BMP and DHT) our temp readings from the unit are constantly reading about 17 degrees F too high. (I'm assuming again this is the added heat from the RaspberryPi itself interfering with the sensors)
thanks again for an absolute amazing job - this is so dang cool! -- we are going to try and add the GPS, wind speed and direction next. My daughter wants to add the geiger counter eventually too in case this is ever used on Mars (ha!) and also an infrared life form body heat detection sensor (which we actually found online) to detect Aliens or Zombies in case of a zombie apocalypse too.... cracking me up.
Great news. For Fahrenheit, add a line to the sensor definition in cfg/sensors.cfg:
unit = F
That should output in Fahrenheit. With the version you're running you might get an error, because sometimes the first one or two readings when you start a run are blank for some reason. I have just committed a version which first runs for 15 seconds without recording any data, which (in my setup) is long enough for all of the sensors to start reporting sensible numbers.
GPS should be fine, as I have one of those and output via 'print' and 'csvoutput' is working nicely. For wind speed, direction, geiger readings and infrared - good luck!
Newest version also has the ability to stop automatically after a set number of samples.
I haven't been able to get it to start on boot up yet. I did realize that after running the "update-rc.d" command to set the boot up stuff that I was getting a message back informing me that "dependency-based booting is enabled" and so therefore nothing was getting done. So, after some Googling a bit i decided to use the "insserv" command instead and that worked without any error or comment back.
However, it's still not starting at boot up so i'll dink with that some more when I can connect to a monitor again and see the boot messages.
Also the temp reads about 17 to 20 degree F too high on both of my sensors (assuming this is due to the heat given off of the Raspberry Pi itself. Is there a way to account for that?
Last Edit: Oct 11, 2014 17:54:02 GMT -5 by pierceit
Thanks for the massively improved software! I'm running into an issue when trying to enable uploads to ThingSpeak. When I set enable = yes for ThingSpeak in output.cfg I get the following error when running airpi.py:
Loading: OUTPUTS Success: Loaded output plugin Calibration Success: Loaded output plugin Print ERROR: Could not import output module thingspeak ERROR: Did not import output plugin ThingSpeak: No module named requests Traceback (most recent call last): File "./airpi.py", line 1170, in <module> PLUGINSOUTPUTS = set_up_outputs() File "./airpi.py", line 495, in set_up_outputs raise excep ImportError: No module named requests