SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By tipo1000
#199671
Has somebody been able to get SCD30 to work with ESP8266?

I can find SCD30 with I2C scanner but Sparkfun SCD30 library/example doesn't connect with SCD30.
It just prints ....... as it's trying to connect.

Thanks,
Timo
By caplanda
#199673
Hi,

I'm having the same problem. I get the exact same ............ using both I2C ports on a Due, and the Qwiic port on a BlackBoard. I added some println()'s into the Sparkfun library code, and found that the sensor doesn't Ack (or at least that's what the comments in the library say). I've also tried another library, which also does not work. Has anyone solved this problem yet?

Thanks!
By paulvha
#199675
I have ordered an SCD30 and had the first look at the driver.

How did you connect the SCD30? is VDD 5V or 3.3v ? Is the SEL VDD or GND/floating ?
When you state it just trying to connect? which sketch do you use and what do you see ?
By caplanda
#199678
I also ordered another SCD30 sensor, with the hope that maybe the first one is faulty. They're very sensitive to static discharge, so perhaps I damaged mine despite my precautions. I'll find out and post if the second one works when I receive it in a couple days.
paulvha wrote: Mon Jul 09, 2018 12:50 pm How did you connect the SCD30? is VDD 5V or 3.3v ? Is the SEL VDD or GND/floating ?
I tried both 3.3 and 5V. I believe the datasheet says the sensor runs on 3.5 to 5.5 V, so my preference was to use 5V. I left SEL floating. Connecting SEL to VDD causes the sensor to communicate using modbus instead of I2C.
paulvha wrote: Mon Jul 09, 2018 12:50 pm When you state it just trying to connect? which sketch do you use and what do you see ?
I can't speak for Timo, but I was using Example_2_SetOptions. I believe it printed something like the following:

SCD30 Example
Getting measurements ............................................................................ (just keeps adding dots...)

It would do this regardless of whether the sensor was physically connected or not. Like Timo, I was able to find the sensor with I2C_scanner when it was connected.

PS: Timo, I don't mean to hijack your thread but it seems like we have a very similar problem so hopefully we will both get our answers at the same time!
By tipo1000
#199681
VDD in my ESP8266 board is 3.3V and that's connected to SCD30.
SEL is floating.
I have tried two SCD30's. Neither of them works.

Both Sparkfun example sketches (Example1_BasicReadings, Example2_SetOptions) give the same result: they can't connect with SCD30.
The problem has to be somewhere in the library. I'm not experienced enough to debug that.
Sparkfun should take a look at their SCD30 library.
By paulvha
#199682
Indeed SEL should be floating to GND for I2C (I would tie to ground just to be sure.)

Not sure that the ESP8266 I2C is running at 100Khz max (higher is not supported by scd30). Just to make sure in the sketch after Wire.begin() do a call Wire.setClock(100000L);

The SCD30 is set to continues reading with the Airsensor.begin() call and 2 seconds interval and it will set the setAutoSelfCalibration(true); When this setAutoSelfCalibration is run the first time one should leave the scd30 sensor running for 7 days, with atleast 1 hour in fresh air (?) every day, to do self calibration.The result of self calibration is of course better results. Not sure what the impact is when trying to read the data at the same time. In the sketch after calling Airsensor.begin() call, try to include airsensor.setAutoSelfCalibration(false) to stop the calibration.

If you get continuous dots or "no data" then apparently the issue related to dataAvailable() call, which reads the SCD30 data-ready-register to indicate new sample is available. However it reads 2 bytes only, while it gets 3 ( 2 bytes data MSB/LSB + CRC). That CRC is not read and not used. Not sure whether that has any impact of not reading. One could try to comment out the dataAvailable() check in the sketch and try to do a read anyway to see what happens

last but not least : I do not know whether ESP8266 supports I2C clock stretching. This is part of the I2C protocol to allow a slower I2C slave device to hold the line a bit longer allowing more time to respond. According to the data-sheet this is a MUST have for the master to support as "Clock stretching period in write- and read-
frames is 12 ms, however, due to internal calibration processes a maximal clock stretching of 150 ms may occur once per day". One could try to reduce the I2C speed every more with experimenting with the Wire.setClock call: like Wire.setClock(70000L) for 70Khz or even lower.

let me know if anything worked..

regards,
Paul
By tipo1000
#199690
- Connected SEL to GND, didn't help.
- ESP8266 I2C is running at 100kHz. I tried to slow it down to 70kHz. No help.
- Set airsensor.setAutoSelfCalibration(false). No help
- Commented out the dataAvailable() check. No help
- Tried different Wire.setClockStretchLimit(200000) values from 1500 to 200000. No help.

The key observation was that (with or without the above changes) I2C communication with SCD30 happens only once when the system is powered up (USB connected to PC). After that there's nothing in SDA and SCL lines. See the attached pics about the communication (SDA yellow, SCL blue). They are about the same situation, the other pic is just zoomed in. The loop() keeps running though: no data or .... is updated to terminal.

https://ibb.co/nmh0z8
https://ibb.co/bWjKsT
By paulvha
#199691
Thanks. Sorry to hear it does not work yet and to bad I don't have my sensor yet to test it myself. Can't help more at this moment.

regards,
Paul
By paulvha
#199699
just one more...looking at the scope pictures I notice the I2C is working on 3.3V (as one would expect with ESP8266) ... try to set VDD to 3.3V instead of 5V OR maybe a level shifter is needed for the I2C lines. I was triggered by a different post about the scd30 : http://forum.arduino.cc/index.php?topic=555764.0 about a Duo. There is also different sample code reference there for an Arduino.

regards,
Paul
By tipo1000
#199700
What do you mean by setting VDD to 5V?
ESP8266 works with 3.3V and SCD30 spec says it works with 3.3-5V.

I would try the library mentioned in the arduino.cc thread but there doesn't seem to be a sample sketch. I don't know how to use the library....

Timo
By paulvha
#199701
I had mixed up your responds with that of caplanda (who indicated it is using the SCD30 at 5V). Agree the spec states 3.3 - 5V, and maybe the logic is then also expecting the I2C signal to be at the same level. However you are already using the SCD30 at 3v3. For the example sketch, maybe contact the writer of the library
regards,
Paul
By caplanda
#199720
Hi Timo,

I saw you have two sensors, but is it possible that they are both damaged? I think my first one was either faulty or I damaged it with a static discharge or something. I hear these sensors are extremely sensitive to static discharges. I received a second SCD30, and I took extreme precautions to keep any possible discharges from damaging the sensor (including putting electrical tape on my fingers when handling the sensor, as was recommended to me by someone that used to work with similar ones). I'm not certain if all that was necessary, but the second sensor worked fine with no modifications to the library or the example.

One other thing to look for: there is a rectangular spot of what looks like glue on the black IR housing. This spot lights up orange on my working sensor when it samples the CO2.

I hope this helps. Good luck!
By tipo1000
#199721
Does your damaged sensor get recognized with I2C scanner (eventhough it doesn't work with library)?

My both sensors have amber LED blinking.

Timo
By caplanda
#199722
Yes, my damaged sensor is detected by i2c scanner. I am guessing that the microprocessor portion is fine, but the detector is broken and so it never has data ready. The amber lights seem like a good sign that your sensors are not broken. I think you know about as much as I do, so I'm not sure if I'll be able to offer much else. Have you tried it with just an arduino uno?

Sensirion has library too, but you have to ask them for it. Check back to that other thread for more details.