Air quality sensors?

1,396 views
Skip to first unread message

Yves Martin

unread,
Apr 4, 2017, 5:44:40 PM4/4/17
to weewx-user
Hi,

Just a simple question about "air quality", because it is nowadays an important health factor in the cities. I'm using a Vantage Pro since 10 years now, and this station is a rock... it never failed and gives accurate information.

Is there a kind of project that could be used with "weewx" for this kind of information? This is the kind of air quality sensor I found on eBay: http://www.ebay.ca/itm/132141883335?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (2017 AirMaster2 AM7 master air CO2 laser pm2.5 formaldehyde air quality testing). Is there a way to integrate this with weewx?

Yves,
YMartin.com/meteo
CANADA

Horacio

unread,
Apr 5, 2017, 12:29:27 PM4/5/17
to weewx-user
Hello Yves

If the unit sends data via USB port and if it's record format is not too complex, It could be possible to write a service program to get data.

This is a cheaper CO2 sensor but you'll need a MCU like an Arduino between the sensor and your PC.

I hope this helps you

Yves Martin

unread,
Apr 10, 2017, 12:01:25 PM4/10/17
to weewx-user
Hello Horacio,

It was just a question/suggestion to know if there are something already done with weewx. It seems not.
I found a lot of Chinese air quality devices (it is a reality in big Chinese cities) but I don't know if they can be "connected"... 
I will check ...

Thanks.
Yves

Paul Bartholdi

unread,
Apr 17, 2017, 3:52:29 PM4/17/17
to weewx-user
Hello,   if this is still open, you may be interested with the "Yoctopuce" modules. " http://www.yoctopuce.com/EN/ ". They include CO_2 and volatile air sensors in very tiny boards interconnected via USB. They are produced in Geneva/Switzerland, supposed of high quality, but at a rather reasonable price. One module includes barometer, temperature and humidity for < 75 US$... on a board of 20x60mm, including connector.
Hope this helps!     Paul

Yves Martin

unread,
Oct 31, 2017, 5:06:30 PM10/31/17
to weewx-user
This is really interesting... but I'm not a programmer,... so the code to be written is not my cup of tea. Because of the Air quality, especially in large cities, becomes a big issue, I hope some will write something someday for Raspberry Pi (the most useful platform), I already use for Weewx but also for my Radio with APRS ...

I found also this very compact module made by Xiaomi: https://xiaomi-mi.com/air-and-water-purifiers/xiaomi-mi-pm25-detector-white/

Yves,
YMartin.com/meteo

pterodaktil

unread,
Nov 1, 2017, 3:03:04 AM11/1/17
to weewx-user
Best air  sensor   i see is airmaster  am7/ My  review  on  it  in russain  https://mysku.ru/blog/taobao/40456.html Hope  google translate  can  help you
And  it can write to pc. I  write  simple  script  to   write  in database. Not weewx  but...

среда, 1 ноября 2017 г., 0:06:30 UTC+3 пользователь Yves Martin написал:

pterodaktil

unread,
Nov 1, 2017, 5:52:13 AM11/1/17
to weewx-user
я wrote  this  to   get data   to  database.
CREATE TABLE IF NOT EXISTS `data` (
 
`unixtime` bigint(20) NOT NULL,
 
`pm25` int(11) NOT NULL,
 
`pm10` int(11) NOT NULL,
 
`hcho` float NOT NULL,
 
`voc` float NOT NULL,
 
`co2` int(11) NOT NULL,
 
`temp` float NOT NULL,
 
`humidity` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


script   to  import  it 

#!/usr/bin/python
import os
import time
import serial
import MySQLdb
import statistics
db
= MySQLdb.connect(host="127.0.0.1",
                     port
=3306,
                     user
="user", # username
                      passwd
="password", # password
                      db
="air") # name of the database
 
cur
= db.cursor()
ser
= serial.Serial( '/dev/ttyUSB0', 9600, timeout=10 )
a
=1
while a==1:
        pm25
= []
        pm10
= []
        hcho
= []
        voc
= []
        co2
= []
        temp
= []
        humidity
=[]
       
for i in range(64):  
                s
= ser.readline()
                sa
= s.split(',')
               
if len(sa) == 8:
                        pm25
.append(float(sa[0]))
                        pm10
.append(float(sa[1]))
                        hcho
.append(float(sa[2]))
                        voc
.append(float(sa[3]))
                        co2
.append(float(sa[4]))
                        temp
.append(float(sa[5]))
                        humidity
.append(float(sa[6]))
                        summ
= float(sa[7])
 
        unixtime
= long(time.time())
        pm25med
=statistics.median(pm25)        
        pm10med
=statistics.median(pm10)
        hchomed
=statistics.median(hcho)
        vocmed
=statistics.median(voc)
        co2med
=statistics.median(co2)
        tempmed
=statistics.median(temp)
        humiditymed
=statistics.median(humidity)
       
print (pm25med)
       
print (pm25)
        a
=2
       
        cur
.execute(
       
'INSERT INTO data '
       
'(unixtime, pm25, pm10, hcho, voc, co2, temp, humidity)'
       
'VALUES'
       
'(%s, %s, %s, %s, %s, %s, %s, %s)',
       
(unixtime, pm25med, pm10med, hchomed,  vocmed,  co2med, tempmed, humiditymed))
        db
.commit()
                       
db
.close()      
   
print('end')


среда, 5 апреля 2017 г., 19:29:27 UTC+3 пользователь Horacio написал:
Привет, Ив

Если устройство отправляет данные через USB-порт, и если формат записи не слишком сложный, можно было бы написать служебную программу для получения данных.

Это более дешевый датчик CO2, но вам понадобится MCU, например, Arduino между датчиком и ПК.

Я надеюсь, это поможет вам


Во вторник, 4 апреля 2017 года в 6:44:40 вечера UTC-3, Ив Мартин писал:
Здравствуй,

Просто простой вопрос о «качестве воздуха», потому что в настоящее время он является важным фактором здоровья в городах. Я использую Vantage Pro с 10 лет, и эта станция является скалой ... она никогда не подводила и не давала точной информации.

Есть ли какой-то проект, который можно использовать с «weewx» для такого рода информации? Это вид датчика качества воздуха, который я нашел на eBay:  http://www.ebay.ca/itm/ 132141883335? _trksid = p2060353. m1438.l2649 & ssPageName = STRK% 3 AMEBIDX% 3AIT (2017 AirMaster2 AM7 главный воздух CO2 лазер pm2.5 формальдегид контроль качества воздуха). Есть ли способ интегрировать это с weewx?

Ив,
YMartin.com/meteo
КАНАДА

Yves Martin

unread,
Nov 8, 2017, 9:01:39 AM11/8/17
to weewx-user
Thanks a lot. I can not read Russian, but I have good friend who can ;)
I will try this.

Yves,
YMartin.com/meteo

Thomas Carlin

unread,
Nov 20, 2017, 10:37:53 PM11/20/17
to weewx-user
I have been looking for air quality sensors also, and the one that peaked my interest is the PurpleAir:  https://www.purpleair.com/  Unfortunately, none of their documentation says anything about local access, but I have found documentation for pulling the data out of thingspeak.  The downside being that is reliant on many things, someone else's servers, your network, Internet, their network, etc.  Another that looked interesting is the uRAD project: https://www.uradmonitor.com/.  

It should be trivial to write a driver for these, TK and the crew have great documentation in the customizing guide.  I'll have to research the Ebay one, If only it was networked, and weather shielded to live outside!

Thomas Carlin

unread,
Nov 26, 2017, 10:58:10 PM11/26/17
to weewx-user
For anyone that is interested, I did finally get a response from the folks at purple air, and you can remotely access the data from the sensors in JSON format by going to http://<sensor-ip>/json.  This sensor system seems to be an excellent compromise between system quality, price, and *hopefully* longevity and reliability.  

I don't know if the document is publically readable or not, but their documentation can be found Here: https://docs.google.com/document/d/15ijz94dXJ-YAZLi9iZ_RaBwrZ4KtYeCy08goGBwnbCU/edit#heading=h.l6r1b1hpfhod

Kenneth Baker

unread,
Dec 4, 2017, 10:03:40 AM12/4/17
to weewx-user
On Sunday, November 26, 2017 at 10:58:10 PM UTC-5, Thomas Carlin wrote:
For anyone that is interested, I did finally get a response from the folks at purple air, and you can remotely access the data from the sensors in JSON format by going to http://<sensor-ip>/json.  This sensor system seems to be an excellent compromise between system quality, price, and *hopefully* longevity and reliability.  

