Serial, SCL, SDA, and conflicts with Digital Pins 0 and 1

Hello, I've read in several places that if I use Digital Pins 1 and 0 that I can longer use the Serial Interface; the common advice was to disconnect those pins before uploading code. And there was often a warning that if you use D0 and D1 then you cannot use the serial interface with a computer via USB.

I2C (like a real time clock or a 2x16 LCD display) uses the SDA pin. Is that the same kind of serial that would conflict with using digital pins 0 and 1? I'm in a remote part of a country in Asia and it takes weeks to get new items, so I would like to avoid time lost by ordering a multiplexer, etc. But I also don't want to break something if there is a conflict and loose time waiting for a new Arduino to arrive, as well.

For this project there are several relays that turn on or off at specific times. I really need as many digital pins as possible, but I also need SDA and SCL for the real-time clock.

Does SDA conflict with digital pins 1 and 0?

Thank you so much!

No.

1 Like

It depends what type of Arduino you are using. That's true for Uno, Nano V3 and others but not true for Leonardo, Pro Micro and others.

Strictly speaking, i2c is a kind of serial interface, yes. But quite different to UART, which is the better name for what we casually call serial interface. The pins for i2c are not shared with the UART pins on most types of Arduino, so no conflict.

Other types of serial interface include SPI, OneWire, WS2812... any type of interface where data bits are sent one after the other rather than at the same time but on different pins. That's called a parallel interface, and there are many types of those also.

1 Like

Here's a diagram showing the UNO pin functions.

Thank you so much for this! What a fast reply. Thank you.

It is a Chinese clone of an Arduino Nano.

That is useful to know. Thank you, Sir Paul. I was concerned because they both had serial in their name.

I've only really learned enough about it all to accomplish what I need to. I find it fascinating and would love to learn more. My sketch is very linear, very basic. Basically, at our orphanage there are many times the children (or volunteers!) will leave a bathroom light on or a closet light on. This project will use an optical relay to take power from each light switch. If the optical relay receives 240V it outputs a high signal. Each of those signals goes to one of the pins on the Nano. I arranged the pins in pairs; a Digital In and a Digital Out. If the IN is high, the OUT sends out a signal to a relay to turn on, and the relay powers the light. When that happens the time is read from the real time clock. If the switch hasn't been turned off in 15 minutes then the relay turns off automatically. The way the code is, right now someone would have to turn the switch off and back on again to turn the light back on. But now I think, since it is all digital, I could change the code in the sketch so that if the relay turns the light off, the Input pin would still be high because the lightswitch would still be on. Maybe I could make it so that if the relay is off but the input is high, if the input switches to low (someone walks into a dark bathroom and flips the switch), then the relay is activated again. It would be like a 3 way switch--sometimes up is on and sometimes down is on.

Thank you for your quick reply. I appreciate your help.

Not entirely true. In that situation you cannot send from the computer but you can use the monitor to see the traffic between Arduino and the serial peripheral, which can be useful.

1 Like

Then you should avoid using pins 0, 1. Even experts will only use those as a last resort, because it makes life so difficult having to disconnect each time you upload your code, and not being able to use serial monitor for debugging.

Not sure what you mean, please post a link.

There exist timer light switches, either with a button, or a PIR sensor, which will automatically switch off a light after an adjustable time. It would be safer and more reliable to use those, and maybe cheaper also, compared to building an Arduino project. If there is an electrical safety inspection of the building, they will demand you rip out your circuit because it will not be considered safe.

I don't mean to ruin your fun here, but there are safety considerations, for you building this, and for others, especially children, using it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.