*Solved* Send/Receive I2C Question

@canada7764 We can’t really help you unless you at least tell us the model name of the sensor.

  • Your example looks a little odd in that you send the letter “r” and then wait 900ms. That’s a VERY long time for a microcontroller to do nothing.
  • An I2C command MAY be just an “r” but it’s likely to be more (the datasheet will tell you this).
  • You have a Wire.endTransmission() in your while-loop despite not sending anything
  • At the end you have Wire.endTransmission(address); <- you shouldn’t have “address” here

I would suggest that you start by checking your code against the official Particle documentation https://docs.particle.io/reference/firmware/photon/#wire-i2c- Make sure you’re calling Wire.begin() somewhere at the start of your code. You will probably not need to use setSpeed or stretchClock, so ignore these. To understand how the Wire.available command should work, just read the docs for it https://docs.particle.io/reference/firmware/photon/#available--2

J

1 Like