ESP32 working as an I2C slave device, receiving writes from PSOC master

pgrlopes
Posts: 1
Joined: Tue Apr 10, 2018 1:46 pm

ESP32 working as an I2C slave device, receiving writes from PSOC master

Postby pgrlopes » Thu Apr 26, 2018 5:42 pm

Hello guys.

I'm trying to get my esp32 working as a slave device and BLE server so that it can receive information from another microcontroller (psoc 5) and send it through bluetooth/wifi. I've been googling and checking examples on github for the past few days and although I got a good grasp at how i2c works, most of the examples are about esp32 working as master and writing/reading to/from slaves. I got my slave initialization done as follows:

Code: Select all

  /*
   * 
   * SLAVE INIT
   * 
   */
    int i2c_slave_port = I2C_SLAVE_NUM;
    i2c_config_t conf_slave;
    conf_slave.sda_io_num = (gpio_num_t)I2C_SLAVE_SDA_IO;
    conf_slave.sda_pullup_en = GPIO_PULLUP_ENABLE;
    conf_slave.scl_io_num = (gpio_num_t)I2C_SLAVE_SCL_IO;
    conf_slave.scl_pullup_en = GPIO_PULLUP_ENABLE;
    conf_slave.mode = I2C_MODE_SLAVE;
    conf_slave.slave.addr_10bit_en = 0;
    conf_slave.slave.slave_addr = ESP_SLAVE_ADDR;
    i2c_param_config((i2c_port_t)i2c_slave_port, &conf_slave);
    i2c_driver_install((i2c_port_t)i2c_slave_port, conf_slave.mode, I2C_SLAVE_RX_BUF_LEN, I2C_SLAVE_TX_BUF_LEN, 0);
  /**/

What I need is to know how to process the information once I received it in the loop function. I'm assuming that my master already sent me the data string, I need to know is how to access it and how to reply with the ACK so I can then print it in the serial monitor to check if it is working.

I'm using the ESP32 Thing from Sparkfun and programming it through the Arduino IDE. I based my code on this example: https://github.com/espressif/esp-idf/bl ... ple_main.c

Is there any basic example on how to process this information?

Thank you.

atur94
Posts: 1
Joined: Sat Aug 25, 2018 12:29 pm

Re: ESP32 working as an I2C slave device, receiving writes from PSOC master

Postby atur94 » Sat Aug 25, 2018 12:31 pm

Hey. Have you managed to run esp32 as a slave? I am having the same difficulty a you had.

Who is online

Users browsing this forum: No registered users and 81 guests