#include <Wire.h> // Arduino library for I2C
const int ADDRESS = 0x08; // Sensor I2C Address
const float SCALE_FACTOR_FLOW = 500.0; // Scale Factor for flow rate measurement
const float SCALE_FACTOR_TEMP = 200.0; // Scale Factor for temperature measurement
const char *UNIT_FLOW = " ml/min"; //physical unit of the flow rate measurement
const char *UNIT_TEMP = " deg C"; //physical unit of the temperature measurement
// -----------------------------------------------------------------------------
// Arduino setup routine, just runs once:
// -----------------------------------------------------------------------------
void setup() {
int ret;
Serial.begin(9600); // initialize serial communication
Wire.begin(); // join i2c bus (address optional for master)
do {
// Soft reset the sensor
Wire.beginTransmission(0x00);
Wire.write(0x06);
ret = Wire.endTransmission();
if (ret != 0) {
Serial.println("Error while sending soft reset command, retrying...");
delay(500); // wait long enough for chip reset to complete
}
} while (ret != 0);
delay(50); // wait long enough for chip reset to complete
}
Serial output repeats: "Error while sending soft reset command, retrying..." when on the R4 WiFi. However, when on the Uno R3, the whole script manages to run and I get sensor values.
About the sensor connections (4):
SDA A4
SCL A5
VDD 3v3
GND GND
I'm looking into how pull up resistors are connected (new to this) based on what you've described is it:
A. Create a 1.8Kohm 'short' between A4 and 3V3 and a separate one between A5 and 3V3?
B. Attach a 1.8Kohm between A4 and the sensor SDA pin and a separate one between A5 and sensor SCL pin?
actually, the R4 does have internal pull up resistors.
Simply modify the blink example to
void loop() {
pinMode(A5, INPUT_PULLUP); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
pinMode(A5, INPUT); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
and connect a low-current LED to A5 and GND and it will flash (0.25 mA).
But you are right: the internal resistor is way too big. 20 kOhms, too much for I2C.
Yes BUT only to 5V. To run the bus at any other voltage, like 3V3 then you need pull up resistors to that voltage.
Correct.
However, I would describe the internal resistors as being "way too small".
I know the resistor value is bigger but when we talk about a pull up resistor it is normal to talk about how "hard" they pull. That means the current they can supply. So hence the 30 to 50 KΩ of the internal pull up resistors, don't pull hard enough.