SCD30 - CO2 sensor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Persuasiv
Normal user
Posts: 2
Joined: 15 Jun 2019, 15:10

SCD30 - CO2 sensor

#1 Post by Persuasiv » 15 Jun 2019, 15:15

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

_petronie_
Normal user
Posts: 12
Joined: 15 Feb 2018, 23:46

Re: SCD30 - CO2 sensor

#2 Post by _petronie_ » 23 Jun 2019, 21:25

Hi,
code is ready and should be visible in dev - just not a part of official release :(. P.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: SCD30 - CO2 sensor

#3 Post by grovkillen » 23 Jun 2019, 22:12

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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

_petronie_
Normal user
Posts: 12
Joined: 15 Feb 2018, 23:46

Re: SCD30 - CO2 sensor

#4 Post by _petronie_ » 01 Aug 2019, 00:03

.. push request done by my friend with updated driver version. P.


Persuasiv
Normal user
Posts: 2
Joined: 15 Jun 2019, 15:10

Re: SCD30 - CO2 sensor

#6 Post by Persuasiv » 04 Aug 2019, 21:42

Thanks!

Eddy1983
Normal user
Posts: 1
Joined: 11 Aug 2020, 20:12

Re: SCD30 - CO2 sensor

#7 Post by Eddy1983 » 11 Aug 2020, 20:16

Hi all,

are there any news about implementing SCD30 sensor?

Thanks for your support.

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#8 Post by TD-er » 11 Aug 2020, 21:24

I don't have such a sensor, so no update from me.

Smotek7
Normal user
Posts: 28
Joined: 01 Aug 2020, 16:18
Location: SK

Re: SCD30 - CO2 sensor

#9 Post by Smotek7 » 20 Jan 2021, 08:33

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

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#10 Post by Ath » 20 Jan 2021, 10:02

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;
/Ton

Smotek7
Normal user
Posts: 28
Joined: 01 Aug 2020, 16:18
Location: SK

Re: SCD30 - CO2 sensor

#11 Post by Smotek7 » 20 Jan 2021, 18:07

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.

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#12 Post by TD-er » 20 Jan 2021, 18:09

Change

Code: Select all

SendStatus(event->Source, log);
into

Code: Select all

SendStatus(event, log);

Patou
Normal user
Posts: 87
Joined: 21 May 2018, 10:33

Re: SCD30 - CO2 sensor

#13 Post by Patou » 26 Mar 2021, 17:13

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

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#14 Post by TD-er » 26 Mar 2021, 18:37

I made an issue for it so it won't be forgotten: https://github.com/letscontrolit/ESPEasy/issues/3558

Patou
Normal user
Posts: 87
Joined: 21 May 2018, 10:33

Re: SCD30 - CO2 sensor

#15 Post by Patou » 26 Mar 2021, 21:10

Thanks i can wait a little for this project

jbarea
Normal user
Posts: 8
Joined: 24 Jun 2021, 00:21

Re: SCD30 - CO2 sensor

#16 Post by jbarea » 18 Aug 2021, 03:56

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.

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#17 Post by TD-er » 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.

jbarea
Normal user
Posts: 8
Joined: 24 Jun 2021, 00:21

Re: SCD30 - CO2 sensor

#18 Post by jbarea » 18 Aug 2021, 15:53

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.

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#19 Post by Ath » 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.
/Ton

jbarea
Normal user
Posts: 8
Joined: 24 Jun 2021, 00:21

Re: SCD30 - CO2 sensor

#20 Post by jbarea » 18 Aug 2021, 16:27

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.

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#21 Post by TD-er » 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().

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#22 Post by TD-er » 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

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#23 Post by TD-er » 19 Aug 2021, 01:31

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.

jbarea
Normal user
Posts: 8
Joined: 24 Jun 2021, 00:21

Re: SCD30 - CO2 sensor

#24 Post by jbarea » 19 Aug 2021, 05:15

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.

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#25 Post by TD-er » 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...)

jbarea
Normal user
Posts: 8
Joined: 24 Jun 2021, 00:21

Re: SCD30 - CO2 sensor

#26 Post by jbarea » 20 Aug 2021, 19:52

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.
Attachments
screenshot about i2c in scd30 sensor
screenshot about i2c in scd30 sensor
scd30_i2c.png (72.36 KiB) Viewed 3661 times

TD-er
Core team member
Posts: 5527
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SCD30 - CO2 sensor

#27 Post by TD-er » 20 Aug 2021, 23:50

So, that's a slow sensor.

bastler11
Normal user
Posts: 39
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: SCD30 - CO2 sensor

#28 Post by bastler11 » 15 Sep 2021, 23:13

Hello,

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

Thanks and best regards.

bastler11
Normal user
Posts: 39
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: SCD30 - CO2 sensor

#29 Post by bastler11 » 24 Sep 2021, 07:35

Hello,

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

Thanks and best regards.

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#30 Post by Ath » 24 Sep 2021, 08:49

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.
/Ton

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#31 Post by Ath » 24 Sep 2021, 21:43

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 29 times
If you need another build type, like a 4M2M or 1M build, just ask for it.
/Ton

bastler11
Normal user
Posts: 39
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: SCD30 - CO2 sensor

#32 Post by bastler11 » 25 Sep 2021, 09:30

:) 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!

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#33 Post by Ath » 25 Sep 2021, 17:42

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
/Ton

bastler11
Normal user
Posts: 39
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: SCD30 - CO2 sensor

#34 Post by bastler11 » 30 Sep 2021, 16:35

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.

User avatar
Ath
Normal user
Posts: 1163
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SCD30 - CO2 sensor

#35 Post by Ath » 30 Sep 2021, 22:08

Thanks for the feedback, I'll update the manual in the coming days or next week.
/Ton

Smotek7
Normal user
Posts: 28
Joined: 01 Aug 2020, 16:18
Location: SK

Re: SCD30 - CO2 sensor

#36 Post by Smotek7 » 20 Oct 2021, 17:02

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

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 30 guests