ralphberner
Member
I have a "Senseair Sunrise" CO2 sensor and i got a reference code for that.
It works perfect an an arduino UNO with the following connections
I soldered the two connections on the sensor itself directly there. So just 5 wires go to the controller.
Then i connected the same sensor to a teensy 3.2:
Sensor -> Teensy:
GND -> GND (next to pin 0) (black)
VCC -> 3.3V (next to pin 23) (red) (Voltage is there. I checked it)
SCL -> SCL / pin19 (yellow) (i tripple checked it)
SDA -> SDA / Pin 18 (blue) (i tripple checked it)
Enable -> pin 8 (green) (same pin as the arduino)
I permanemtly get an error 4 for Wire.endTransmission(true);
I reduced the code to the minimum for analyses here
It still gives the same error:
Console text:
Error 4
Error 4
Error 4
Error 4
Error 4
I used no external resistors for pullup etc.
I tis confusing, because i used so many I2C devices without any trouble on teensys up to now.
Does anybody have an idea for solution or is further information needed?
Regards
It works perfect an an arduino UNO with the following connections
I soldered the two connections on the sensor itself directly there. So just 5 wires go to the controller.
Then i connected the same sensor to a teensy 3.2:
Sensor -> Teensy:
GND -> GND (next to pin 0) (black)
VCC -> 3.3V (next to pin 23) (red) (Voltage is there. I checked it)
SCL -> SCL / pin19 (yellow) (i tripple checked it)
SDA -> SDA / Pin 18 (blue) (i tripple checked it)
Enable -> pin 8 (green) (same pin as the arduino)
I permanemtly get an error 4 for Wire.endTransmission(true);
I reduced the code to the minimum for analyses here
It still gives the same error:
Console text:
Error 4
Error 4
Error 4
Error 4
Error 4
Code:
#include <Wire.h>
const int SUNRISE_EN = 8; //serial EN pin
const uint8_t SUNRISE_ADDR = 0x68; // communication address
const int ATTEMPTS = 5; // Amount of wakeup attempts before time-out
/* Delays in milliseconds*/
const int STABILIZATION_MS = 35;
//███████████████████████████████████████████████████████████████
void reInitI2C() { // Initialize I2C
Wire.begin();
Wire.setClock(100000); // Setup I2C clock to 100kHz
}
//███████████████████████████████████████████████████████████████
bool _wakeup(uint8_t target) // Wakes up the sensor by initializing a write operation with no data.
{
int attemps = ATTEMPTS;
int error;
do {
Wire.beginTransmission(target);
error = Wire.endTransmission(true);
Serial.print("Error ");
Serial.println(error);
} while (((error != 0 /*success */) && (error != 2 /*Received NACK on transmit of address*/)) && (--attemps > 0));
if (error == 4) {
reInitI2C();
return false;
}
return (attemps > 0);
}
//███████████████████████████████████████████████████████████████
void setup()
{
pinMode(SUNRISE_EN, OUTPUT);
digitalWrite(SUNRISE_EN, HIGH);
delay(STABILIZATION_MS); // Wait for sensor start-up and stabilization
reInitI2C(); // Initialize I2C
Serial.begin(115200);
_wakeup(SUNRISE_ADDR);
}
//███████████████████████████████████████████████████████████████
void loop() {
}
I used no external resistors for pullup etc.
I tis confusing, because i used so many I2C devices without any trouble on teensys up to now.
Does anybody have an idea for solution or is further information needed?
Regards