Pages: 1 [2] 3   Go Down
Author Topic: Help to get two Arduino communicate through RF  (Read 3696 times)
0 Members and 1 Guest are viewing this topic.
Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again,,

I ran it as shown below:
tx & rx code:
#include <NewSoftSerial.h>

int ledPin = 13;
int potPin1 = 0;
int potPin2 = 1;
int val1 = 0;
int val2 = 0;
int rx = 0;
int tx = 1;
NewSoftSerial RFSerial(0, 1);


void setup() {
 pinMode(ledPin, OUTPUT);
 pinMode(rx, INPUT);
 pinMode(tx, OUTPUT);
 Serial.begin(4800);
 RFSerial.begin(4800);
}

void loop() {
 val1 = analogRead(potPin1);
 val1 = map(val1, 0, 1023, 0, 255);
 delay(100);
 Serial.println(val1);
 val2 =analogRead(potPin2);
 val2 = map(val2, 0, 1023, 0, 255);
 Serial.println(val2);
 if (RFSerial.available()) {
    Serial.print((char)RFSerial.read());
  }
}

I think the data shown in Serial monitor refer to the transmitter side. I do see changes in accordance to the potentiometer, but there is no receiving signal at all. I check that by using Multimeter and I measured the voltage in transmitter when the joystick was in neutral.
It gives me 2.35v, once I moved forward gives me 1.50 v but when moved backward remains the same as neutral voltage (2.3v).
I tested only one axis.
Also, I measured the voltage in receiver side I found the voltage around 4.15v.

could you please Guys advise the outcomes I got and even the code I wrote. Am I in right truck? Or do I need to modify things? Or do I need do something else.

Your comments are really appreciated.

Cheers.. smiley

Yousuf
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
#include <NewSoftSerial.h>

int ledPin = 13;
int potPin1 = 0;
int potPin2 = 1;
int val1 = 0;
int val2 = 0;
NewSoftSerial RFSerial(2, 3);


void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(4800);
RFSerial.begin(4800);
}

void loop() {
val1 = analogRead(potPin1);
val1 = map(val1, 0, 1023, 0, 255);
delay(100);
RFSerial.print(val1);
val2 =analogRead(potPin2);
val2 = map(val2, 0, 1023, 0, 255);
RFSerial.print(val2);
delay(1);
if (RFSerial.available()) {
   Serial.println((char)RFSerial.read());
 }
}

Right... Plug the transmitter one into 2,3 and the receiver into 1,2 respectively and then you should see the values from the potentiometers mapped from 0-255 in the serial monitor. The code is taking the pot values, mapping them 0-255 then sending them to the software serial port (2,3 - rx,tx) to the RF module. This then sends it via RF to the receiver module (plugged into 0,1) where it then displays on the serial monitor.

Take a look at what I changed on the code and that might also give you a better idea of what it's all doing.

I may be misunderstanding what RF units you are using but I think it should be fine.

Quote
could you please Guys advise the outcomes
To be honest, I think it's just me reading this thread...

Mowcius
« Last Edit: April 17, 2010, 11:17:26 am by mowcius » Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks mate,

I really appreciate your hard comments toward my concern.

I will re-test it now and send some feedback.

Sorry for any inconvenience mate.

All the best.

Cheers  smiley
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using FM transmitter and receiver Hybrid Modules (FM-RTFQ2 & FM-RRFQ2) with 433 MHZ.
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Plug the transmitter one into 2,3 and the receiver into 1,2 respectively

What do mean by that? Do you mean the pins number 2,3 & 1,2.

In transmitter I have 5 pins :
two for ground.
one for vcc.
one for data input.//I plugged this into the Arduino board as tx pin (1).
one for external antenna.

In receiver I have 7 pins:
two for ground.
one for vcc.
one for AF output.
one for received signal strenght output.
one for data output.// I plugged this into the Arduino borad as rx pin (0).
one for data in (antenna).

Please advise.

Cheers
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well I assumed that the modules were bi-directional but in that case, plug the transmitter pin into pin 3 (the tx pin from the virtual serial pins), and the receiver into pin 1 (the tx on the board so it sends it to the computer serial monitor)

Mowcius
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm lost mate, what do you mean?

In fact, I'm using Seeeduino board of ATMEGA 168.

I have got pins from 0-13 on the digital side. These pins are as follow:
0=rx
1=tx
2=nothing mentioned on the board.
3=pwm
4=nothing mentioned on the board.
5=pwm
6=pwm
7=nothing mentioned on the board.
8=nothing mentioned on the board.
9=pwm
10=pwm
11=pwm
12=nothing mentioned on the board.
13=nothing mentioned on the board.

Plus GND and AREF

Please advise.

Cheers.
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Plug the transmitter pin into pin 3 (this is defined in the code as a serial pin - that is what the newsoftserial library does)
Plug receiver into pin 1 (this is the standard hardware tx pin and will send anything that it gets, to the computer)

then use my code above and you should be getting somewhere.

Mowcius

Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay mate,

I will do it now.

Thank you very much.

Cheers.
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mate ...

I did not get anything in Serial Monitor.

I plugged the transmitter input data pin into the pin 3 of the Arduino board (which is called PWM=3 as I mentioned to you in previous comments about the pins description). And the receiver input data pin into the pin 1 of the arduino board (which is called tx=1 as I mentioned to you in previous comments about the pins description).

Please advise.

Cheers.
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I suggest you have a play around tonight and ask again another day once you have had a go at sorting it out yourself.

Mowcius
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much for your expression.

I'm sorry if I caused you a headache and if I bothered you with my concerns.

I wish you great day mate and I'm very very very sorry again.

Thanks a lot.

Yousuf
Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please Guys Advise..

I did everything I knew but did not work at all the time.

I did not understand the previous comments regarding the pin assignments plugging.

Please Adviiiiiiiiiiiiiiise.

All the best.

Cheers..  :-[

Logged

Middlesbrough, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once again I want to communicate the RF module with each other by printing the data received by receiver which transmitted by transmitter into the serial monitor to observe the outcomes.

I did test this  code, but there was nothing print.

#include <NewSoftSerial.h>

int ledPin = 13;
int potPin1 = 0;
int potPin2 = 1;
int val1 = 0;
int val2 = 0;
NewSoftSerial RFSerial(2, 3);


void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(4800);
RFSerial.begin(4800);
}

void loop() {
val1 = analogRead(potPin1);
val1 = map(val1, 0, 1023, 0, 255);
delay(100);
RFSerial.print(val1);
val2 =analogRead(potPin2);
val2 = map(val2, 0, 1023, 0, 255);
RFSerial.print(val2);
delay(1);
if (RFSerial.available()) {
  Serial.println((char)RFSerial.read());
}
}

so, please I advise.

I want to send one axis signal only.

How????

Cheers..
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First off, forget trying to read the pot pins, and sending those values.

Start with making one Arduino send "Hey, there", and making the other receive it.

Only when that works, expand the sketch to send meaningful data.
Logged

Pages: 1 [2] 3   Go Up
Jump to: