RobTillaart / ACD10

Arduino library for the ACD10 CO2 sensor
MIT License
3 stars 0 forks source link

initial version #3

Closed RobTillaart closed 1 year ago

RobTillaart commented 1 year ago

remarks can be made here

fuzonmedia commented 1 year ago

getAddress() and isConnected() tested working fine so far image

RobTillaart commented 1 year ago

Looks good!

Current commit implements

please give those examples a try

fuzonmedia commented 1 year ago

here is the output

image

fuzonmedia commented 1 year ago

image

those 2 function looks good

RobTillaart commented 1 year ago

The readSensorCode functions should not be printed as HEX as it are chars and digits. I'll change the code.

The other works well.

RobTillaart commented 1 year ago

Changed the signature of the readSensorCode() function added the readSensor() function + some related. added a demo sketch how it can be used.

Please verify.

Still open is calibration, which will be later this week.

fuzonmedia commented 1 year ago

image

Seems the value does not looks OK. Do you agree ?

fuzonmedia commented 1 year ago

this may be useful to understand

image

RobTillaart commented 1 year ago

Seems the value does not looks OK. Do you agree ?

1400 CO2 can easily be true for an indoors level. Furthermore the sensor probably need calibration.

With other CO2 sensors it was needed to be 24++ hrs outside before it gave good readings.

The temperature around 13350 does not make sense to me. I will check the code and the datasheet.

RobTillaart commented 1 year ago

The readSensorCode now looks very informative. We're going in the right direction.

fuzonmedia commented 1 year ago

have you updated codebase ? Do you want me to test again ?

As per datasheet it says its pre calibrated . Do we need any manual calibration ? Or do you suggest you leave it power up for 24 hrs to make it calibrated ?

fuzonmedia commented 1 year ago

Do you understand why temperature looks odd ?

fuzonmedia commented 1 year ago

Also 1400 ppm Co2 in indoor is not very good result unless its due to calibration issue

RobTillaart commented 1 year ago

have you updated codebase ? Do you want me to test again ?

No, tomorrow I'll continue with this lib.

RobTillaart commented 1 year ago

As per datasheet it says its pre calibrated . Do we need any manual calibration ? Or do you suggest you leave it power up for 24 hrs to make it calibrated ?

The latter, datasheet states it calibrates after 24 hrs. After start. I assume it should be outside to have ~400 ppm

RobTillaart commented 1 year ago

Do you understand why temperature looks odd ?

No, not investigated yet. What is the temperature (approx).

RobTillaart commented 1 year ago

Also 1400 ppm Co2 in indoor is not very good result unless its due to calibration issue

It is high but not uncommon level for indoor.

fuzonmedia commented 1 year ago

Also 1400 ppm Co2 in indoor is not very good result unless its due to calibration issue

It is high but not uncommon level for indoor.

I understand but i tested it in a large room with myself only thats why i am worried its giving right value or it may sorted after 24hrs of continues run. Its true it does not ran 24 hrs yet after i started using that sensor

fuzonmedia commented 1 year ago

Tomorrow i will try outside & let you know the value.

fuzonmedia commented 1 year ago

Do you understand why temperature looks odd ?

No, not investigated yet.

What is the temperature (approx).

25 - 28 c

RobTillaart commented 1 year ago

To understand the CO2 concentration and temperature I also read the UART interface in the datasheet.

For I2C the CO2 math uses 4 bytes of the answer. For UART the CO2 math uses 2 bytes of the answer.

As the range support is 400-5000 one should say that 2 bytes is sufficient.

I saw that read temperature is not supported in the UART interface!
( table skips command 2, should that be a hidden / reserved one?)

I need to implement the CRC checking to see if the data fetched is correct. Will try to have a new version today.

RobTillaart commented 1 year ago

@fuzonmedia Hi, I uploaded a new version.

Can you please post the output of all the examples?

The ACD10.cpp file has some commented lines, these could provide more info about the data (CO2 and temperature).

First version of calibration functions included, but I did not review them yet (other tasks need attention). Also no example code for calibration exists.

RobTillaart commented 1 year ago

@fuzonmedia Send an email to aosong as some information is missing in the datasheet. About temperature scale and some differences between UART and I2C interface.

RobTillaart commented 1 year ago

@fuzonmedia Got your email and changed the interface of the library as 80 ms delay is an eternity for a microprocessor. Updated all examples to match the new insights.

Still no information about the temperature, although that could be good after 80 ms too. In fact it might be that only the temperature needs the 80 ms delay. Need to think how to find out.

RobTillaart commented 1 year ago

Can you post the output of the examples as TEXT (not as image) Parts can be useful for documentation.

fuzonmedia commented 1 year ago

Ok will do

fuzonmedia commented 1 year ago

Sorry for bit delay reply. I am outstation for few days due to holidays here.

RobTillaart commented 1 year ago

@fuzonmedia Any progress to report?

RobTillaart commented 1 year ago

@fuzonmedia I am going to release a 0.1.0 version so more people can provide feedback.

fuzonmedia commented 1 year ago

@RobTillaart Sorry for delay reply as I was traveling.

I tested the latest code but it gives some error during compile

image

fuzonmedia commented 1 year ago

21:33:21.219 -> /Users/nil/Downloads/ACD10-master/examples/ACD10_readSensorCode/ACD10_readSensorCode.ino 21:33:21.219 -> ACD10_LIB_VERSION: 0.1.0 21:33:21.219 -> FIRMWARE: AS V1.0.00 21:33:21.219 -> SENSORCODE: 0188152356

This one is working fine as expected

fuzonmedia commented 1 year ago

But read sensor one is showing compile error

RobTillaart commented 1 year ago

Remarkable as the build (continuous integration) compiles all examples.

Have you fetched the latest branch.

fuzonmedia commented 1 year ago

Yes I tried both 2 branch examples files. Both branch read sensor example shows same error. Can you please check the code again as this issue was not present in the earlier codebase

RobTillaart commented 1 year ago

For which board are you compiling

RobTillaart commented 1 year ago

The examples compile for 5 platforms in the build CI.

See: https://github.com/RobTillaart/ACD10/actions/runs/6419162887/job/17428429730

If your compiler cannot find requestSensor() you are somehow using the old version 0.1.0. Maybe your compiler cached it?

RobTillaart commented 1 year ago

Looking at the screenshot (Please copy TEXT not screenshots of errors) shows your 8266 environment cannot find some .h file.

fuzonmedia commented 1 year ago

@RobTillaart Sorry for delay reply as I was traveling.

I tested the latest code but it gives some error during compile

image

For this I used arduino Uno board

RobTillaart commented 1 year ago

You should download the develop 0.1.1 branch as the error indicates you are using the 0.1.0 master branch.

RobTillaart commented 1 year ago

@fuzonmedia Any progress to report?

RobTillaart commented 1 year ago

@fuzonmedia Merged and released 0.1.1 => update readme.md + some minor edits

fuzonmedia commented 1 year ago

I downloaded the latest release but its showing same error

image

fuzonmedia commented 1 year ago

Compiling sketch... /private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src -I/Users/nil/Documents/Arduino/libraries/ACD10-develop /var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/arduino_build_652482/sketch/ACD10_demo.ino.cpp -o /var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/arduino_build_652482/sketch/ACD10_demo.ino.cpp.o /Users/nil/Downloads/ACD10-0.1.1/examples/ACD10_demo/ACD10_demo.ino: In function 'void loop()': ACD10_demo:29:12: error: 'class ACD10' has no member named 'requestSensor'; did you mean 'readSensor'? mySensor.requestSensor(); ^~~~~~~~~~~~~ readSensor ACD10_demo:30:19: error: 'class ACD10' has no member named 'requestReady'; did you mean 'lastRead'? while (mySensor.requestReady() == false) delay(10); ^~~~~~~~~~~~ lastRead Using library Wire at version 1.0 in folder: /private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire Using library ACD10-develop at version 0.1.0 in folder: /Users/nil/Documents/Arduino/libraries/ACD10-develop exit status 1 'class ACD10' has no member named 'requestSensor'; did you mean 'readSensor'?