I don't know if the document is publically readable or not, but their documentation can be found Here: https://docs.google.com/document/d/15ijz94dXJ-YAZLi9iZ_RaBwrZ4KtYeCy08goGBwnbCU/edit#heading=h.l6r1b1hpfhod


Hi Thomas,

My Purple Air device just arrived...  Have you written a weewx driver for Purple Air?

-- Ken

Thomas Carlin

unread,
Dec 4, 2017, 11:51:03 AM12/4/17
to weewx-user
I have not.  It should be pretty easy with the google doc link above, and the documentation provided by TK and the crew here: http://www.weewx.com/docs/customizing.htm#Adding_2nd_source.  You would just need to parse and sanitize the data coming in from the json output, and stuff it into the database.  Once it is there, it's just a matter of modifying the weewx UI to display as desired.

I have a handful of other projects going right now, but this is definitely on the list.  When it happens is anyone's guess.

Daniel Rich

unread,
Dec 4, 2017, 2:43:56 PM12/4/17
to weewx-user
A friend of mine pointed me at the PurpleAir back when we had a valley full of smoke from the Napa/Sonoma fires a few months ago. This thread just convinced me to buy one. :-)  If no one else has tackled it by the time it shows up and I have time to install it, I'll look into adding a data source for it. It shouldn't be too hard to pull the JSON and convert it to a 2nd database in weewx (and in my InfluxDB as well).

Kenneth Baker

unread,
Dec 5, 2017, 11:09:36 PM12/5/17
to weewx...@googlegroups.com

Daniel & Thomas,

I started in on a 2nd data source collector today. The code is based on Matthew's
cmon plugin. I plan to do some more testing and then I'll post it here for
comments.

Thanks!

-- Ken
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> weewx-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


Thomas Carlin

unread,
Dec 6, 2017, 10:59:12 PM12/6/17
to weewx-user
That's great!  You'll have to keep us updated.  Are you accessing it using you LAN (192.168.whatever) or pulling the data from their servers?

Kenneth Baker

unread,
Dec 7, 2017, 9:43:34 PM12/7/17
to weewx...@googlegroups.com

I am pulling the data from the local device.

-- Ken
>> > weewx-user+...@googlegroups.com <javascript:>.

Neville Davis

unread,
Dec 9, 2017, 5:26:07 AM12/9/17
to weewx-user
I have just read through this post, if I have it right you have a device that has json in a web page and you wish to import this data into weewx.
I had a similar situation with my air conditioner that also had data in json on my local lan...and wanted to get it into weewx...Is the aircon was on? heating or cooling, set temp, and current temperature....etc, if you look on the weewx wiki at the hardware i2c with raspberry Pi links you will find the files I used to (a) get the data and (b) get the data into weewx... link to my site is also there and you can see the info displayed.
There might be something you can use.

Nev

Daniel Rich

unread,
Jan 7, 2018, 4:45:40 PM1/7/18
to weewx-user
Ken,

How goes your work on a PurpleAir plugin? Mine finally showed up last week (they had some supplier issues) and I just got it up on the outside of the house a few minutes ago. If you have something that works I'd be glad to give it a try and let you know how it goes for me.

Greg Troxel

unread,
Jan 7, 2018, 8:17:51 PM1/7/18
to Daniel Rich, weewx-user
Daniel Rich <wwwd...@gmail.com> writes:

> How goes your work on a PurpleAir plugin? Mine finally showed up last week
> (they had some supplier issues) and I just got it up on the outside of the
> house a few minutes ago. If you have something that works I'd be glad to
> give it a try and let you know how it goes for me.

Can you set up the purpleair to give you data locally and not upload to
their cloud? That was not at all clear from their website.

Also, I recently came across a new sensor at adafruit:

https://www.adafruit.com/product/3686

(I have only read the ad page, not actually played with one.)

Thomas Keffer

unread,
Jan 7, 2018, 8:39:41 PM1/7/18
to weewx-user, Daniel Rich
That AdaFruit sensor looks sweet at a great price. Have you thought about how to mount it outside?

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.

Thomas Carlin

unread,
Jan 7, 2018, 9:09:43 PM1/7/18
to weewx...@googlegroups.com
Yes you can access the purple air data locally, I posted a link to their hidden document above. Something like <sensorIP>/json. It will still send data to their cloud, but you won't be dependent on it to get your data, and you will be able to access it quickly.

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/hzN9K3QH7kU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+unsubscribe@googlegroups.com.

