Go Down

Topic: Temp, Humidity CO2 sensor and library. (Read 138901 times) previous topic - next topic

roder

For anyone is using a Pinoccio (https://pinocc.io), which uses the ATmega2560 chip:

I used `SCK` as pin `11` and `MISO` as pin `12`

`SoftwareSerial nss(11,12);`

https://github.com/Pinoccio/core-pinoccio/blob/master/avr/variants/pinoccio/pins_arduino.h#L48-L49

nitrojet

Interestingly as soon as I take a reading in my loop:

lcd.setCursor(0,0);lcd.print("CO2 : "); lcd.print(czr.CO2());

My ads1115 running on the i2c bus stops taking readings!

If I rem this line out, it works fine??

The CO2 reading works fine anyway.

robtillaart

Quote
nterestingly as soon as I take a reading in my loop:
lcd.setCursor(0,0);lcd.print("CO2 : "); lcd.print(czr.CO2());
My ads1115 running on the i2c bus stops taking readings!
If I rem this line out, it works fine??
The CO2 reading works fine anyway.
The I2C communication might be corrupted by the LCD communication. How is the LCD connected?

do you have pull ups on the I2C lines?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nitrojet

Wow, you are a great help to the community!

Yes I am using an i2c LCD but like I say, it works fine if I remark out any lines that read the cozir, but as soon as I take a reading from the cozir, the communication with the adc on the i2c bus stops!

My sketch takes a reading from the adc first, this works and is displayed on the lcd (and the serial monitor), then a CO2 which works fine, on the next loop (as a CO2 reading has now been taken) the adc (ads1115) returns nothing!

Very strange.

nitrojet

I thought the pullup resistors are internal to the atmega, I am using an Uno.

Should I disable them? I think they are software turn offable.

robtillaart

I am no EE but IIRC the internal pullups are not the right size.
the longer the wires the lower the pullups should be.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nitrojet

Interestingly, if I pull the LCD out completely, no change (as I half expected)

If I pull the CO2 out of pins 2 & 3, the ADS1115 works fine (as I also half expected)

If I try the softwareserial on pins 10&11, I accidentally plugged in back to front, the ADC worked fine, as soon as I turned the CO2 round the right way, the ADC stopped reading.

Must be a conflict in the code?

I will try the alternative sample code maybe?

robtillaart

Can it be that all the devices together draw to much current, thereby corrupting signals.??
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nitrojet

No as the lcd is 40ma and when I unplug that, it still plays up yet I can even run a TIP120 or other devices. The USB is 500ma and so I am not sure.

I appreciate your help.

I am a bit stuck.

robtillaart

Arduino can only deliver 5-10mA per pin - check the specification, - http://arduino.cc/en/Main/arduinoBoardUno -


or try it with a separate power supply for the peripherals...(GND's connected)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

nitrojet

Well the CO2 and the ADS1115 connected and just using the serial monitor as you suggested but still not. The LCD draws 40ma but straight from the 5v rail, not from one of the PWM or Analog outs, even still, I get the first result in from the ADS1115 and then the result from the cozir and then once it tries to get another result from the ADS1115, it returns nothing. Very weird

Dew321

Hi Everyone,

     I recently purchased a COZIR wide range 65% sensor, and I hooked it up to Arduino using the code and library provided by DirtGambit. However, for the sensor when it reaches around 65000 ppm it will undergo a wrap-around, where it will start back at 0 and then continue going up from there. Does anyone know if this is caused by something in the code that DirtGambit provided, or if it is something to do with the sensor itself (since it is 65%, so it should go to 650,000 ppm according to the CO2meter website, not 65000).

      Thank you
     

robtillaart

#87
Nov 13, 2014, 07:50 pm Last Edit: Nov 13, 2014, 07:52 pm by robtillaart
Can be something in the code, I'll need to check.

an unsigned int wraps around at 65355->0

which version of the library are you using?

can you post your sketch and point out where it wraps?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

The interface of the 01.03 version has a

   uint16_t CO2();

that means it can only return values between 0..65535
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Dew321

Hi robtillaart,

    Thank you for your reply! The sketch I am using is the exact same as the one that DirtGambit provided, although I changed int c = czr.CO2();  into a double so that the range would be wider, as with just an int it faltered at around 13000 ppm. Also, I am using the library from github that was provided by Roder on this thread.
    Hmm...I'll take a look at the uin16_tCO2(). Is there a way to make it go up to around 650,000 ppm, which is the max for this particular sensor?

Go Up