-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The mode is a lie? #11
Comments
@Beanow If time permits coming days I will make a test setup and look if I can recreate the problem. I have one related remark in the readme.md under future check the mode bits of the status byte with internal _mode. |
Thanks! Would be great to compare and know if something is different about the 118 version or whether it's the same for 117. Lines 104 to 111 in e42a538
Comparing those it does look like a date in the first bytes btw. Mine reports 21, 2, 3, 118, CRC looking like 2021-feb-3 .
Sourced at https://nl.aliexpress.com/item/1005003131194702.html |
YES, found the sensor rather quick. Ran your sketch inhouse
Although there seems to be a switching artefact I got quite different values for PPB and UGM3. |
Whoa that's weird. Plus you seem to have more data in the status byte. The internal use bits I presume. I think the switching artifact might be right. The datasheet does say it takes 2s to switch modes, and my sketch doesn't have the delay for that. How have you wired it. Are you using any external resistors? I did read something about that, but assumed that is about the internal pullup. Also your readout is a lot higher, mine eventually settles on about ~61 PPB(?) in the living room. Ah, I see yours is tumbling down, so I assume that's still warmup as well. Mine started at some obscene values like 35000, takes a while to settle down. |
switching Wiring Values
(You're from Netherlands? Me ZO Brabant) |
If you get readings like that the signal is good to perfect, No pull ups needed. An excellent reader about pull ups - http://www.gammon.com.au/forum/?id=10896&reply=5#reply5 |
It's at least responding to gasses though. Here's holding it right up to a lighter's gas.
|
still dropping on this side
|
My datasheet has version V1.2-20200306, yours? |
On the back of the sensor I have SNH 12 02 40 16 36 |
So judging by the footer of the datasheet, the manufacturer's site is aosong.com. Serials wise I've got
|
So serial wise you seem to have at least two different batches. The SNJ number differs 1400 so pretty close. |
I am preparing a 0.1.4 version to add a function uitn32_t getSensorDate() uint32_t dd = sensor.getSensorDate();
Serial.println(dd, HEX); (implementation might change, just a helper function for debugging) |
works
|
so status field gives correct info. Question is if the read function should return some error or so? |
It looks like the both
|
So I've messed about with resistors, 3.3v and 5v, and an external 1A power supply. None of which made any difference, unsurprisingly. I really think either the protocol changed or something isn't working properly and the v118 exists for silicon shortage reasons xD |
I have tested with an UNO which is 5V, you tested with ESP32 ? |
I'm testing with the UNO currently (tried it's 3.3V and 5V outputs). The ESP-WROOM-32 I tried as well, but not using the Arduino IDE or your library. Wrote the I2C protocol with ESP-IDF referencing your library there and got the same results, no mode switching, 0x00 status byte. And the juice was what I was thinking as well, hence I tried an external 5V 1A power supply, with the same results. |
|
added #define AGS02MA_ERROR_NOT_READY -13 and code in .cpp to set this error flag. |
So, since the datasheet isn't telling the whole truth, I decided to dump the registers. Full dump
removed "duplicates" to make it scrollable |
Can you make a 2nd dump up to reg 22 to see what changed? Most is calibration stuff I expect, but it might also have some counters or last measured value?...
see no patterns, too late :) |
I've at least grouped them by what the sheet mentions. Sensor data
Zero calibration data
Undocumented
Version number
Undocumented
I2C slave address
|
last version 0.1.4 shows explicit the not ready flag (in an uint32_t way)
|
A first (manual) analysis of the hex data gave a few hints
The above could be automated
Back to work :) |
Observing a bunch of these over time I found that registers 2-6 are static for me. 7, 8 and 20 do change. Reg 7 seems to be two uint16 parts, the A part seems roughly inversely proportional to the reg 0 measurement value when I spike the reading with some gas. B part is all over the place, can't tell what that is, maybe some clock or counter. I also learned you can get 3 degrees of readiness, depending on how much you pause between I2C commands.
Presumably the I2C commands just hogs all the internal chip's processing cycles, preventing any measuring. And the in between nr 2 state seems to indicate some internal samples being stored in Reg 7. What that tells me is: my v118's busy bit is also not correct. Maybe the entire status byte isn't correctly memory mapped to it's functions in v118. Though it returns 0x00 instead of 0xFF like the unused registers, I've not seen it change from 0x00 no matter what I do. Probably time to try customer support for maybe an updated datasheet and why it's neither using the busy bit correctly and seems to be lacking the UGM3 mode entirely. |
I have made a request to find out if the datasheet is the latest (through my preferred shop who are reseller) |
Thanks I also contacted the reseller I used and aosong.com contact emails, which I assume is the manufacturer's real site. |
if it is a clock it probably is micros ? So reg 7 can be the raw read of particles, it is multiplied with the constant registers to get uG as I expect it uses a constant factor between the two measurements. |
Just reading back the thread I don't think the problem with the status bit is caused by the library. we did not find a way to solve it either yet. So I will keep the issue open at least until there is more info about the datasheet. FYI - Merged the date PR. |
Yes, it's definitely the sensor not behaving as advertised. Thanks for helping debug this, let's wait for the retailer/manufacturer response, as for now this revision just looks partially functional. |
@Beanow |
Me either @RobTillaart
Perhaps that has something to do with it. |
Guess so. |
So, in the meantime. The retailer sent me the Chinese v1.2 datasheet. Even though I told them I already had the v1.2 and was wondering if there was a newer one. It's a good thing I gave them a dedicated email address, because who would otherwise open an attachment like this? Now the technical staff explains: (With PPB underlined.) Did they just silently downgrade to an AGS01DB or what? They have AGS02MA printed on though. So whatever this is it looks like ASAIR's shenanigans more than the retailer. Though the retailer removed the product I left a bad review on and posted it again. Old: https://www.aliexpress.com/item/1005003131194702.html Still claiming ug/m3 output mode. 🤔 seems pretty trustworthy. |
interesting, But that said, it becomes unfixable and I will spend some lines about it in the readme So for now it seems a "won't fix" issue. If you have an idea for a workable solution, let me know. |
Huh, haven't encountered it before. I'd have to dig a bit deeper into the protocol and such if it really is a AGS01DB under the hood, yeah it wouldn't make sense for the library to address as being a AGS02MA flavor. |
going to add this to the readme.md. Is it clear enough? Version problem?The library can request the version with getSensorVersion(). So if you encounter problems with setting the mode, let me know. |
LGTM, at your discretion could link this issue for context. But I think this should do. |
link is good idea. |
@Beanow |
Yeah, if I do get any more insights I'll create a new issue / reopen then :] |
Or at least, the datasheet and output don't seem to match up. Is this how your (v117) devices behave as well?
I've got three (v118) AGS02MA here, that I wasn't able to get into UGM3 measurements on some custom ESP IDF code. Thought I was going mad so I tried an Arduino uno with your library and see the same results, not really changing modes apparently.
Looking at the datasheet, I'd expect the status value to change.

b0000
(decimal 0) for ready + PPB mode.b0010
(decimal 2) for ready + UGM3 mode.Using an adaptation of the library example code, I set up one that alternates modes every 10 measurements. Except that it doesn't? Here's some output I'm seeing with the status being 0 throughout. And no noticeable change in measured value either (other than going down as it warms up).
The text was updated successfully, but these errors were encountered: