feature-requests
feature-requests copied to clipboard
Add forced calibration to the SCD30
Describe the problem you have/What new integration you would like Add forced calibration to the SCD30
Please describe your use case for this integration and alternatives you've tried: Forced calibration is needed for indoor environments.
Additional context This has already been implemented for SCD4X (https://esphome.io/components/sensor/scd4x.html#perform-forced-calibration-action)
Previous attempts:
- https://github.com/esphome/esphome/pull/1237
- https://github.com/esphome/esphome/pull/1402
- https://github.com/esphome/esphome/pull/1561
Any updates on it? I'm also looking forward to this functionality
I'm making another attempt at this. I haven't opened a PR yet, but will after I do some more testing. If anyone else would like to try it:
https://github.com/bekriebel/esphome/tree/scd30_force_calibration_with_reference
external_components:
- source: github://bekriebel/esphome@scd30_force_calibration_with_reference
components: [ scd30 ]
You can then call it as an action. Personally, I tied it to a button for now; this could easily be made into a Home Assistant service:
binary_sensor:
- platform: gpio
pin:
number: 38
inverted: true
name: "$friendly_name Button"
on_press:
then:
- scd30.force_recalibration_with_reference:
value: 419
@bekriebel Would you be willing to help me test this? I have successfully loaded the external component but struggle to force a recalibration.
I run the SCD30 on a ESP8266 and am unsure which in number I need to choose.
Thanks a lot!
@WinstonCh I'm not quite sure what you need help with. If it helps, this is my sensor entry in my esphome config:
substitutions:
# Name the device and it's entities
device_name: "test-air-quality"
friendly_name: Test Air Quality
sensor:
# Air quality sensor
- platform: scd30
id: sensor_scd30
co2:
name: "$friendly_name CO2"
id: scd30_co2
accuracy_decimals: 0
filters:
- filter_out: 0.0
- filter_out: 40000.0
temperature:
name: "$friendly_name Temperature"
accuracy_decimals: 2
humidity:
name: "$friendly_name Humidity"
accuracy_decimals: 1
automatic_self_calibration: false
altitude_compensation: 100m
update_interval: 60s
@bekriebel I got it. This is about utilising a physical button on the board. My bad! Thanks for your input! Much appreciated.
Hi @bekriebel I've also tested this on a few sensors and the results look good. Something that is not obvious and worth mentioning as others might get confused: The FRC method imposes a permanent update of the CO2 calibration curve which persists after repowering the sensor. The most recently used reference value is retained in volatile memory and can be read out with the command sequence given below. After repowering the sensor, the command will return the standard reference value of 400 ppm. https://sensirion.com/resource/user_guide/scd30/interface_description
Would love to see your code merged :)
Hi @bekriebel thank you for the change!
I didn't have a physical button available, so I created a HA service you can call with a parameter:
api:
services:
- service: recalibrate_scdx_co2
variables:
actual_co2: int
then:
- scd30.force_recalibration_with_reference:
value: !lambda 'return actual_co2;'
Works flawlessly.
I get a linking error when I try to add this external component with the service on a raspberry pico device. It builds fine if I leave out the service (though I don't have a button). For an ESP32, it seems to build fine with a service.
/data/cache/platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld: /data/air-test/.pioenvs/air-test/src/main.cpp.o: in function `_ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE':
main.cpp:(.text._ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE[_ZN7esphome3api15UserServiceBaseIJlEE15execute_serviceERKNS0_21ExecuteServiceRequestE]+0x216): undefined reference to `_ZN7esphome3api21get_execute_arg_valueIlEET_RKNS0_22ExecuteServiceArgumentE'
/data/cache/platformio/packages/toolchain-rp2040-earlephilhower/bin/../lib/gcc/arm-none-eabi/10.3.0/../../../../arm-none-eabi/bin/ld: /data/air-test/.pioenvs/air-test/src/main.cpp.o: in function `_ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv':
main.cpp:(.text._ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv[_ZN7esphome3api15UserServiceBaseIJlEE28encode_list_service_responseEv]+0x2a): undefined reference to `_ZN7esphome3api19to_service_arg_typeIlEENS0_5enums14ServiceArgTypeEv'
collect2: error: ld returned 1 exit status
*** [/data/air-test/.pioenvs/air-test/firmware.elf] Error 1
Any help needed to get this merged? I would also love this functionality added.
https://github.com/esphome/esphome/pull/4362
I took the changes and integrated them into a fresh fork. It seems the original fork is already too far behind the actual tree. I also made a PR and updated the documentation for the module. Lets see when it will be merged into the dev branch.