So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Clemens Arth
#82613 We have some serious trouble setting up our custom PCB/assembly with the ESP8266 ESP-12F on it, and I really really hope someone can give us some hints on this.

Briefly, we were working in iterations of a board and what we did was creating a single I2C bus with a BNO055 and an MPL3115A2 which connect to GPIO2 (SDA) and GPIO14 (SCL) of an ESP-12F, all of the sensors and the ESP powered up simultaneously on applying VDD. In iteration #1 that was actually working flawlessly - we were able to flash the board and boot the software and also retrieving data worked. Btw, we used expressif@1.8 and the wire library to drive the I2C, plus some additional code for BNO and MPL.

In iteration #2 we kept everything the same and changed some wiring elsewhere, however, now we are completely stuck. It seems that the powering of the sensors brings GPIO2 into a state that neither allows booting nor flashing (we did not see this behaviour in iteration #1, thus we also did not realize the conceptual flaw). Just now we learned that using GPIO2 is a BAD idea.
Ok, on applying power, we can actively see the sensors sending data over I2C (using an oscilloscope) - just as it should be and GPIO2 seems to be the I2C master (?) - however, obviously the boot process crashes constantly with "Fatal Exception". To move forward and actively flash the board, we had to physically cut the I2C data bus to GPIO2 to get the board into flash/boot mode at all. As expected, the ESP then behaves as it should, but the bus is cut obviously, so no data. Now, here's what we tried given GPIO2 was cut:

1) cut power to the sensors, reestablish GPIO2 connection, establish power to sensors after booting, and use Wire.begin(2,14) as before. The result: there is no data sent over I2C. We clear the bus and we run into "SDA data line held low" with no chance to get out of this any more...

2) just rewire the SDA to GPIO5, and change the pin in the software with Wire.begin(5,14). The result: I2C does not come up, same problem with "SDA data line held low" as with GPIO2, no way to recover from this any more... (well, at least the board boots and does not get stuck in the fatal exception).

The big question is - why does it supposably work on GPIO2 causing the boot race condition, but does not work if we use GPIO5? We have read LOTS of forum entries and other comments with respect to the I2C and ESP12. Some pages say you can Quote "use pretty much any pin for I2C", however, after playing around with reset/clean/startup writes/reads from the new SDA pin 5, we are out of ideas, so any help on how to correctly set up the I2C bus given a booted board would be highly appreciated.
User avatar
By rudy
#82622 I use GPIO0 and GPIO2 all the time for I2C without issue. What value pull up resistors do you use? Have you verified the waveforms with a scope? Are the rise times in spec?

I mostly use 2k2 pull up resistors, but that is mainly because I have been using that value for many years on 5 volt systems. Now for 3.3 volt I2C applications I have been switching to a 1K pull up resistor.

Often GPIO4 and GPIO5 are used for I2C because Unos used A4 and A5. I have used GPIO4 and GPIO5 a few times on specific projects but 0 and 2 are my goto since those lines are are awkward for other uses.

EDIT:

I looked at the MPL3115A2 data sheet and they use a 1K pull up resistors for their specifications.
User avatar
By Clemens Arth
#82656
After switching to gpio5: do you have pullup on i2c?

What value pull up resistors do you use?

GPIO15 is pulled down with 12k
for the rest:
GPIO14 is pulled up with 12k (SCL)
GPIO2 is pulled up with 10k (SDA)
GPIO5 is also now pulled up with 10k (as it should replace GPIO2)
If I'm not completely in the woods, all of those are overridden by 1k + 3.3k at the sensors respectively, so we end up with overall pull up on SDA and SCL around 710-720Ohm

In the meantime I also used the I2C scanner (actually multiple different ones) with the rewired GPIO5 but there is no output... as I said, rewiring to GPIO2 does not bring up the board any more...

but 0 and 2 are my goto

do you use jumpers to pull pins high/low for flashing?

Have you verified the waveforms with a scope? Are the rise times in spec?

got to check this, but what buffles me is that it seems to work on GPIO 2 but not on GPIO 5...