Page 1 of 3

SCD30 - CO2 sensor

Posted: 15 Jun 2019, 15:15
by Persuasiv
hey,

would be great, if you could support the SCD30 in one of the future releases. The Arduino Library can be found here:

https://github.com/sparkfun/SparkFun_SC ... no_Library
https://cdn.sparkfun.com/assets/1/a/7/9 ... asheet.pdf
https://www.sparkfun.com/products/15112

The sensor works great and is very precise ...

cheers

Re: SCD30 - CO2 sensor

Posted: 23 Jun 2019, 21:25
by _petronie_
Hi,
code is ready and should be visible in dev - just not a part of official release :(. P.

Re: SCD30 - CO2 sensor

Posted: 23 Jun 2019, 22:12
by grovkillen
I haven't seen any PR so it's not part of any official code from us. The developer need to add a push request.

Re: SCD30 - CO2 sensor

Posted: 01 Aug 2019, 00:03
by _petronie_
.. push request done by my friend with updated driver version. P.

Re: SCD30 - CO2 sensor

Posted: 01 Aug 2019, 00:05
by _petronie_

Re: SCD30 - CO2 sensor

Posted: 04 Aug 2019, 21:42
by Persuasiv
Thanks!

Re: SCD30 - CO2 sensor

Posted: 11 Aug 2020, 20:16
by Eddy1983
Hi all,

are there any news about implementing SCD30 sensor?

Thanks for your support.

Re: SCD30 - CO2 sensor

Posted: 11 Aug 2020, 21:24
by TD-er
I don't have such a sensor, so no update from me.

Re: SCD30 - CO2 sensor

Posted: 20 Jan 2021, 08:33
by Smotek7
Hello,
I find in some current .bin sensor SCD30.
I watched DEV
ESP_Easy_mega_20201130_dev_ESP8266_4M1M
but he's not there.
Do I have to do my own compilation?
Thank you

Re: SCD30 - CO2 sensor

Posted: 20 Jan 2021, 10:02
by Ath
Plugin is only available in the PluginPlayground, so not in the main repo (mega) yet.
If you need it now, then a self-compilation is the only way (clone the mega repo and copy in the extra file from the PluginPlayground, and possibly the library files).
The plugin needs only minor adjustments, though it is looking quite good, it should have this line changed:

Code: Select all

Device[deviceCount].VType = SENSOR_TYPE_QUAD;
into:

Code: Select all

Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_QUAD;

Re: SCD30 - CO2 sensor

Posted: 20 Jan 2021, 18:07
by Smotek7
Thank you for the info.
I have a problem compiling on the line:

In function 'boolean Plugin_178(byte, EventStruct*, String&)':
_P178_SCD30:163: error: cannot convert 'EventValueSource::Enum' to 'EventStruct*' for argument '1' to 'void SendStatus(EventStruct*, const String&)'
SendStatus(event->Source, log);
exit status 1
cannot convert 'EventValueSource::Enum' to 'EventStruct*' for argument '1' to 'void SendStatus(EventStruct*, const String&)'

if I comment out the line, the compilation works.
The sensor will not arrive until tomorrow, then I will test it.

Re: SCD30 - CO2 sensor

Posted: 20 Jan 2021, 18:09
by TD-er
Change

Code: Select all

SendStatus(event->Source, log);
into

Code: Select all

SendStatus(event, log);

Re: SCD30 - CO2 sensor

Posted: 26 Mar 2021, 17:13
by Patou
Hello
I am interested in the integration of this sensor but i am not clever enough to make my own bin file
Can someone send a bin file for 4 Mb esp that include this sensor
Many thanks in advance

Patou

Re: SCD30 - CO2 sensor

Posted: 26 Mar 2021, 18:37
by TD-er
I made an issue for it so it won't be forgotten: https://github.com/letscontrolit/ESPEasy/issues/3558

Re: SCD30 - CO2 sensor

Posted: 26 Mar 2021, 21:10
by Patou
Thanks i can wait a little for this project

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 03:56
by jbarea
Hi all,

I have been using the plugin P178 from playground successfully with the SCD30 sensor (https://es.aliexpress.com/item/1005001392172293.html) to monitor CO2 levels. I could compile with the version mega-20210503 of espeasy. The readings follow the readings of a Senseair S8 very well. Also I modified the plugin to include some functionalities such as the forced calibration to 400 ppm using new commands. All the testings were done using a ESP8266 board. However I couldn't compile the firmware for ESP32. This happens because the file twi.h used for the compilation in ESP8266 is absent in the case of ESP32. I make some research to figure out the reason. Finally I found that ESP32 does not support clock stretching in the I2C bus, as ESP8266 does. The plugin P178 is based in a library from Frogmore where ESP8266 is only supported. However there is another library, https://github.com/paulvha/scd30, which support ESP8266 and ESP32 because it includes a "sub library" called SoftWire which emulates the Wire library from ESP8266 and includes clockstretching when ESP32 is chosen as destination board.

I think it is a good idea to include this library SoftWire in espeasy because it would provide I2C clockstretching for ESP32 and many I2C sensors would benefit from this. I can try to adapt the plugin P178 to use the paulvha library instead of frogmore library, but that would work only if SoftWire is included in the Espeasy Framework, since Wire.begin is called at that level. I don't feel with the knowledge to code at that level. Well, actually, I neither know if this is the right place to point out all this staff or I should open a new topic or even a issue in github.com/letscontrolit/Espeasy. I just hope this info is useful.

Jose.

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 12:22
by TD-er
Sorry I had not yet time to reply to your email about this...
I am a bit reluctant to include a new library for I2C as I am quite sure it will conflict with the existing I2C.
So if we need it because of the availability of clock stretch, then it must be the main (and only) I2C handling.

ESP32 does have 2 hardware I2C interfaces, so perhaps it is possible to split it and thus add some 'virtual' I2C selection, just like we did with the multiplexer.
However this is a HUGE change with very likely stability issues.
So I think it best to include support for this sensor in stages.
First as "ESP8266 only" and then have a proper look at how to add clock stretching to ESP32.
Maybe when using a later ESP IDF version, we already have access to this.

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 15:53
by jbarea
TD-er wrote: 18 Aug 2021, 12:22 Sorry I had not yet time to reply to your email about this...
I am a bit reluctant to include a new library for I2C as I am quite sure it will conflict with the existing I2C.
So if we need it because of the availability of clock stretch, then it must be the main (and only) I2C handling.

ESP32 does have 2 hardware I2C interfaces, so perhaps it is possible to split it and thus add some 'virtual' I2C selection, just like we did with the multiplexer.
However this is a HUGE change with very likely stability issues.
So I think it best to include support for this sensor in stages.
First as "ESP8266 only" and then have a proper look at how to add clock stretching to ESP32.
Maybe when using a later ESP IDF version, we already have access to this.
Thanks for your answer. The two hardware interfaces is a good advantage. Are both activated in the main code of espeasy, or just one of them?
If only one is activated, the other one may be activated directly from the call to the sensor, using of course other gpios different from 21 and 22 for SDA and SCL.
Do you think if it is feasible? I am thinking in something which would not affect the functionality of the rest of espeasy, something just restricted to this sensor, and its plugin, of course.

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 16:20
by Ath
If we are going to support the second I2C channel, I'm in favor of adding it fully supported to the generic ESPEasy code, so 1 channel can be High Speed and another Low Speed, f.e. And they would both need separate Clock stretch settings too, once that is supported for ESP32 ;)
Having this type of specific hardware support, not directly related to the hardware to connect, in a plugin looks like overkill, or 'Doing It The Wrong Way', to me, ditto for a different I2C library.

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 16:27
by jbarea
Ath wrote: 18 Aug 2021, 16:20 If we are going to support the second I2C channel, I'm in favor of adding it fully supported to the generic ESPEasy code, so 1 channel can be High Speed and another Low Speed, f.e. And they would both need separate Clock stretch settings too, once that is supported for ESP32 ;)
Having this type of specific hardware support, not directly related to the hardware to connect, in a plugin looks like overkill, or 'Doing It The Wrong Way', to me, ditto for a different I2C library.
I agree completely with you, it should not be restricted to a particular sensor, my proposal was just for testing if the idea works. I am very newbie on this area and many things escape from me.

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 18:32
by TD-er
Not sure if that library supports to select "the other" I2C bus. (I don't know it either, have to look into that myself)
But like I said, maybe a later ESP IDF already has support for clock stretching and if so, that's a preferred route IMHO.
Or maybe the current IDF already supports it, but its calls to set it are not yet present in the Arduino layer.
So then we can just add it ourselves by setting the clock stretch right after we call Wire.begin().

Re: SCD30 - CO2 sensor

Posted: 18 Aug 2021, 23:45
by TD-er
I read a bit more about the I2C clock stretch for ESP32.
And it doesn't look promising.

https://github.com/espressif/esp-idf/is ... -495970657

In other words, you can set some timeout to about 13 msec, but if that's exceeded the transaction is aborted in hardware.
So some clock stretching is possible without a new library, but if your library allows for longer, I guess that library will implement I2C in software.

See also the documentation to set the timeout: https://docs.espressif.com/projects/esp ... 2c_port_ti

Re: SCD30 - CO2 sensor

Posted: 19 Aug 2021, 01:31
by TD-er
The lack of clock stretching is done here by simply waiting after each write:
https://github.com/pantaluna/esp32_scd3 ... #L266-L338
So I guess we should either add a clock stretch per device, or maybe even introduce a new "device" type like I2C_ClockStretched, as the strech is rather device specific.

Re: SCD30 - CO2 sensor

Posted: 19 Aug 2021, 05:15
by jbarea
TD-er wrote: 18 Aug 2021, 18:32 Not sure if that library supports to select "the other" I2C bus. (I don't know it either, have to look into that myself)
But like I said, maybe a later ESP IDF already has support for clock stretching and if so, that's a preferred route IMHO.
Or maybe the current IDF already supports it, but its calls to set it are not yet present in the Arduino layer.
So then we can just add it ourselves by setting the clock stretch right after we call Wire.begin().
I took a look and it uses the gpios 21 and 22. I don't know if both I2C buses uses the same gpios. It makes sense to me to use different gpios. In https://github.com/espressif/esp-idf/issues/4173 they mention that ESP32S2 could support clock stretching.
TD-er wrote: 18 Aug 2021, 23:45 I read a bit more about the I2C clock stretch for ESP32.
And it doesn't look promising.

https://github.com/espressif/esp-idf/is ... -495970657

In other words, you can set some timeout to about 13 msec, but if that's exceeded the transaction is aborted in hardware.
So some clock stretching is possible without a new library, but if your library allows for longer, I guess that library will implement I2C in software.

See also the documentation to set the timeout: https://docs.espressif.com/projects/esp ... 2c_port_ti
Yeap, as far as I could see, the SoftWire library included in the paulvha's SCD30 library implements clock stretching via software and it is selected 200ms by default. The 13 ms is not good enough at least for the SCD30, which may be require 150 ms due to internal calibration processes.

Re: SCD30 - CO2 sensor

Posted: 19 Aug 2021, 21:40
by TD-er
Well... 150 msec clock stretching is not good for ESPEasy.
How often does this happen?

And about the GPIO pins on an ESP32.
With some exceptions, you can connect almost any function to almost any pin.
So based on the pin nr you cannot tell what I2C bus it is. (or whether it is an I2C bus...)

Re: SCD30 - CO2 sensor

Posted: 20 Aug 2021, 19:52
by jbarea
TD-er wrote: 19 Aug 2021, 21:40 Well... 150 msec clock stretching is not good for ESPEasy.
How often does this happen?

And about the GPIO pins on an ESP32.
With some exceptions, you can connect almost any function to almost any pin.
So based on the pin nr you cannot tell what I2C bus it is. (or whether it is an I2C bus...)
[/
150 ms once per day and 30 ms in the reading/writing frames as is stated in the SCD30 interface description.

Re: SCD30 - CO2 sensor

Posted: 20 Aug 2021, 23:50
by TD-er
So, that's a slow sensor.

Re: SCD30 - CO2 sensor

Posted: 15 Sep 2021, 23:13
by bastler11
Hello,

is it possible to download the prepared espeasy image for esp8266 ?

Thanks and best regards.

Re: SCD30 - CO2 sensor

Posted: 24 Sep 2021, 07:35
by bastler11
Hello,

I want to use the scd30 together with an esp8266. Which actual image could I use?

Thanks and best regards.

Re: SCD30 - CO2 sensor

Posted: 24 Sep 2021, 08:49
by Ath
There is a plugin available in the ESPEasyPluginPlayground, but that hasn't been updated recently (~2 years ago), and is not (yet) integrated into the main ESPEasy repository.

Only current solution is to a) get the latest ESPEasy sources, b) add that plugin (and it's accompanying library) from the Playground, c) fix the issues it will throw at compilation of the current plugin-source, and after a successful build d) test it on your hardware.

Re: SCD30 - CO2 sensor

Posted: 24 Sep 2021, 21:43
by Ath
Not sure if you can get that build process going, so I've done the steps I wrote earlier.
Here is a custom build with the SCD30 plugin from ESPEasyPluginPlayground included:
ESP_Easy_mega_20210924_custom_ESP8266_4M1M.zip
(557.19 KiB) Downloaded 438 times
If you need another build type, like a 4M2M or 1M build, just ask for it.

Re: SCD30 - CO2 sensor

Posted: 25 Sep 2021, 09:30
by bastler11
:) wow, thank you very much! You are right, I'm in the moment not able to build the image, but I think I have to learn it :-). I will test your image!

Best regards!

Re: SCD30 - CO2 sensor

Posted: 25 Sep 2021, 17:42
by Ath
bastler11 wrote: 25 Sep 2021, 09:30 :) wow, thank you very much!
You're welcome :)
bastler11 wrote: 25 Sep 2021, 09:30 You are right, I'm in the moment not able to build the image, but I think I have to learn it :-).
I'm working on a How To guide, it's available as a (preliminary) pdf in this PR #3784, to make it part of the normal ESPEasy documentation at Read The Docs

Re: SCD30 - CO2 sensor

Posted: 30 Sep 2021, 16:35
by bastler11
Thanks for this information! I had just a look on it. Several parts I could understand bus several not :roll:

If I could wish for something:

A story with text and pictures described on a specific task

1. Describe the problem -> here: how could I build an image with the SCD30 sensor
2. What is necessary and were to find
3. Steps with pictures what is to do
4. The result

I know that is not easy and somebody like you looks on all may be very different like me :D . But it could help to arrive also people who are in the beginning :). One more idea: A red line on which I could go and I could also go back. So if I do not understand any thing, I could ask and tell the concrete place.

Re: SCD30 - CO2 sensor

Posted: 30 Sep 2021, 22:08
by Ath
Thanks for the feedback, I'll update the manual in the coming days or next week.

Re: SCD30 - CO2 sensor

Posted: 20 Oct 2021, 17:02
by Smotek7
Ath
I need advice
I had my FW scd30, which I can't find.
Therefore, I use the above but do not read the values with scd30.
Have you tested the compilation?
I also uploaded it to my tested HW and it also doesn't read values.
Can the compilation not work?

Board Lolin V3

Re: SCD30 - CO2 sensor

Posted: 20 Nov 2021, 15:00
by Ath
Smotek7 wrote: 20 Oct 2021, 17:02 Board Lolin V3
Hi Smotek7,

I've created a pull request in ESPEasy repository, PR #3854

Here's a testbuild from that code:
ESP_Easy_mega_20211120_custom_ESP8266_4M1M.zip
(558.89 KiB) Downloaded 411 times
And a screenshot of the available settings.
P117_DeviceConfiguration.png
P117_DeviceConfiguration.png (43.07 KiB) Viewed 92838 times

Re: SCD30 - CO2 sensor

Posted: 20 Nov 2021, 16:03
by Smotek7
@Ath
I confirm that this version works for me.

Re: SCD30 - CO2 sensor

Posted: 20 Nov 2021, 16:16
by Ath
Great, thank you very much for testing! :)

Re: SCD30 - CO2 sensor

Posted: 24 Dec 2021, 15:44
by Ath
Smotek7 wrote: 20 Nov 2021, 16:03 @Ath
I confirm that this version works for me.
The plugin has been included in the release, available here

Re: SCD30 - CO2 sensor

Posted: 07 Feb 2022, 16:45
by Mecha
Hi, thank you for your work!
I downloaded the last release, but i can't find the SCD30 Sensor. I am just able to see the Senseair and Winsen sensors. The image i used is the "ESP_Easy_mega_20211224_normal_ESP8266_4M1M.bin". Am i doing something wrong?

Re: SCD30 - CO2 sensor

Posted: 07 Feb 2022, 16:58
by Smotek7
Try the test_D version.
I have her in one sensor.

Re: SCD30 - CO2 sensor

Posted: 07 Feb 2022, 17:01
by Ath
As said: You will need to install the test_d build, as that has the SDC30 plugin included.

See the Plugins page for plugins and the build(s) they are included in. NB: The test/testing builds also have the normal set of plugins included, but a few functions disabled to make it all fit.

Re: SCD30 - CO2 sensor

Posted: 08 Feb 2022, 14:32
by Mecha
It works! Thank you very much!

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 02:25
by Mecha
Hi again,
is there a way to activate automatic self calibration in ESP Easy? In the plughin there is a command to check "Show automatic calibration period in days" which seems to be turned off (0) by default. But i can't find a way to change it.

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 10:21
by Ath
I'll investigate what has to be done, and how to do it, and if all succeeds, create a PR to enable self-calibration.

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 10:25
by Smotek7
You must enter in the browser
http://IP/control?cmd=scdgetabc
It displays the status.
But I don't know how to start FRC and ASC calibration.
I would like to know that.

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 10:33
by Smotek7
I've been following 3 new sensors for about a month:
Interior / exterior (located 10cm apart)
S1 920/489
S2 859/370
S3 1029/541
I have 2 pieces which in the interiors at 800ppm showed 1390 and 2000ppm.
All one batch from the supplier.

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 13:29
by Ath
I've added an 'Automatic Calibration' checkbox to the device configuration, and commands 'scdsetcalibration' for changing the calibration mode and 'scdsetfrc' for setting a forced recalibration value.

PR #3965

Help with testing requested, as I don't own this type of sensor ;)

You can download the .bin files from the Github Actions page, once the build has completed.

Re: SCD30 - CO2 sensor

Posted: 26 Feb 2022, 13:52
by Smotek7
If I understood correctly, automatic calibration takes at least 5 days.
I'm waiting to upload. It goes gradually ...
I'll test it on one sensor.
You can also add a command
setForcedRecalibrationFactor
setManualCalibration
And when changes are made it wouldn't be bad either
setMeasurementInterval