STM32WB cannot connect to adafruit feather through I2C
Hi there,
I tried to set STM32 as the master and adafruit feather ESP8266 as the slave. They are going to communicate through I2C. Below is the configuration of the i2c3 because it is the only port for external sensors:
Then I write below code for master STM32:
HAL_StatusTypeDef ret;
uint8_t counter;
uint8_t i2c_addr = 0;
MX_I2C3_Init();
while (1) {
for (counter = 0; counter < 255; counter++) {
ret = HAL_I2C_IsDeviceReady(&hi2c3, (uint16_t)(counter<<1), 3, HAL_MAX_DELAY);
if(ret == HAL_OK) {
i2c_addr = counter;
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
}
}
HAL_Delay(500);
}And code in Arduino for slave feather:
#include <Wire.h>
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif
int cnt = 0;
void receiveEvent(int howMany)
{
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
void setup() {
// put your setup code here, to run once:
Wire.begin(2);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
delay(100);
}All I got is `HAL_ERROR`. But I can receive something on SDA (so as SCL):
For hardware connection, I connected two 10k pull-up resistors to SDA and SCL. Did I do something wrong? I really appreciate any help to this problem !!
