but all I get back in the COMM is something like "CO2: 0.00 ppm, Temp: 0.00 C, Rh: 0.00%"
I proofed all the code and used updated language (changed Wire.send to Wire.write, etc).
I think it may have something to do with the wakeSensor portion of the code, which warns that if you are using a different AVR, you may need to use different registers. They use a Duemilanove with ATmega168. Do I need to change this portion of the code since I'm using a 2560? I have no idea how to look up the registers and compare them across AVRs. Can you think of another reason for the zero reading?:
void wakeSensor() {
// This command serves as a wakeup to the CO2 sensor, for K33?ELG/BLG Sensors Only
// You'll have the look up the registers for your specific device, but the idea here is simple:
// 1. Disabled the I2C engine on the AVR
// 2. Set the Data Direction register to output on the SDA line
// 3. Toggle the line low for ~1ms to wake the micro up. Enable I2C Engine
// 4. Wake a millisecond.
TWCR &= ~(1<<2); // Disable I2C Engine
DDRC |= (1<<4); // Set pin to output mode
PORTC &= ~(1<<4); // Pull pin low
delay(1);
PORTC |= (1<<4); // Pull pin high again
TWCR |= (1<<2); // I2C is now enabled
delay(1);
}
Is the K33 powered independent or connected to the Arduino? I get the same values (just zeros) if my battery runs dry. Just to prove whether this is the problem or not, connect the K33 directly to 9v as shown in the datasheet. If it takes a measurement (After the void wakeSensor the call of initPoll() ) the led in the sensor will flash round about 25 times. This means, it takes a measurement.
// We will be using the I2C hardware interface on the Arduino in
// combination with the built‐in Wire library to interface.
// Arduino analog input 5 ‐ I2C SCL
// Arduino analog input 4 ‐ I2C SDA
Please be aware that the I2C pins on the Arduino Mega 2560 are NOT A4 and A5. They are Pins 20 and 21.
Hi.
I have essentially the same problem except that I'm working with an Arduino Uno R3 board with ATmega328 processor and have a the sensor CO2 Engine K33-LP T/RH from Sensair connected. I have implemented the wiring according to figure 2 on page 4 of this document (which was referenced by the data sheet of my sensor).
I have the G+ and G0 pins of the I2C port on the sensor connected to an external power supply with 9.2V. Then the DVCC port from the sensor is connected to 3.3V on the Arduino, and SDA and SCL to A4 and A5.
I've run a scanner to check the addresses, but get the feedback that there are no I2C devises connected. I read here that "The newer Atmega328p chip follows the pinout of the Atmega168 exactly." I'm pretty sure that mine is an Atmeg328 chip (no p), but couldn't find any information saying that my registers are different.
Did you ever get your sensor to give readings? Does anyone have any idea what might be going wrong?
Thanks for your reply. I got it working now. I looked into the pull-up resistors but it doesn't need any (I have used those for another project with an I2C connection though). It turned out that the plug I was using to connect with the little part I soldered to the board had a faulty connection; once I replaced the plug it worked great.
Apparently, the sensor sometimes locks up after running for a bit... I haven't had this happen, but haven't had it running for long yet. In case anyone else runs into this problem and stumbles upon this post, I found this pdf file which offers solutions.