Page 1 of 4

Hitchhiking with the Airlink interface of CMX

Posted: Sun 11 Oct 2020 12:16 pm
by HansR
In August I wrote about some sensor work I was doing and shortly after (roughly 12 hrs) ConligWX wrote about the AirLink. Apparently the AirLink was to be added to CMX as a sensor.

So version 3.9.0 of CMX did get the AirLink interface. I had been thinking this over and it became clear that interfacing to CMX to get the particle concentration data of any particle sensor would not have to be too difficult. So after a short exchange with Mark, I decided to build an interface to CMX (which polls the AirLink) and create a FakeAirLink. After a proof of concept I made a simple but workable application.

If you like working with hardware, have a Raspberry and want to spend some 35 euro on sensors, than I have the software to make it work.
And of course, CumulusUtils will soon support the AirLink (both the real and the fake) as well.

I published the code and you can find the release there as well under the tag (take the most recent).
The Readme should get you started. Other sensors are possible, ask for it (and send me one) and I'll implement if possible.

Git repository here, with code and release and info.
For general info on AirQuality, sensors and AQI interpretation I wrote a separate post.

NB: Although this is slightly a home built device (why I wrote the first message in the Homebuilt forum), the project turned towards CMX as the AirLink became available and a supported device for the Cumulus World. I had already planned to make an AirQuality module for CumulusUtils so combining all this, I decided to make this message in the CumulusUtils part of the forum. It fits. Homebuilt is too separate.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sat 14 Nov 2020 8:58 pm
by Phil23
Interesting Han's,

I've actually got a pair of Sensiron SPS30 Sensors here. Have had various thoughts on what to do with them but never proceeded.

Have two rPi's on hand, a couple of Arduino's & dozens of Micromites.

It was Micromite where I was originally planning to go, in particular adding it into an existing VOC Air Quality monitor I built.

VOC I found to be very interesting after building the unit, in particular the degrading of the air quality of a closed bedroom at night with poor ventilation.
VOC's increased during the night & found the peak to correspond with when my sleep was disrupted.
Also it proved a point that the VOC's pooled from the floor up as they increased in the room.

That could be another interesting sensor to add, cheap as chips, only catch is it requires a warm up period & a bit of a calibration routine occasionally.

Cheers

Phil.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 15 Nov 2020 6:39 am
by HansR
@Phil:
Yes, the sensirion is a very well known sensor, I may add it some time. A bit more complex interface but otherwise principally pretty much the same as the PMS1003 I did implement. The Micromites system is interesting, a microcosmos in itself. Never seen it before, might be useful for using analogue sensors such as indeed the VOC or other gas sensors. It adds another layer of coding and complexity but still. I'll look at it in more detail.

Thanks for the reply and the suggestions.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 15 Nov 2020 7:48 am
by Phil23
HansR wrote: Sun 15 Nov 2020 6:39 am The Micromites system is interesting, a microcosmos in itself.
There is good support for most interfaces. I actually run 17 temp sensors here over 3 devices which integrate in the end.
There is also a version that runs on rPi, but it would need an additional A/D interface module to read analogue sensors.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 15 Nov 2020 5:52 pm
by ExperiMentor
Hans, Can you reccomend a cost-effective sensor?

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 15 Nov 2020 6:46 pm
by HansR
Not really. It also depends on what you want to sense ;)

For PM sensor I am very happy with my PMSxyyy sensors. Cheap and workable. Lots of literature.
The SPS30 is very well known, proven but a bit more expensive
For temp/hum the SHT sensors (used by Davis) are very well proven and not too expensive)
If you want pressure as well you might want to go for the BME280
If you want to add VOC you might want to have the BME680.

And so on... not to talk about inside or outside and temp/hum correction.
It is not all that straight forward and requires some study and especially: what do you want to measure?
So many sensors.... I can't even start to have preference. And then I am not even talking about gas sensors (NO2, SO2 etc...)

Choices need to be your own.
Important is you know HOW to read the sensor, to store the data and how to present it.
Cost of the sensor is not the issue these days.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 15 Nov 2020 9:49 pm
by ExperiMentor
Thanks for the great introduction - I need to get more into this, had no idea there was so much easily available and cheaply! I had thought the discussion was mainly about PM but guess it would be good to put together a full array for wide-ranging air quaity measurement. I can feel a project coming on!

Re: Hitchhiking with the Airlink interface of CMX

Posted: Thu 19 Aug 2021 11:51 am
by HansR
Because WeatherDuino now has an AirQuality sensor module which actually does exactly the same as what I came up with (including mimicking the Airlink and using Sensor Community) I decided to stop this development. I wasn't doing too much anyway :|
If you want something like this: go for the AQM III.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 07 Aug 2022 10:36 am
by watsonm
Hans,
I have the PMS5003 and have it running on my Raspberry pi (indoors). All I am doing is getting the pm1, pm2.5 and pm10 data points
and sending them to CMX as extra Air quality sensors points 1, 2 and 3.

Is your Air link emulator processing the instant data to get the 1hr, 3hr, 24hr data points as I presume that is what is needed to post to CMX.

cheers Mike
(note for a change I am posting to forum rather than a private note! :D )

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 07 Aug 2022 11:50 am
by HansR
watsonm wrote: Sun 07 Aug 2022 10:36 am Hans,
I have the PMS5003 and have it running on my Raspberry pi (indoors). All I am doing is getting the pm1, pm2.5 and pm10 data points
and sending them to CMX as extra Air quality sensors points 1, 2 and 3.

Is your Air link emulator processing the instant data to get the 1hr, 3hr, 24hr data points as I presume that is what is needed to post to CMX.

cheers Mike
(note for a change I am posting to forum rather than a private note! :D )
Yes, it is and it sends the data to CMX through the webserver.

The bad news is that I assume the PMS5003 is different from the PMS1003 which is the only one I implemented so it would require some adaptation for that device unless it reacts the same to the same commands as the PMS1003.

The badder news even is that the library I built the AirLink Emulator (RaspberrySharp by JTrotta) has been abandoned by its creator and replaced by the Microsoft System libraries e.g.

Code: Select all

    using System.IO;
    using System.Device.Gpio;
    using System.Device.I2c;
    using System.Device.Spi;
    using System.Threading;
    using Iot.Device.Sht3x;
    using Iot.Device.Bmxx80;
Which are written for .NET

I did look into it to change the libraries but that requires quite some work so it has been dropped for the moment. Nevertheless, the original is on github and could be used if you wish. You could also take out the webserver part and use that in your own piece of code of you wish.

Any program able to read the PMS5003 could easily implement the (or a) webserver be it in Python or in the Arduino IDE (which has several webservers available on the net. But it requires some programming and engineering. My code can be used as an example and or source.

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 07 Aug 2022 2:12 pm
by watsonm
Hans,

I have created the code for getting the 1hr and 3hr avergae of the air quality and am trying to get it
into CMX -> extra sensors-> Airlink page. Looking at your EmulateAirlink.cs I see you using code like:

Code: Select all

"pm_2p5_last_1_hour\":{thisAirLink.PM25_last_1_hourList.Average():F2}," );
"pm_2p5_last_3_hours\":{thisAirLink.PM25_last_3_hourList.Average():F2}," );
"pm_2p5_last_24_hours\":{thisAirLink.PM25_last_24_hourList.Average():F2}," );
"pm_2p5_nowcast\"

I am using http post to input my data and none of this data appears in the Airlink page. Other weather data in the string appears correctly. I am not sure weather I need to set or clear any check boxexes in the CMX -> settings-> extra Sensor -> Air Quality or Davis Airlink pages

Part of my http posting line:

Code: Select all

 'pm25_ch3': '8', 'pm_2p5': '8', 'pm_10': '8', 'pm_2p5_last_1_hour': 8.0, 'pm_2p5_last_3_hours': 8.0, 
The 'pm25_ch3': '8', appears in the correct spot in the extra sensors page but the
'pm_2p5_last_1_hour': 8.0, does not appear anywhere in the Airlink page.

Am I using the correct tag in 'pm_2p5_last_1_hour'

Re: Hitchhiking with the Airlink interface of CMX

