I find many tutorials for using pico as an i2c master (controller), but not a lot of help using pico as an i2c slave (responder). I'm aware of the library created by Don Perron (and the epmoyer derivative) but haven't had a great deal of success with it. I have control system using a network of RPis, and currently using chips such as the mcp23017 for i/o. I wish to replace the various i/o devices with picos.
So I have looked at my i2c line with a logic analyzer and keep gettin g a setup to read followed by a NAK even though im trying to write to the device. I 100 percent have to right address for the device 102 for the EZO_RTD. I did not pull up my resistor in internally since i have them externally. Help would be appreciated I have been trying ti fix this for days void i2c_setup(int SDA, int SCL,uint clock_speed,i2c_inst_t* i2c_port) { i2c_init(i2c_port, clock_speed); // This example will use I2C0 on the default SDA(Pin 0) and SCL(Pin 1) gpio_set_function(SDA, GPIO_FUNC_I2C); // Serial Clock gpio_set_function(SCL, GPIO_FUNC_I2C); // Serial Data line gpio_pull_up(SDA); gpio_pull_up(SCL); } int main() { int SDA = 0; int SCL = 1; // Vairable for read and write blocks uint8_t rxbuff[40]; // Receiving Buffer const uint8_t command[2]= "r"; // Command int len_bytes_command = strlen(command); int max_length_receive_bytes = 40; uint8_t address = 102; // Enable USB UART so we can print status output stdio_init_all(); i2c_setup(SDA,SCL,400*1000,i2c0); while(1) { int written = i2c_write_blocking(i2c0,address,command,1,false); sleep_ms(600); printf("Bytes:%d,Address: %d ",written,address); } return 0; }
Hi, i get error that i could not communicate with ADXL343, I don't have an accelerometer as you so i changed ADXL343_ADDR to: ADXL343_ADDR = 0x4c, So it should work fine. I would be grateful if you could help me solve this problem By the way my accelerometer is Grove - MMA7660FC bytearray((DEVID,)) = b'\xe5' data = '\x00'