UNO, USB, TX/RX and SCL/SDA

Hi!
I have been doing real time programming for many years, more than 40, and now I putting my nose into it again because of the easyness in using stuff like UNO and all available shields instead of wire wrapping everthing myself.

The environment is new to me. Can You sort out the things for me about the communication options available using an UNO?

There is the use of the USB connector and "Serial monitor" and I use it for debugging info. Looking at the UNO board I see "RX/TX" printed at the location of digital in-/out- put D0 resp. D1. It looks obvious that D0/D1 can not be used for digital I/O at the same time as serial communication is used on TX/RX.

Then there is the I2C using SCL and SDA. I find them near the USB connector but I feel I have seen videos using A0 and A1 for them. Can You sort this out for me? Is SCL/SDA hard wired to A0/A1?

Is it possible to communicate to/from an UNO on 3 different channels, USB, TX/RX and I2C?

Regards,
Railroader

The TX/RX pins of the MCU are permanently connected to the USB<>Serial chip, so best not to use them for anything else, unless you know what you’re doing. You can always use some software Serial code on another set of pins.
If you need more/faster Serial, then move to e.g. a Mega with it’s three extra hardware serial channels.
The I2C pins on an Uno are A4 and A5, and are duplicated (exactly the same) near the Aref pin for compatibility.
Google e.g “Arduino Uno pinout” (images).
Leo…

1. Please check if the following diagram provides you some information as to the role/use of various IO lines of the ATmega328P MCU of the UNO Board for exchanging data with peripheral devices and sensors.

Figure-1: Hardware Block Diagram of ATmega328P MCU showing data exchange

2. Please check if the following diagram can help you finding the wiring level connection between the UART Port (hardware) of the MCU and the Serial Monitor.

Figure-2: Connection between UART Port and Serial Monitor

3.

It looks obvious that D0/D1 can not be used for digital I/O at the same time as serial communication is used on TX/RX.

During uploading of a sketch, there must not be any IO devices connected with DPin-0 (D0) and DPin-1(D1). (In some cases, we need these IO lines for connecting IO devices like port driven 7-segment display devices or UART Port driven HC12 Radio Module.)

4.

Then there is the I2C using SCL and SDA. I find them near the USB connector but I feel I have seen videos using A0 and A1 for them. Can You sort this out for me? Is SCL/SDA hard wired to A0/A1?

The I2C/TWi Bus has been formed by borrowing IO lines (PC4 and PC5) from port-C.

5.

Is it possible to communicate to/from an UNO on 3 different channels, USB, TX/RX and I2C?

The possibilities are:
(a) UART <—> USB <—> Serial Monitor (extra devices from UART Port should remain disconnected)

(b) Soft UART <—> HC12
(c) MCU <—> I2C Bus

Railroader:
Then there is the I2C using SCL and SDA. I find them near the USB connector but I feel I have seen videos using A0 and A1 for them. Can You sort this out for me? Is SCL/SDA hard wired to A0/A1?

On earlier UNO models the I2C bus only appears on A4 and A5. The R3 model adds two I2C pins near the USB connector that are also connected to A4 and A5. On other models (Leonardo, MEGA) that have the I2C bus on other pins, the I2C pins are connected to those other pins. This allows modern Aruino shields that need I2C to find those pins in a fixed location regardless of model.

Railroader:
Is it possible to communicate to/from an UNO on 3 different channels, USB, TX/RX and I2C?

On the UNO, RX and TX are used by the USB-to-Serial interface so you can’t use both USB and RX/TX. On the Leonardo the USB connector goes to the USB pins on the processor, leaving RX and TX (Serial1) for use at the same time as USB (Serial). On the MEGA there are three spare serial ports: Serial1, Serial2, and Serial3.

I2C uses addresses so multiple devices can be slaves that share the I2C bus.

SPI shares three pins between all slaves and uses one digital pin per slave to select which device can use the bus.

SoftwareSerial is a built-in library that implements a serial port on any spare pair of pins. There are third-party libraries that do similar and may be better for some cases.

Software can be used to implement the OneWire bus on a digital pin.

