Happy New Year!
Please help me to creating rs485 wired connection for Arduino pro micro. I want to connect Arduino Pro Micro with Raspberry Pi and I can`t do it. I want to solve this problem step by step. First, I tried to receive a signal to another arduino. I use arduino pro micro as an transmitter. And arduino nano as a receiver.
Connections:
arduino pro micro arduino nano
0 pin (TX) <-> 8 pin (software RX)
1 pin (RX) <-> 9 pin (software TX)
Transmitter code (pro micro)
void setup () {
Serial1.begin (9600);
}
void loop () {
Serial1.write (1);
Serial1.print (1);
Serial1.print ("A");
delay (500);
}
Receiver code (nano)
#include <SoftwareSerial.h>
// software serial # 1: RX = digital pin 8, TX = digital pin 9
SoftwareSerial portOne (8, 9);
void setup () {
// Open serial communications and wait for port to open:
Serial.begin (9600);
while (! Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin (9600);
}
void loop () {
// By default, the last intialized port is listening.
// when you want to listen on a port, explicitly select it:
portOne.listen ();
Serial.println ("Data from port one:");
// while there is data coming in, read it
// and send to the hardware serial port:
while (portOne.available ()> 0) {
char inByte = portOne.read ();
Serial.print (inByte);
}
// blank line to separate data from the two ports:
Serial.println ();
}
The transmitter is powered by charging. The receiver is connected to the USB port of the computer. The serial port monitor only outputs the following:
Data from port one:
Data from port one:
Data from port one:
Data from port one:
Why is the Serial1 port on pro micro not working and where is my mistake?