I want to connect 3 MPU9250 sensors, but since there is just one I2C bus, so there are another 2 sensors I want to connect through SPI.

Library used - https://github.com/bolderflight/MPU9250/blob/master/examples/Basic_SPI/Basic_SPI.ino

There is an SPI example code written, but I don't know about the connections. There are no MISO and other pins on the sensor which i use but its SPI compatible. How do I connect 2 MPU9250 to NodeMCU with SPI?

If SPI connection is not possible then please post about I2C slave connection.

enter image description here

  • The MPU-9250 I2C address will be 0x68 if the AD0 pin is grounded or 0x69 if the AD0 pin is pulled high. So there's 2. The third one would be more complex, though you could use 2 i2c and 1 spi. You can also just use a 2nd pair of pins to run an additional i2c bus to the 3rd sensor, instantiae another Wire instance (passing the pins numbers to it) and feeding that wire instance to the MPU9250FIFO constructor. – dandavis Mar 7 at 17:58

To connect multiple SPI components, you only need 4 pins on each 'slave' (thus sensors): SLCK, MOSI, MISO and SS (Slave Select).

The Slave select pin depends to which the master (NodeMCU in your case) is 'talking too'. So on your NodeMCU you will have 3 SS pins (one for each slave sensor). The NodeMCU should talk exactly to one slave device at the same time by setting that SS pin LOW (while the other SS pins are high).

See for the full article: Multiple-SPI-devices-to-an-arduino-microcontroller.

enter image description here

  • I uploaded the sensor image, which pin is SCLK, MOSI, MISO & SS in this case? – suu Mar 7 at 14:51
  • Those are I2C slaves, SPI is a completely different protocol. – Michel Keijzers Mar 7 at 14:54
  • Can you post the answer about connect 3 mpu9250 sensor with i2c slave? Thanks so far – suu Mar 7 at 14:55
  • I don't have much experience with I2C, I think the SDA and SCL are default I2C connection/pins, so use those. – Michel Keijzers Mar 7 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.