Sensirion / arduino-i2c-scd4x

Arduino library for Sensirion SCD4x sensors
BSD 3-Clause "New" or "Revised" License
48 stars 19 forks source link

scd41 connected to Atmega168PA #8

Closed slechtvalk200 closed 1 year ago

slechtvalk200 commented 2 years ago

I am trying to use the example code on a longan I2C CAN BUS module. I use a adafruit friend as FTDI.

When i run this code : (stripped to bare minimum)

#include <Arduino.h>
#include <SensirionI2CScd4x.h>
#include <Wire.h>

SensirionI2CScd4x scd4x;

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    delay(100);
  }
  Wire.begin();
  uint16_t error;
  Serial.println("1");
  scd4x.begin(Wire);
  error = scd4x.stopPeriodicMeasurement();
  Serial.println(error);
 }

void loop() {
}

I get no println at all. Even not the Serial.println("1"); So there has to be something very wrong, when i comment line "error = scd4x.stopPeriodicMeasurement();" . There is no problem at all. Then i have all println, so then my code run.

in arduino-1.8.15\libraries\arduino-i2c-scd4x\src\SensirionI2CScd4x.cpp , when i comment out "error = SensirionI2CCommunication::sendFrame(SCD4X_I2C_ADDRESS, txFrame,*_i2cBus);" Then it runs again.

I have connection to the scd41, when i do a i2c scan, i see a device on 0x62.

arduino-snippets/SCD4x_I2C_minimal_example/SCD4x_I2C_minimal_example.ino works great.

Any idea what the problem could be?

psachs commented 2 years ago

Hi, could you resolve the issue? Can you also confirm that you get meaningful values with the minimal code snippet

I don't have a Atmega168PA to test. With several of the official Arduino boards everything works fine. Arduino doesn't provide very good error handling system. If something goes wrong in the code, you may or may not get a print output. Serial communication writes to a buffer which might not get flushed in case of a crash.

The drivers internally use TwoWire which might cause problems with your platform. Else the commands should be the same as in the code snippets.

psachs commented 1 year ago

closed due to inactivity