Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5196

Beginners • Cannot detect i2c address from Pi Pico w

$
0
0
Hello, I am just getting into using i2c communication (specifically with magnetometer MLX90393) and I cannot get the pico to even recognise the slave address. My code is as follows:

Code:

int main() {    stdio_init_all();    i2c_init(i2c1, 100000); //100 min 400 max    gpio_set_function(2, GPIO_FUNC_I2C);    gpio_set_function(3, GPIO_FUNC_I2C);    //gpio_pull_up(2);    //gpio_pull_up(3);    while(1) {        sleep_ms(100);        uint8_t rt = RT;        uint8_t dst[10];        int z = i2c_write_blocking(i2c1, DEFAULT_ADDR, &rt, 1, 1);        printf("%d\n", z);    }   return 0;}
Also, here is the wiring, if it helps:
pico.jpg
I disabled the pullups because the breakout board for the peripheral already has enough resistance.
I have also tried the i2c scan example code and ran into the same issue- I've opted to use this code for testing since the datasheet for the sensor says i2c communication should be initiated with a write (not a read as the i2c scan does). I've tried other i2c pins and bus 1 vs 0, but no luck so far. I'm pretty new to this so I feel I could be missing something obvious. If you have any suggestions for debugging, I'd be grateful! Thanks so much!

Statistics: Posted by kamuii — Tue Jun 04, 2024 10:50 pm — Replies 0 — Views 13



Viewing all articles
Browse latest Browse all 5196

Trending Articles