Kenneth Baker

unread,
Jan 8, 2018, 4:17:43 PM1/8/18
to weewx...@googlegroups.com

Hi Daniel,

I do have a plugin ready and working. I'll push it tonight or first thing tomorrow
and post it here when I do.

-- Ken
>> > weewx-user+...@googlegroups.com <javascript:>.

Greg Troxel

unread,
Jan 9, 2018, 8:39:59 AM1/9/18
to Thomas Keffer, weewx-user, Daniel Rich

Thomas Keffer <tke...@gmail.com> writes:

> That AdaFruit sensor looks sweet at a great price. Have you thought about
> how to mount it outside?

Not really ;-) Mounting is the downside. I was actually thinking of
indoors first, to be able to tell if HEPA filters were changing the
levels (really, if the levels without them are bad enough to bother
running them -- I know they are very effective when levels are higher).

My only thought is to have some sort of rain shield that's large and
fairly flat (like a trash can lid) and suspend it beneath, enough to get
airflow but not enough to get rain, and figure that at $40, one can take
a chance.
signature.asc

Greg Troxel

unread,
Jan 9, 2018, 8:41:21 AM1/9/18
to Thomas Carlin, weewx...@googlegroups.com

Thomas Carlin <thomas...@gmail.com> writes:

> Yes you can access the purple air data locally, I posted a link to their
> hidden document above. Something like <sensorIP>/json. It will still send
> data to their cloud, but you won't be dependent on it to get your data, and
> you will be able to access it quickly.

Thanks. Regardless of cloudy issues, it will be great to have another
driver.

My concern about the cloud is not relying on it, but sending data in the
first place, especially since they seem to think it should all be
published.
signature.asc

Daniel Rich

unread,
Jan 9, 2018, 11:16:51 AM1/9/18
to Greg Troxel, Thomas Carlin, weewx...@googlegroups.com, weewx...@googlegroups.com
With PurpleAir, they give you the option when you setup the sensor to make the data public or private.

-- 
                               |  "Step up to red alert!"  "Are you sure, sir?
                               |   It means changing the bulb in the sign..."
                               |          - Red Dwarf (BBC)
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.

Kenneth Baker

unread,
Jan 10, 2018, 11:14:48 AM1/10/18
to weewx...@googlegroups.com
Hi Daniel,

Please give this a try: https://github.com/bakerkj/weewx-purpleair. The
installation procedure is untested at the moment. Comments, suggestions, new
feature requests are all welcome.

-- Ken


P.S. Matthew, I modeled this plugin on your cmon extension - Thanks!



jonathan koren

unread,
Jan 15, 2018, 10:45:10 PM1/15/18
to weewx-user
I just installed my purple air sensor, and am trying out weewx-purpleair, but I'm having all sorts of problems getting the purpleair.sdb to be created correctly.

Originally, purpleair.sdb wasn't created, so I created it along with the archive table, but it still isn't working. It's now complaining about
OperationalError: No day summary schema for table 'archive' in database 'purpleair.sdb'

jonathan koren

unread,
Jan 15, 2018, 10:54:24 PM1/15/18
to weewx-user
Apologies for the double post. I accidentally sent the message before I was ready.

Here's the stack trace.
Traceback (most recent call last):
  File "/usr/share/weewx/weewx/reportengine.py", line 239, in run
    obj.start()
  File "/usr/share/weewx/weewx/reportengine.py", line 273, in start
    self.run()
  File "/usr/share/weewx/weewx/imagegenerator.py", line 32, in run
    self.genImages(self.gen_ts)
  File "/usr/share/weewx/weewx/imagegenerator.py", line 72, in genImages
    archive = self.db_binder.get_manager(binding)
  File "/usr/share/weewx/weewx/manager.py", line 857, in get_manager
    self.manager_cache[data_binding] = open_manager(manager_dict, initialize)
  File "/usr/share/weewx/weewx/manager.py", line 1009, in open_manager
    manager_dict['table_name'])
  File "/usr/share/weewx/weewx/manager.py", line 104, in open
    dbmanager = cls(connection, table_name)
  File "/usr/share/weewx/weewx/manager.py", line 1149, in __init__
    raise weedb.OperationalError("No day summary schema for table '%s' in database '%s'" % (self.table_name, connection.database_name))

