Your two topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Hey, thank you for the information. I was aware of that, but I was hoping for more specific feedback when having another title. I will pay more attention on that in the future!
Hey guys, I run a CO2 sensor on I2C and want to find out its address using the I2C scanner from Wire library. However, it does not find my sensor, although the sensor works in another sketch. I know the address already, but I want to change it and have proof that the change was successful. Since the sensor gives plausible values when running the CO2 sketch, I assume the wiring is correct. But where is the mistake then?
It is a senseair sunrise CO2 sensor. The manufacturer provided code to me to change the address, which is
#include <Wire.h>
//Current Address
int SunriseAddress = 0x68;
//New Address
int SunriseNewAddress = 0x10;
//Variable for the decision whether address should be changed
int changeaddressbyte = 1;
//Variable to start reading CO2 data with new address (Will be active after changing address or manually)
int active_routine = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Wire.begin();
Wire.setClock(100000);
delay(500);
}
void ChangeAddress(uint8_t target, uint8_t targetnew) {
int error;
//wakeup;
Wire.beginTransmission(target);
error = Wire.endTransmission(true);
//Write new address to register
Wire.beginTransmission(target);
Wire.write(0xA7);
Wire.write(targetnew);
error = Wire.endTransmission(false);
delay(10);
//Restart the sensor, aftet that new address needs to be used to communicate with sensor
Wire.beginTransmission(target);
Wire.write(0xA3);
Wire.write(0xFF);
error = Wire.endTransmission(false);
}
void loop() {
int reading = 0;
if (changeaddressbyte == 1 && active_routine == 0) {
ChangeAddress(SunriseAddress, SunriseNewAddress);
active_routine = 1;
}
if (active_routine == 1)
{
//wakeup;
Wire.beginTransmission(SunriseNewAddress);
Wire.endTransmission(true);
//Read CO2
Wire.beginTransmission(SunriseNewAddress);
Wire.write(0x06);
Wire.endTransmission();
Wire.requestFrom(SunriseNewAddress, 2);
//Receive reading CO2 from sensor
if (2 <= Wire.available()) { // if two bytes were received
reading = Wire.read(); // receive high byte (overwrites previous reading)
reading = reading << 8; // shift high byte to be high 8 bits
reading |= Wire.read(); // receive low byte as lower 8 bits
Serial.print(reading); // print the reading
Serial.println(" CO2");
}
}
delay(4000);
}
They use the i2c scanner to verify the address change, but on a nano board, I use Uno rev 3.
@de_botaniker1 Yet another duplicate topic merged into the original.
@de_botaniker1, as you don't seem to have understood those words I've given you a 2 day break from posting on the forum while you consider their meaning. If you continue to create duplicate topics the breaks will get longer.
I found the solution of the problem. As it was already super confusing, that the sensor was working with one script but could not be detected in the scanner, I called the manufacturer. After a long chat, we figured out that there is a pin which has to be HIGH when operating the sensor (or using the scanner).
Everything works fine now. Thank you all for trying to help me