Software can be use to emulate an I2C bus on a pair of spare digital pins.

If you need to talk to a hardware interface that is not built in to the processor, you can probably find software to emulate it.

Thanks a lot! I will need to reread Your answer to fully understand the details.
Those extra I2C pins origin from standard pins might be surpricing.
I operate a stepper motor shield, a Protoneer V3. On that board I can control the direction of 2 steppers from either digital outputs or analog I/O. Built in conveiniences confuses me. Protoneer has not answered my request for a board drawing…
Communication I/O looks the same to me, some things unknown. Knowing such basics is valuable before starting new projects.

Railroader:
I operate a stepper motor shield, a Protoneer V3. On that board I can control the direction of 2 steppers from either digital outputs or analog I/O. Built in conveiniences confuses me. Protoneer has not answered my request for a board drawing…

A quick Google search turned up a schematic here:

Hi!¨
Thanks for the link

When I, as a newbe, tested the Protoneer board I found this:

// analogWrite( 2, Low);// x-step analog
// analogWrite( 3, Low);// y-step analog
// analogWrite( 4, Low);// z-step analog
// analogWrite( 5, Low);// x-dir analog
// digitalWrite(2, LOW);// x-step digitalt
// digitalWrite(3, LOW);// y-step digitalt
// digitalWrite(4, LOW);// z-step digitalt
// digitalWrite(5,LOW); // x-dir digitalt
// digitalWrite(6,HIGH);// y-dir HIGH == CW LOW == CCW
// digitalWrite(7,HIGH);// z-dir HIGH == CW LOW == CCW

Looking at the drawings I cant find the explanation why the analog pins do the same work as the digital ones. My fear is taht, using the D2 - D7 the analog pins 2 - 5 are accupied in some way.

Note: the "analogWrite()" function is used to control duty-cycle on the PWM pins (3, 5, 6, 9,10, and 11). It takes a value from 0 (always off) through 128 (on half the time), to 255 (always on). If you use analogWrite() on a pin that does not support PWM you will get LOW for values below 128 and HIGH for values from 128 to 255.

The "analogRead()" function can be used to read analog values from the analog input pins (A0 through A6). The values range from 0 (0V) to 1023 (5V).

You can see from the schematic that Pin 8 is connected to the Enable pin on the four stepper drivers. The circle on the pin means it is "active low" so set Pin 8 to LOW to get any motion.

X-Step, Y-Step, and Z-Step outputs are Pins 2, 3, and 4 respectively.
X-Dir, Y-Dir, and Z-Dir outputs are Pins 5, 6, and 7 respectively.
X-Endstop, Y-Endstop, and Z-Endstop inputs are Pins 9, 10, and 11 respectively.

For each step, set the Dir pin and pulse the Step pin.

Pins 11 and 12 are Spindle Enable and Spindle Direction.

There are three jumper inputs on A0, A1, and A2. These are acting as digital input pins.

The A3 pin is used as a digital output to control a coolant pump.

A4 and A5 are the I2C pins and can be used to drive an LCD.

Thanks a lot for Your answer! There where some news for me. Adds to Your karma.

I realize I was totaly wrong thinking I was using the analog pins in my first tests to figure out about how to make the stepperboard run the first stepper. I ordered PWM from the digital outputs and didn't notice it......

My mistaken code:

if (motor == motorX )
{
digitalWrite( 5, dir);//digital dir does not owerride analoWrite(5, dir)
// analogWrite( 5, adir);// x-dir KLAR High == CW Low == CCW
digitalWrite( 2, HIGH);// digital x-step
// analogWrite( 2, High);// analog x-step
digitalWrite( 2, LOW);// digital x-step
// analogWrite( 2, Low);// analog x-step
delay(5);
}

The language is Ardiono IDE so searching the Atmega328 pages will not give me the instructions available in IDE.
Can You provide me a link to the standard IDE functions available?

One day or Another I migh want do use A0 - A5 as outputs..

https://www.arduino.cc/reference/en/

Thanks a lot gF! Karma++;

There is the goldmine I was looking for.

Also thank You o GolamMostafa!

and johnwasser.