davidkreidler / OpenCO2_Sensor

Arduino Repository for an E-Ink CO2 Sensor using ESP32 and SCD4X
https://www.tindie.com/products/davidkreidler/open-co2-sensor/
MIT License
100 stars 5 forks source link

Bigger clock #20

Closed saviola777 closed 4 months ago

saviola777 commented 4 months ago

Hello, great little device!

How difficult would it be to add a setting to have a bigger clock at the bottom, replacing the "12:31 co2ppm"? Both the wifi symbol and the co2ppm are kind of unnecessary to me (the former since the clock is only shown when connected to wifi anyway, the latter because well, I know the units!). As it is, the clock is a bit hard to read for someone without perfect vision (like me).

Of course nobody else might be interested in something like this so it might not be worth it. If that's the case, maybe you could give me some pointers how to implement something like that myself? (I do have a computer science background, but have never worked with ESP / Arduino IDE etc.)

Thanks!

PS: I don't really want to open another issue for this because it's not really a problem, just something maybe worth documenting: after opening/closing the menu, calibration, reboots etc., all sensor values (mostly temperature and humidity) are random and several hours to slowly come back to the correct values. It's not a big deal, but it seems like something easily fixed by starting from the last known values?

davidkreidler commented 4 months ago

Hey @saviola777 , thanks for reaching out and Im always happy about improvement suggestions. The size and position of the time is programmed here: https://github.com/davidkreidler/OpenCO2_Sensor/blob/main/epd_abstraction.ino#L951 The WiFi Symbol is programmed just above it. I've made the change for the next upcoming release: image

You can download a preview firmware here: https://drive.google.com/file/d/1CZV0PkfPjihIBflSv7b6Stn6vJallcpi/view?usp=sharing Install it by plugging in a data USB-C cable into your PC and the Sensor. Then copy FIRMWARE.BIN to the USB device.

Regarding the temperature and humidity values: Because of self heating of the whole sensor when WiFi is activated a relatively large temperature offset of 13°C is applied automatically when WiFi is active. Without WiFi only a 4.4°C offset is applied. On Battery the offset is only 0.8°C. https://github.com/davidkreidler/OpenCO2_Sensor/blob/main/OpenCO2_Sensor.ino#L174

Since this self heating takes some time the temperature and humility values might be off after a cold start. If you know any possibility to decrease the power consumption of the ESP32 using WiFi as a client, I would appreciate the help. Switching to matter or esphome might improve this. But with less convenience access to the values and the initial WiFi setup.

saviola777 commented 4 months ago

Awesome, thank you! Works like a charm. I guess it makes sense with the heat, I did not think about that at all.

I had it running overnight on battery and it showed 16°C and 10% humidity this morning (real values were closer to 26.5°C and 60%, unfortunately). Maybe that was also related to the offset somehow? But I'm planning to have it run on power constantly anyway (connected to the USB port of my FritzBox), or would you recommend against that because of power usage?

While powered, the temperature seems to be off by about -1°C, humidity by +5% (if I can trust the readings of this other sensor which I'm not sure about), which is within an acceptable range (and something I could manually fix by changing the offset in the code once I figure out how to build the firmware myself).

I suppose I could disable WiFi, but I really like that clock. :smile:

davidkreidler commented 4 months ago

As I understand you had it on Battery over night and then plugged it in? Then the temperature was then lower then expected. If yes, this is exactly what the offset causes. Its applied instantly but the device was not heated up jet.

The specs for accuracy are: Temperature ±0.8°C Humidity ±6%

Instructions for setup the programming Environment can be found here: https://github.com/davidkreidler/OpenCO2_Sensor?tab=readme-ov-file#installation-inside-the-arduino-ide

Running it plugged in to your fritzbox is totally fine. Power consumption is about 0,1 Watt or while charging up to 3 Watt. For long long term usage like this you could think about charging the battery to around 60% and then unplugging it.

saviola777 commented 3 months ago

As a small addendum: I tested it without WiFi and the values for both temperature and humidity are now exactly the same as on my other sensors. I guess the offsets for WiFi don't work in all situations (for me it was always temperature 0.8-1.0° too low and humidity 4-5% too low), or maybe it needs a linear offset depending on measured values, I don't know.

I decided to give up on the clock for now and run without WiFi, maybe one day I'll set up a development environment and tinker with different offsets.

davidkreidler commented 3 months ago

Hey @saviola777 thanks for the follow up. I did a deep dive and build a debug firmware that shows the applied offset in the Menu -> Info point. By doing this I found a but that was introduced in v4.6 with the faster wifi response time. The change from usb power mode to battery mode lead to a case where the offset was not applied because comingFromDeepSleep was set incorrectly (because there was no new measurement value after 500ms).

Fix: image

Now the offset is correctly applied when going into Batery mode.

Also compared the temperature while using wifi and you are correct. Compared to a reference device I could see a about 0.8°C difference. Likely root cause of the lower offset requirement is that I switched from 240MHz to 80MHz mode. The new offset will be allied in the next release: image

Thank you for pointing out these bugs! Here is a preview: https://drive.google.com/file/d/1StSAuJfoRrM6ONd-Y4JslkN3VltMClaX/view?usp=sharing

saviola777 commented 3 months ago

Awesome, thanks! Temperature now within 0.3 of the other sensor which is great. Humidity is off by 6% (too high), do you have an explanation for that? Does the sensor use the measured temperature to determine the humidity or something which leads to wrong values with the WiFi heat? Do we need an offset here as well?

It's not a big deal of course, and it's also possible my other sensor is wrong, but without WiFi the humidity readings were within 1% from the other sensor.

davidkreidler commented 3 months ago

The claimed accuracy of the scd40 sensor by sensirion is +-6% for humidity. So this would be within spec. Inside the scd40 itself it's only possible to set a temperature offset it also affects the calculation for the humidity.

Hope this helps! David

saviola777 commented 3 months ago

Yeah that's fine. I just find it weird that it's always exactly +4-6% above my other sensor when on WiFi and within +-1% of the other sensor when without WiFi. I guess it would be simple to alter the recorded/displayed humidity reported by the sensor depending on the WiFi status, maybe I'll try to make that change.

davidkreidler commented 3 months ago

Go for it! If you need help please ask.