Posted: Sun 07 Aug 2022 3:17 pm
by HansR
watsonm wrote: Sun 07 Aug 2022 2:12 pm I have created the code for getting the 1hr and 3hr avergae of the air quality and am trying to get it
into CMX -> extra sensors-> Airlink page. Looking at your EmulateAirlink.cs I see you using code like:

Code: Select all

"pm_2p5_last_1_hour\":{thisAirLink.PM25_last_1_hourList.Average():F2}," );
"pm_2p5_last_3_hours\":{thisAirLink.PM25_last_3_hourList.Average():F2}," );
"pm_2p5_last_24_hours\":{thisAirLink.PM25_last_24_hourList.Average():F2}," );
"pm_2p5_nowcast\"

I am using http post to input my data and none of this data appears in the Airlink page. Other weather data in the string appears correctly. I am not sure weather I need to set or clear any check boxexes in the CMX -> settings-> extra Sensor -> Air Quality or Davis Airlink pages

Part of my http posting line:

Code: Select all

 'pm25_ch3': '8', 'pm_2p5': '8', 'pm_10': '8', 'pm_2p5_last_1_hour': 8.0, 'pm_2p5_last_3_hours': 8.0, 
The 'pm25_ch3': '8', appears in the correct spot in the extra sensors page but the
'pm_2p5_last_1_hour': 8.0, does not appear anywhere in the Airlink page.

Am I using the correct tag in 'pm_2p5_last_1_hour'
Mike, it need some more accurate steps, see points below:

1) You need to configure an AirLink in CMX. Since you are emulation an airlink, skip all official Davis required data, just input what CMX needs, see the screenshot below of my configuration (of course IP and station name must be yours). For an emulator you only need to set the indoor/outdoor tick and then the IP address and the AirLink hostname you use:
    Schermafbeelding 2022-08-07 164943.jpg
      2) The above configures CMX to send a request to the AirLink every requested interval. It does so according to the Davis spec. So if you put

      Code: Select all

      http://<airlink-ip-address-here>/v1/current_conditions
      in your browser the response will be the structure with all data. Your AirLink emulator needs to create such structure with the data you assembled and send it back to CMX in response. I don't think POST will do the trick (but do try, I never did), I think you really need to use a webserver which waits for a request and replies and sets out a new request.

      3) I don't know what language you are using but either you have to create that webserver yourself like I did or you need to find a library which does that part for you. If you do it in C# you can use my code, but no doubt that modern languages will have some webserver lib hanging around on the web.

      4) You can check the CMX logfile to see what it gets back on the AirLink request. That string must be equal to what you see when you put the request-string in the browser.

      5) The data which you do not wish to supply (temperature, nowcast or whatever) still needs to be present in the reply you send to CMX, it needs to be a complete answer (I think although Mark may be able to tell you what happens if certain data are missing). If you don't have temperature, set it to some value which will be accepted, start with 0 and see what happens ;) Note that Temp MUST be in Fahrenheit!

      6) Don't put the values in quotes. It is just a JSON structure so visual checks are easy and because you assemble it in the code with some trial and error you will quickly create the correct json-string.

      That's it. Not so difficult but the trick lies in the async webserver code.

      Good luck!

      Re: Hitchhiking with the Airlink interface of CMX

      Posted: Sun 07 Aug 2022 3:22 pm
      by HansR
      And re-reading you post with the line you send it seems to me you are actually mixing the AirLink configuration with an Ecowitt Extra Sensor configuration. Is that correct?

      Re: Hitchhiking with the Airlink interface of CMX

      Posted: Sun 07 Aug 2022 5:39 pm
      by watsonm
      Hans,

      Yes I was trying to but decided that (at the moment) I don't want to build the AIRlink emulator in python. I
      was hoping I could just http post it to the table after I did the 1hr 3hr calculations.

      Instead I have decided to add the current readings as extra AQ sensor 1 and 2 and the one and
      three hour as 5 , 6, 7 and 8 while I think about it!! :shock:

      Re: Hitchhiking with the Airlink interface of CMX

      Posted: Sun 07 Aug 2022 7:59 pm
      by HansR
      OK