So I am working on a project where I communicate to a IR temp sensor over I2C from an Arduino Uno. I am using the arduino Wire library to do the communication, I want it to request the temperature data once a second so I added a 1000ms delay in the void loop(). However, despite the delay function in there the arduino is sending the request every 2.5ms. I have attached the code and screen shot of the logic analyzer, any insight would be great.
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.begin();
#if defined(WIRE_HAS_TIMEOUT)
Wire.setWireTimeout(3000 /* us */, true /*reset on timeout */);
#endif
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(0x5A);
Wire.write(0x07);
Wire.requestFrom(0x5A, 3, true);
while (Wire.available()){
byte c = Wire.read();
Serial.print(c, HEX);
Serial.print(" / ");
}
Wire.endTransmission();
Serial.println();
delay(1000);
}
