0

I made a mistake connecting SD0 (GPIO7) and SD1 (GPIO8) with the SDA and SCL on my arduino nano. I got confused with GPIO21 and pin21 and GPIO22 and pin 22!

Since I made a PCB prototype, I would avoid to add some wires and cut the traces, so I would ask if I could use these pins (GPIO7 and GPIO8) as SDA and SCL.

If the answer is affirmative, using Arduino library how could I assign them?

Wire.begin (7,8)?

Another question, I would use a dedicate 2x4.7K pull up resistors. On the arduino side I wrote:

digitalWrite(SDA, 0); digitalWrite(SCL, 0);

It is correct to do the same thing on the ESP32 side?

Update November 01: After the question from Majenco I think I need more help for the I2c setup.

I designed the PCB having in mind that the esp32 was 5V tolerant, so at the moment I pull-up the SDA, SCL from the 5V that I input in the esp power pin. Note that this 5V doesn't come from the Nano due to the high current required by the esp. I take my 12V power supply input and regulate it to 5V with a 7805, only dedicated to the esp (I know, a lot of dissipation! In the next PCB version I have to change the things, having in mind that I need both 12V and 5V in my circuit).

Now, I read that the esp32 is not 5V tolerant. In order to avoid level shifter can I pull up the SDA and SCL from the 3.3V line (the arduino 3.3V or esp32 one?)?

I would use the esp32 as master.

Thanks.

  • As I know, the Wire library is a hardware I2C library, not software. Hardware I2C is bound to special pins. And why would you try to pull both lines to low via digitalWrite? – chrisl Oct 25 '19 at 23:32
  • I would pull low the two lines in order to eliminate the internal arduino pull up resistors from the circuit, using the esternal one. I don't know if I can do same on the esp32 side. – daigs Oct 27 '19 at 21:35
  • If you are using hardware I2C on the Nano, the lines would do nothing, since the pins are controlled by the I2C hardware instead of the digital output hardware. If you are using software I2C, The pins will be controlled by the library. Doing the digitalWrite will disable the internal pullups for the moment, but as soon as the library takes action, the pins will be set to the libraries default state (most likely with enabled pullup, but not garanteed). So I think these lines do not serve a function on the Arduino. – chrisl Oct 27 '19 at 21:53
0

Since I made a PCB prototype, I would avoid to add some wires and cut the traces, so I would ask if I could use these pins (GPIO7 and GPIO8) as SDA and SCL.

No, you can't. Those pins are used by the internal flash chip. If you connect things to them you will end up not being able to read the flash and thus won't be able to run any code. In other words, the chip will not boot. So you will have to bite the bullet and cut traces and add bodge wires.

Wire.begin (7,8)?

Yes. That will control the bus matrix to route the I2C through different pins - but of course you can't use those pins, as noted above.

On the arduino side I wrote:

digitalWrite(SDA, 0); digitalWrite(SCL, 0);

It is correct to do the same thing on the ESP32 side?

No. That exploits a quirk in the AVR GPIO system that doesn't exist in the ESP32. In the ESP32 the pins are configured with:

pinMode(sda, OPEN_DRAIN | PULLUP | INPUT | OUTPUT );

and

pinMode(scl, INPUT | PULLUP);

so you could try replicating that in your code but without the PULLUP flag. However the effect of this is unknown, so YMMV.

However, if your external pullups are pulling up to 3.3V then you really don't need to do anything on the ESP32. All you end up with is a large resistance in parallel with your 4.7kΩ, which will just cause your resistance to drop slightly (and since 4.7kΩ is arguably too high any way that's a good thing).

  • it is 7 and 8 on Nano – Juraj Oct 27 '19 at 9:23
  • @Juraj No, it's SD0 and SD1, which are GPIO7 and 8 on the esp32! Read the question. The nano is irrelevant. – Majenko Oct 27 '19 at 9:45
  • yes, sorry, you are right. – Juraj Oct 27 '19 at 9:48
  • @Majenco so how could I use the external 4.7K pull up without interfere with the esp32 internals? – daigs Oct 27 '19 at 21:41
  • @daigs What voltage are you pulling up to? – Majenko Oct 27 '19 at 21:48

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.