I'm using the apc220 rf modules. Now I'm having the following problem:
My receiving arduino uno only receives data when the tx pin on the arduino (rx pin on the rf module) is disconnected. As soon as I connect the tx pin my serial monitor receives only the value 0.
Is my rf module broken, or can someone help me with this?
-
Which Arduino board are you using?Raceimaztion– Raceimaztion06/02/2015 09:10:42Commented Jun 2, 2015 at 9:10
-
1The Uno only has a single hardware UART. Are you attempting to use it to connect to both the USB-UART bridge and the RF module at the same time?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams06/02/2015 09:19:28Commented Jun 2, 2015 at 9:19
1 Answer 1
To have two serial ports on Arduino board like Uno use SoftwareSerial.h
.
Example
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Hello!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
Now after opening Serial monitor
you should see Hello! and then you can test SoftwareSerial
.
DO NOT FORGET!!!
When you connect to pins 2,3 or etc, this is TTL voltage level. You can't connect direct to RS232.
-
I know about Software Serial. The problem is that I use the rf modules for a quadcopter project and I need the memory of the rx pin, I think (correct me if I'm wrong).Michael– Michael06/02/2015 09:38:43Commented Jun 2, 2015 at 9:38
-
Ok, so if you know more than i expected :) Clear for me this: How you connect RF module and debug it at the same time having only 1 serial port? Remember that : pins 0 and 1 ar Tx, Rx for USB. You can use them only without USB attachedMartynas– Martynas06/02/2015 09:51:46Commented Jun 2, 2015 at 9:51
-
1And yes it takes more than memory. I would go for HW serial. replacing with Mega maybeMartynas– Martynas06/02/2015 09:54:46Commented Jun 2, 2015 at 9:54
-
Haha, I'm starting to know arduino bit by bit. :) Whem I'm uploading the code I always disconnect the rf module. After uploading the code I connect the rf module again. If I open the serial monitor it seems to work on 1 serial port. But I just ordered my arduino Mega because the serial communication is a big pain in the ass with the uno... :)Michael– Michael06/02/2015 16:29:37Commented Jun 2, 2015 at 16:29