Sensor calibration at bootup
saso5 opened this issue · comments
First off, thank you for your work decoding the information. You saved me a lot of time!
But I have doubts regarding the calibration ('ad') command at startup.
As this happens indoors I now only get values around ~0.001 mg/m³.
I've put the sensor outside for recalibration and removed the 'calibration' code, and now it works better IMO.
Does your sensor work differently?
Thank you, as you pointed out, I agreee to remove the calibration code.
There is no official information about this sensor, so I wrote the program by protocol analysis. There is a part by my guessing, and calibration is one of them.
I also decided to the futures of this program ad hoc, such as delay() timing. That should be fixed.
Thank you for your help.
I did some package analysis of the app communication (just rename the files as .pcap and open them in Wireshark).
In the second example, I've reconnected to the sensor via the app just to see how it behaves if sensors are already hot.
Here are some of my observations:
- Notifications are turned on at the start
- I don't see the
ee
package as you did in your analysis (different firmware?) - I don't know what the
ae
package is I've tested and I get notifications without sending it - I think the
ac
package checks if sensors are ready/hot
Regarding the Sensor error? you mentioned in your blog. I was thinking that it might be just values going below 0 and the sensor return negative values. Proper calibration would probably get rid of those if true.
This is the summary of package values in the communication.
#6003_package_hci_.1.
-> Value: aa15011e0c3629
<- Value: aa15011e0c3629
-> Value: ab
<- Value: 0a15011e0c3600d708000255005e010002b4
-> Value: ae02
<- Value: ae0305
-> Value: ac //Check sensor?
<- Value: ac01000000
-> Value: 0b15011e0c3200d7314d02760063000002b9
-> Value: ac00000000 //Sensor ready?
#6003_package_hci_.2
#1 Connection
Value: aa15020e091a0c
Value: aa15020e091a0c
Value: ab
Value: 0a15020e091a00d208003fff3fff010001c2
-> Value: ae02
<- Value: ae0305
-> Value: ac
<- Value: ac09000000
<- Value: 0b15020e081d00c5314d0005000100000219
<- Value: 0b15020e082200b1f1d00005000001000219
<- Value: 0b15020e082700a9f1d00005000101000222
<- Value: 0b15020e082c00a7f1d0000500030100021f
<- Value: 0b15020e083100a5f1d0000500030100021f
<- Value: 0b15020e083600a7f1d0000500020100021f
<- Value: 0b15020e083b00bbf1d00006000101000229
<- Value: 0b15020e090400c5f1d00006000201000229
<- Value: 0b15020e090900cd40000000000001000000
<- Value: ac00000000
<- Value: 0a15020e091a00d258023fff3fff010001c2
-> Value: ab
<- Value: 0a15020e091a00d208003fff3fff010001c2
-> Value: ab
<- Value: 0a15020e091a00d208003fff3fff010001c2
-> Value: ab
<- Value: 0a15020e091a00d408003fff3fff010001c2
...
->Value: 0a15020e091d00d408000000000001000000
->Value: 0a15020e091d00d408000007000201000237
#2 Re-Connection
-> Value: aa15020e091e24
<- Value: aa15020e091e24
-> Value: ab
<- Value: 0a15020e091e00d408000007000001000230
-> Value: ae02
<- Value: ae0305
-> Value: ac
<- Value: ac00000000 //No heading required
-> Value: ab
<- Value: 0a15020e091e00d40800000700020100022c
-- Calibrate
-> Value: ad
<- Value: ad01
-> Value: ab
....
Also, I've prepared an environment to play with the sensor more interactively - https://saso5.github.io/WP6003-air-box/
Thank you for your great research.
- Notifications are turned on at the start
That's right.
- I don't see the
ee
package as you did in your analysis (different firmware?)
I checked it on iOS and my dummy program. There is something different.
- I don't know what the
ae
package is I've tested and I get notifications without sending it
That's right. The notification will be sent even if you do not set it. I wrote notification time to specify it, but you can omit it.
-> Value: ae02
<- Value: ae0305
I think ae02 read notification interval time from sensor. ae01 sets it.
- I think the
ac
package checks if sensors are ready/hot
I dit not see any 'ac'. I no good idea for this.
<- Value: ac00000000
<- Value: 0a15020e091a00d258023fff3fff010001c2
-> Value: ab
<- Value: 0a15020e091a00d208003fff3fff010001c2
Response 0b looks like be in calibration.
Sometime, response 0a returns with incorrect value (3fff). I don't know the correct way to get rid of this incorrect value. I'm just throwing away the value 3fff.
Thank you for helping.
Also, I've prepared an environment to play with the sensor more interactively - https://saso5.github.io/WP6003-air-box/
great!
I checked it on iOS and my dummy program. There is something different.
I didn't consider that there might be differences in the applications Android vs iOS.
This might be it.
But regarding the ac
package. It is most definitely related to sensor heating.
This is what I see in the application until the response is ac00000000
.
Do you have this step in your app? (It only shows if the device has been turned off for a few minutes/hours)
I've linked the sensor with InfulxDB/Grafana and did some testing.
Looking at the graph it looks like there is only one sensor responsible for producing HCHO, TVOC, and CO2 data.
I've also wanted to test if heat has any effect on the sensor so I put some ice underneath the sensor to cool it down to see if affected the other sensor. It might but the effect seemed negligible.
Beautiful work. Thanks to you two.
Many thanks for you work up to now . Are you shure about the data of CO2 ?. I have two of this device started outside , fresh air away from the city,during daylight , no heating around as fast as possible connect to you tool /webpage . at startup the device show a value of 450, rising up to about 530 after 10 .. 20 Minutes . Now about 6h later the value is 543, same location outside.
Some days before i tried the same with the other device , same behaviour. also starting with ~450 , then up to ~540.
For my opinion / what I found on the internet a value of about 410 should be normal , so values shown are to high .. You graph above shows also alway a value > 500.
So i see the same .. value rising inside , dropping with windows open
? is there any way to have the data as an (string) output , like your grafana , I would like to import data to iobroker Homeautomation system ( mqtt, https, .. ) but I am not a programmer .. :-(
@zu2 Just an update. I've been running the sensor for 2 weeks now and I had no problems.
There was one spike, but otherwise, everything is looking
So tnx again for the work you did
@saso5 I'm contacting you here as you don't have issues enabled on your fork.
To store data in home-assistant the best bet would be to write a python library + a hass integration.
I was planning (but I am not sure if I am able to do it) on using the same approach used by the miflora integration (in the end, we need to write a small wrapper that uses BLE to talk to the sensor)
https://github.com/basnijholt/miflora/blob/master/miflora/
What about this approach https://github.com/ThomDietrich/miflora-mqtt-daemon ?
Would be pretty cool if HA could just communicate with a plug-in over BLE with this device and even autodiscover it. :)