Skip to content
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

"Found device", then no output #2

Open
hberg539 opened this issue Oct 5, 2021 · 15 comments
Open

"Found device", then no output #2

hberg539 opened this issue Oct 5, 2021 · 15 comments
Assignees

Comments

@hberg539
Copy link

hberg539 commented Oct 5, 2021

Hello,

when i start the binary, the only output i get is "Found device", then nothing happens.
Any idea why it doesn't work?

Thanks!

Best regards,
Kevin

@hberg539
Copy link
Author

hberg539 commented Oct 5, 2021

Just now an output happend:

# ./co2monitor /dev/hidraw0
Found device
CO2(37407)
CO2(37407)
Failed to send measurement to Influx
CO2(37404)

But the values don't seem quite right. The device was built on 03/21, maybe they changed the encryption?

@gtudan
Copy link
Owner

gtudan commented Oct 5, 2021

Quiet possible - my device is a few years older, so maybe something changed.
How long did you have to wait for the output? The decrypted packages have a checksum and the implementation discards readings where the checksum didn't match. So maybe these readings are falty, but still happened to have a valid checksum by pure luck?

@hberg539
Copy link
Author

hberg539 commented Oct 5, 2021

The first output appeared instantly ("Found device"), the output with values appeared after around 30 seconds.
My device came without a manual, maybe it was used and / or is somehow faulty.

If i find something out, i will report back.

@hberg539
Copy link
Author

hberg539 commented Oct 8, 2021

Same issue with the replaced device. They seem to have updated the firmware.

@hberg539
Copy link
Author

hberg539 commented Oct 8, 2021

Henryk Plötz used the ZG application for windows in his blog. The software he linked (v1.0.0) doesn't work with my device, but the latest version 2.4.4.7 does work. So they must have changed something.

@ghattd
Copy link

ghattd commented Dec 3, 2021

Similar for me - bought an TFA CO2Monitor 2021-11, plugged it in, installed hidapi via brew first, compiled the binary on my M1 Apple Silicon, executed the binary target/release/co2monitor under macOS 11.6.1, and got:

Found device
CO2(53786)
CO2(53786)
Failed to send measurement to Influx
CO2(53786)
CO2(53786)
Failed to send measurement to Influx

The hardware info returned by sysinfo on the Mac about the CO2Monitor USB device is:

Product ID: 0xa052
Vendor ID: 0x04d9
Version: 2.00
Vendor: Holtek

@gtudan
Copy link
Owner

gtudan commented Dec 3, 2021

Sorry to hear that :-( If I find some time I might decompile the latest windows binaries and try to figure out what's going on. I don't own a newer device, so this issue is hard to track down...

@gtudan gtudan self-assigned this Dec 3, 2021
@ghattd
Copy link

ghattd commented Dec 3, 2021

No reason to be worried, you provided it kindly, it’s open source.

Any way I can help debugging this? Unexperienced with USB debugging but I have basic tech skills and with sufficient thrust I can do some gdb …

@gtudan
Copy link
Owner

gtudan commented Dec 3, 2021

It could help to capture the traffic between the windows binary and the device. If you want to have a go at it, see https://desowin.org/usbpcap/

@ghattd
Copy link

ghattd commented Dec 4, 2021

Contacted you via email.

@gtudan
Copy link
Owner

gtudan commented Dec 5, 2021

Interesting... the captured data looks very familiar.

  • The initialisation seems identical.
  • The device seems to send the same amount of data in the same intervals
  • I think even the decryption and checksum stuff is the same

So I guess they only changed the sensor/controller and it is sending data that we can't decode.
Could you try to look inside which sensor they use in later models? My version could easily be opened by taking the back cover off. Inside is a ZGM053U sensor with a RAD-AP05B-QL111 Controller

@ghoffart
Copy link

ghoffart commented Jan 2, 2022

Please find images attached: ZGM053U & sensor/PCB overview

20211222-214840772

20211222-215132643b

@mnhauke
Copy link

mnhauke commented Jan 26, 2023

The newer units report different values for iSerial and bcdDevice ...

There's no change in the data format but it turned out that the newer units do not longer "encrypt" the data.
Just skip the decryption part and and have fun with the new sensor ...

diff --git a/src/zytemp.rs b/src/zytemp.rs
index 8d9ed2f..ba7111d 100644
--- a/src/zytemp.rs
+++ b/src/zytemp.rs
@@ -35,7 +35,7 @@ pub fn initialize<'a>(api: &'a hidapi::HidApi) -> hidapi::HidDevice<'a> {
 pub fn read_data(device: &mut hidapi::HidDevice) -> Reading {
     let mut data = [0u8; 8];
     device.read(&mut data).ok();
-    let decrypted = decrypt(data);
+    let decrypted = data;
     validate_checksum(&decrypted).ok();

     match decode(decrypted) {

@kkettinger
Copy link

kkettinger commented Jan 27, 2023

@mnhauke, just tried your changes and they work with my device. Thank you!

Found device
Temperature(20.850006)
Temperature(20.912506)
CO2(831)
Temperature(20.912506)
CO2(831)
Temperature(20.912506)
CO2(831)

@gtudan
Copy link
Owner

gtudan commented Jan 27, 2023

Ah, great catch - I'll try to come up with a version that conditionally decrypts depending on the usb meta data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants