2

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

2
  • 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, 2019 at 17:58
  • if you are working on a sensor your should have read its datasheet first rather going for some arduino library instead.
    – Vaibhav
    May 14, 2019 at 5:17

3 Answers 3

2

If you want to use SPI-

The homepage of the library you mentioned, clearly explains the circuit connections.-

The MPU-9250 pins should be connected as:

  • VDD: this should be a 2.4V to 3.6V power source.
  • GND: ground.
  • VDDI: digital I/O supply voltage. This should be between 1.71V and VDD.
  • FSYNC: not used, should be grounded.
  • INT: (optional) used for the interrupt output setup in enableDataReadyInterrupt and enableWakeOnMotion. Connect to interruptable pin on microcontroller.
  • SDA / SDI: connect to MOSI.
  • SCL / SCLK: connect to SCK.
  • AD0 / SDO: connect to MISO.
  • nCS: connect to chip select pin. Pin 10 was used in the code snippets in this document and the included examples, but any digital I/O pin can be used.
  • AUXDA: not used.
  • AUXCL: not used.

Each sensor's nCS (chip select pin) needs to be connected to a slave select pin (any digital pin) on the NodeMCU. This allows the NodeMCU toselect which sensor it wants to talk to.

Another easy way of connecting multiple sensors with the same I2C address is by using an I2C multiplexer like the Adafruit TCA9548A TCA9548 I2C multiplexer This would allow you to connect up to 8 sensors having the same I2C address. Here's a youtube video explaining how to do so.

However, if you just want connect two MPU9250s, you dont need to do any of this, as the board offers two unique addresses via the AD0 pin-

  • 0x68 if AD0 is grounded
  • 0x69 if AD0 is pulled high
1

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

4
  • I uploaded the sensor image, which pin is SCLK, MOSI, MISO & SS in this case?
    – suu
    Mar 7, 2019 at 14:51
  • Those are I2C slaves, SPI is a completely different protocol. Mar 7, 2019 at 14:54
  • Can you post the answer about connect 3 mpu9250 sensor with i2c slave? Thanks so far
    – suu
    Mar 7, 2019 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. Mar 7, 2019 at 15:30
1

The MPU-9250 pins should be connected as:

--Vcc: this should be a 2.4V to 3.6V power source.

--GND: ground.

--FSYNC: not used, should be grounded.

--SDA / SDI: connect to MOSI.

--SCL / SCLK: connect to SCK.

--AD0 / SDO: connect to MISO.

--nCS: connect to chip select pin (Any digital pin but in your example is PIN 10).

Also, you can check the connection from:

https://learn.sparkfun.com/tutorials/mpu-9250-hookup-guide?_ga=1.139382715.926858641.1470020364

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.