How do I connect an accelerometer (GY-521) to a SparkFun Thing Dev (ESP8266)?

2018-11-13 23:22:11

All of the wiring diagrams I've found for wiring up a GY-521 accelerometer to an Arduino have looked something like this:

I've read in several places that it needs to be connected to A4 and A5. I want to connect one to a SparkFun ThingDev, which unfortunately only has a single analog input:

Is this possible?

I only need it for a very simple application (finding out if a machine is vibrating or not).

A4 and A5 on the Arduino double as the I2C pins SDA and SCL. You are communicating with I2C, not analog.

The ESP8266 doesn't have I2C in hardware, but there is a software-based I2C implementation which can work on any pins. The pinout you show has I2C labeled on pins 2 and 14. While you can use those you could use any two pins of your choosing.

Note that I2C on the ESP8266 has a slightly different begin function:

Wire.begin(2, 14);

That is where the pins you want to use are assigned - in this case, pin 2 for SDA and pin 14 for SCL.

  • A4 and A5 on the Arduino double as the I2C pins SDA and SCL. You are communicating with I2C, not analog.

    The ESP8266 doesn't have I2C in hardware, but there is a software-based I2C implementation which can work on any pins. The pinout you show has I2C labeled on pins 2 and 14. While you can use those you could use any two pins of your choosing.

    Note that I2C on the ESP8266 has a slightly different begin function:

    Wire.begin(2, 14);

    That is where the pins you want to use are assigned - in this case, pin 2 for SDA and pin 14 for SCL.

    2018-11-14 01:00:11