fuzonmedia commented 1 year ago

Compiling sketch... /private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire/src -I/Users/nil/Documents/Arduino/libraries/ACD10-develop /var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/arduino_build_900459/sketch/ACD10_readSensor.ino.cpp -o /var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/arduino_build_900459/sketch/ACD10_readSensor.ino.cpp.o /Users/nil/Downloads/ACD10-0.1.1/examples/ACD10_readSensor/ACD10_readSensor.ino:11:16: warning: invalid conversion from 'TwoWire*' to 'uint8_t {aka unsigned char}' [-fpermissive] ACD10 mySensor(&Wire); // explicit default, not needed. ^~~~~ In file included from /Users/nil/Downloads/ACD10-0.1.1/examples/ACD10_readSensor/ACD10_readSensor.ino:8:0: /Users/nil/Documents/Arduino/libraries/ACD10-develop/ACD10.h:22:3: note: initializing argument 1 of 'ACD10::ACD10(uint8_t, TwoWire*)' ACD10(uint8_t address = ACD10_DEFAULT_ADDRESS, TwoWire *wire = &Wire); ^~~~~ /Users/nil/Downloads/ACD10-0.1.1/examples/ACD10_readSensor/ACD10_readSensor.ino: In function 'void loop()': ACD10_readSensor:32:14: error: 'class ACD10' has no member named 'requestSensor'; did you mean 'readSensor'? mySensor.requestSensor(); ^~~~~~~~~~~~~ readSensor ACD10_readSensor:36:16: error: 'class ACD10' has no member named 'requestReady'; did you mean 'lastRead'? if (mySensor.requestReady()) ^~~~~~~~~~~~ lastRead Using library Wire at version 1.0 in folder: /private/var/folders/xs/8m8thf7x4d968sw4vqxp2g5w0000gn/T/AppTranslocation/AC51C3D8-AD07-4EED-B8C3-D26D1FB573F9/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/Wire Using library ACD10-develop at version 0.1.0 in folder: /Users/nil/Documents/Arduino/libraries/ACD10-develop exit status 1 'class ACD10' has no member named 'requestSensor'; did you mean 'readSensor'?

RobTillaart commented 1 year ago

That is a lot of info, need some time to analyze what happens in the code.

fuzonmedia commented 1 year ago

Ok I understand . It was my fault. It was pulling library from the old codebase. Now I made it correct

17:01:42.501 -> /Users/nil/Documents/Arduino/libraries/ACD10-0.1.1/examples/ACD10_demo/ACD10_demo.ino 17:01:42.501 -> ACD10_LIB_VERSION: 0.1.1 17:01:42.572 -> 1651 12187 17:01:44.673 -> 1647 12183 17:01:46.766 -> 1643 12186 17:01:48.857 -> 1640 12186 17:01:50.973 -> 1638 12187 17:01:53.048 -> 1637 12186 17:01:55.137 -> 1635 12183 17:01:57.243 -> 1634 12186 17:01:59.324 -> 1632 12183 17:02:01.420 -> 1631 12185 17:02:03.504 -> 1630 12184

This is what I am getting now from 0.1.1

fuzonmedia commented 1 year ago

Seems the temperature is still not correct. but Co2 is showing as needed

RobTillaart commented 1 year ago

If you divide temperature by 512. ? Would give ~23.8 °C

RobTillaart commented 1 year ago

Does the CO2 match the testcode you got from aosong?

fuzonmedia commented 1 year ago

Does the CO2 match the testcode you got from aosong?

Similar