OperationalError: No day summary schema for table 'archive' in database 'purpleair.sdb'
Jan 15 19:44:52 raspberrypi wee_reports[14415]: copygenerator: copied 8 files to /var/www/html/weewx

It looks likes it's something with the user.purpleair.schema not being passed through correctly or sometthing.

Any suggestions? This is v0.2 release from github.

Thanks.

gjr80

unread,
Jan 15, 2018, 11:48:57 PM1/15/18
to weewx-user
Hi,

I'm not familiar with weewx-purpleair and I am not sure if the stack trace you posted is with a manually created database or not, but one suggestion if I may. If the weewx-purpleair is supposed to create its own database then I would be trying to work through that issue rather than manually creating the database. In my experience when weeWX related databases are manually created and you subsequently have errors you then need to work out if the errors are due to the manually created database having some defect/shorfall or is it due to an error in the extension/driver/code you are running. You are usually far better to let the weeWX API maintain the databases, when things don't work it takes one variable out of the equation.

Gary

Glenn McKechnie

unread,
Jan 16, 2018, 12:59:16 AM1/16/18
to weewx...@googlegroups.com
Hi jonathon

There is a typo in the install script which I installed using
wee_extension, ie: 'wee_extension --install master.zip'

process_services='user.cmon.PurpleAirMonitor',

should be...

process_services='user.purpleair.PurpleAirMonitor',


You can change it directly in weewx.conf and restart weewx (stop weewx
first, then start it as it maybe a bit messed up from the hard crash -
at least for me it was)

It creates the database with archive_day tables so that may satisfy
the day summary complaint?

I can't test it any further as there is nothing to query here - I
don't have one.

Good luck!



Cheers
Glenn

rorpi - read only raspberry pi & various weewx addons
https://github.com/glennmckechnie
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

jonathan koren

unread,
Jan 16, 2018, 1:36:28 AM1/16/18
to weewx-user
That appears to have been the problem.

I'm really happy how easy this has been to integrate into my local setup.

Thanks

Daniel Rich

unread,
Jan 16, 2018, 4:09:58 PM1/16/18
to weewx-user
I finally had time to take a look at this today, it looks great! I just sent you a pull request for the one remaining cmon reference in the process_service value.

Now I just have to figure out what to do with the data... I'm going to have to find some time to add it into the Saratoga templates that I use at https://www.lapseofthought.com/weather/.


On Wednesday, January 10, 2018 at 8:14:48 AM UTC-8, Kenneth Baker wrote:

Kenneth Baker

unread,
Jan 16, 2018, 8:05:16 PM1/16/18
to weewx...@googlegroups.com

Hi Daniel,

Thanks for the pull request I merged it a moment ago.

You can see what I did with the data here:
https://weather-rockport.keneli.org/
https://weather-rockport.keneli.org/history.html

-- Ken
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> weewx-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


Kenneth Baker

unread,
Jan 16, 2018, 8:09:47 PM1/16/18
to weewx...@googlegroups.com

Jonathan,

I'm glad to hear this fix from Glenn fixed it.

-- Ken



> That appears to have been the problem.
>
> I'm really happy how easy this has been to integrate into my local setup.
>
> Thanks
>
> On Monday, January 15, 2018 at 9:59:16 PM UTC-8, Glenn McKechnie wrote:
>>
>> Hi jonathon
>>
>> There is a typo in the install script which I installed using
>> wee_extension, ie: 'wee_extension --install master.zip'
>>
>> process_services='user.cmon.PurpleAirMonitor',
>>
>> should be...
>>
>> process_services='user.purpleair.PurpleAirMonitor',
>>
>>
>> You can change it directly in weewx.conf and restart weewx (stop weewx
>> first, then start it as it maybe a bit messed up from the hard crash -
>> at least for me it was)
>>
>> It creates the database with archive_day tables so that may satisfy
>> the day summary complaint?
>>
>> I can't test it any further as there is nothing to query here - I
>> don't have one.
>>
>> Good luck!
>>
>>
>>
>> Cheers
>> Glenn
>>
>> rorpi - read only raspberry pi & various weewx addons
>> https://github.com/glennmckechnie
>>
>>
>> On 16 January 2018 at 15:48, gjr80 <gjrod...@gmail.com <javascript:>>
>> > email to weewx-user+...@googlegroups.com <javascript:>.
Reply all
Reply to author
Forward
0 new messages