i2cscanner single device, multiple device addresses
zmemw16 Tue Aug 18, 2015 9:08 pm
STM32F103ZET6 Minimum System Development Board ARM STM32 Cortex-m3 M75
from
http://www.ebay.co.uk/itm/291305557264? … EBIDX%3AIT
i2c scanner(from examples) shows this
Scanning…
I2C device found at address 0x50
I2C device found at address 0x51
I2C device found at address 0x52
I2C device found at address 0x53
done
the device address is known to be 0x50, so is this just bad address decoding or is it really returning 4 devices?
i’m inclined to the former:-)
the data sheet says single address and im trying to write and then read back from a location; mention is made of
a ‘repeated start.
so my code
int data;
#define Trigger PB3
void setup() {
pinMode(Trigger, OUTPUT);
digitalWrite(Trigger, LOW);
Serial.begin(115200);
Wire.begin();
}
void loop() {
digitalWrite(Trigger, HIGH); // ols trigger
Wire.i2c_start();
Wire.i2c_shift_out(0x50); // device address
Wire.i2c_get_ack();
Wire.i2c_shift_out(0x5a); // writing data to this address
Wire.i2c_get_ack();
Wire.i2c_shift_out(0xa5); // write data
Wire.i2c_get_ack();
Wire.i2c_stop();
delay(5);
Wire.i2c_start();
Wire.i2c_shift_out(0x50); // device address
Wire.i2c_get_ack();
Wire.i2c_shift_out(0x5a); // writing data to this address
Wire.i2c_get_ack();
data = Wire.i2c_shift_in(); // write data
Wire.i2c_get_ack();
Wire.i2c_stop();
digitalWrite(Trigger, LOW); //
delay(5);
}
