14.1 Serial
Hardware Wiring
Cited directly from https://www.arduino.cc/en/Tutorial/SoftwareSerialExample:
"There is no circuit for this example. Make sure that your Arduino or Genuino board is attached to your computer via USB to enable serial communication through the serial monitor window of the Arduino Software (IDE).".
Due to the comments inside the sketch code,
"The circuit:
RX is digital pin 10 (connect to TX of other device)
TX is digital pin 11 (connect to RX of other device)"
So, to test the serial communication, it's better we found some device/module, which comes with an RX and TX pins. Therefore, we carry out the test with a Wifi ESP8266 module, which will be detailedly discussed again in 14.2 Wifi - ESP8266.
We then connect the pins as:
ESP8266 | Arduino UNO R3 |
GND | GND |
VCC | 3.3V |
CH_PD | 3.3V |
TX | Virtual RX, namely, pin 10 |
RX | Virtual TX, namely, pin 11 |
Sketch
The code can be found at Examples_Arduino - arduinocc - _001_Serial - _001_Serial.ino, which is directly copied from https://www.arduino.cc/en/Tutorial/SoftwareSerialExample.
Outcome
However?
So far, we can clearly see Goodnight moon! has been successfully output to the Monitor Serial dialog. However, in our sketch, it's quite clear that Hello, world? should also be output somewhere. But, where? Clearly, mySerial defines the virtual serial port using pin 10 and pin 11. So, there must be a 2nd serial port on the Wifi Module ESP8266.
Last updated