mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-02 21:41:01 +02:00
31 lines
623 B
Arduino
31 lines
623 B
Arduino
![]() |
#include "Wire.h"
|
||
|
|
||
|
#define I2C_DEV_ADDR 0x55
|
||
|
|
||
|
uint32_t i = 0;
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(115200);
|
||
|
Serial.setDebugOutput(true);
|
||
|
Wire.begin();
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
delay(5000);
|
||
|
|
||
|
//Write message to the slave
|
||
|
Wire.beginTransmission(I2C_DEV_ADDR);
|
||
|
Wire.printf("Hello World! %u", i++);
|
||
|
uint8_t error = Wire.endTransmission(true);
|
||
|
Serial.printf("endTransmission: %u\n", error);
|
||
|
|
||
|
//Read 16 bytes from the slave
|
||
|
error = Wire.requestFrom(I2C_DEV_ADDR, 16);
|
||
|
Serial.printf("requestFrom: %u\n", error);
|
||
|
if(error){
|
||
|
uint8_t temp[error];
|
||
|
Wire.readBytes(temp, error);
|
||
|
log_print_buf(temp, error);
|
||
|
}
|
||
|
}
|