0
\$\begingroup\$

I need to have an ESP8266 connected with these components

  • MPU6050 gyroscope/accelerometer
  • HMC5883L compass
  • BMP280 presure sensor
  • GYNEO6MV2 GPS Module

and I should drive 4 PWM lines according the input calculated.

I'm not sure if the wiring that I'm thinking to use is appropriate. Here my scheme: enter image description here

I report the connections here if it isn't clear enough:

GPIO-12 -> control ESC1

GPIO-13 -> control ESC2

GPIO-14 -> control ESC3

GPIO-15 -> control ESC4

GPIO-1 -> SDA BMP280 (pressure sensor/altimeter)

GPIO-3 -> SCL BMP280 (pressure sensor/altimeter)

GPIO-2 -> SDA HMC5883L (compass)

GPIO-0 -> SCL HMC5883L (compass)

GPIO-5 -> SDA MPU6050 (gyroscope/accelerometer)

GPIO-4 -> SCL MPU6050 (gyroscope/accelerometer)

GPIO-9 -> SDA GYNEO6MV2 (GPS Module)

GPIO-10 -> SCL GYNEO6MV2 (GPS Module)

with common 3.3 Vin and GND to supply power to ESP8266 and all modules

Is this wiring appropriate? If no, how the components should be wired?

EDIT

Wise people here suggested to use multiple devices on same SDA and SCL lines, so: using I2C addressing it is enough to wire them directly in this way or is needed something to prevent them to interfere with each other? (Note that GPIO-4 and GPIO-5 are marked SDA and SCL on this board)

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ SDA and SCL can probably be shared between all 4 sensors if there are appropriate pullups (not shown in your "schematic") and no conflicting I2C addresses. \$\endgroup\$
    – StarCat
    Oct 5, 2022 at 20:29
  • \$\begingroup\$ @StarCat Thanks for the point. I'm not sure how to properly share SDA and SCL lines to spare some GPIO pin without some mess.. however other than this, is my wiring correct? \$\endgroup\$
    – AndreaF
    Oct 5, 2022 at 20:43

1 Answer 1

0
\$\begingroup\$

The idea behind using a protocol like I2C is to be able to share a common data bus between many devices.

Right now you are presumably trying to set up your devices as I2C (since you're using SDA and SCL) lines but you are setting them up each as a separate bus.

This is not the right way to go. Look into the datasheets for each device to determine how to set the I2C addresses and make sure each address is different. Then wire them all to the same I2C bus.

Start with one, then test to see if it works, then add a second one and troubleshoot, then add more...

There are many guides online for setting up multiple I2C devices. You should follow one. Not all GPIO pins are appropriate for use as serial communication pins. On your device pinout, there should be 2 pins specifically labeled for use as SDA and SCL. Use them

\$\endgroup\$
4
  • \$\begingroup\$ Thanks for reply. I have added an update to my question ...check it to be sure I have understood well what you mean \$\endgroup\$
    – AndreaF
    Oct 5, 2022 at 22:40
  • \$\begingroup\$ i2c devices will only respond to data that is prepended with their address, so long as no i2c devices share the same address, there will be no interference on the bus. I2C addresses are commonly set by bridging some physical pins on the devices themselves, look at the datasheets for details. The only other consideration is pullup resistors for the bus, many boards have internal pullup resistors for this purpose. Check to see if your esp8266 has internal pullups that you can turn on, and then also confirm that your other devices don't (to avoid reducing the resistance due to parallels) \$\endgroup\$ Oct 5, 2022 at 23:17
  • \$\begingroup\$ from this question electronics.stackexchange.com/questions/404632/… there are pullups on GPIO-4 and GPIO-5 for SDA and SCL... so it is enogh to enable them to make wiring as in second sheme ok...confirm?? \$\endgroup\$
    – AndreaF
    Oct 5, 2022 at 23:30
  • \$\begingroup\$ activate the internal pullups on your esp and then start with just one of your i2c devices. Confirm that you can read from it. Then add another and confirm that you can read from both, et cetera. if you get to a point where adding a device stops the bus from working, check the pullup resistance on the bus to confirm that the added device didn't add more pullup resistors in parallel. You got this. Good luck \$\endgroup\$ Oct 6, 2022 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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