In fact; I'm new in this field and this website as well. I do not have that much experience about programming, but I can learn and understand the things fast.
I get interesting to deal with electronic and programming especially with Arduino, since my discipline is purely Electrical. I'm looking for you help for my project. I explain below:
In fact, I'm working on Arduion board called Seeeduino ATMEGA 168. I would like to setup a code for transmitting and receiving signal wirelessly by using transmitter RTFQ2 and receiver RRFQ2 Hybrid Module. I would like to connect the transmitter in Arduino board and the receiver in another Arduino board . Then transmitting an analog signal using potentiometer joystick and receive it by printing the transmitted and received signals into the Serial Monitor to observe the function.
In fact; I'm working on a project with other colleague to design a control system for sailboat to be used by a disabled person.
Therefore; we would like initially from you guys if you could provide us with some basic codes for transmitting and receiving signals through two Arduino boards using Radio control circuits and 2-Axis joystick. Or if you could advise....
Your hard work is appreciated.
I hope you guys understand my explanation and needs.
I'm looking for your kindly support on this soon as possible.
In fact; I can write some code to defines the inputs and outputs, but I do not know how to convert the analog singnal to digital. Because we cannot send an analog signal having 0-5v range. Therefore; I'm looking for how can I do this or otherwise to use one of Arduino board function called ADC (analog to digital converter).
One more think if you do ot mind, how can I let the microcontroller understand I wnat to transimtt this analog singal through the tx?
I mean which command I have to write to let the microcontroller to understand my needs!
to transmit serial commands through the tx pin all you have to do is:
Serial.print(joyval);
joyval being the value that was taken from the analogRead of the joystick pin.
You might also want to look into NewSoftSerial (NewSoftSerial | Arduiniana) which allows you to use any digital pin as a 'virtual' serial port so that you are not using the hardware serial pins (they are used when uploading code through the USB port so you would need to disconnect anything from them before uploading new code)
What about the receiver Serial? I mean once I transmitt the signal using Serial.print(joyval) command, which command I have to write to let the receiver to read the signal transmitted?
Is it going to be Serial.Read(joyval)?
Or Serial.Write(joyval)?
Could anyone give an advise about this code to transmit an analog signal from 2-axis potentiometer from one Arduino board to be received by another Arduino board!?
The other arduino needs to wait for serial. It cannot tell if it is val1 or val2 but as one will be after the other there shouldn't be a problem.
Download the newsoftserial library that I linked and put it into the arduino libraries folder on your hard drive then look at this code...
If you use this code on the other arduino then it will take any values that it receives and send them to the serial monitor (if the usb cable is plugged in):
#include <NewSoftSerial.h>
NewSoftSerial RFSerial(2, 3); //'virtual' rx pin, 'virtual' tx pin
void setup()
{
Serial.begin(9600);
RFSerial.begin(9600);
}
void loop() // run over and over again
{
if (RFSerial.available()) {
Serial.print((char)RFSerial.read());
}
}
Experiment with that and see where you get. You could plug the RF module into the receiving arduino's hardware serial ports and then it would send it to both the arduino and computer without any code.
There are lots of possible reasons why that might not work out quite according to plan but it should give you an idea.
Is it possible to attach the RF modules (transmitter and receiver) in oneArduino board? I mean, transmit an anlog signal and receive it through the same Arduino board? And then print the outcomes into the Serial Monitor.
Yes, by using the newsoftserial library mentioned above you can send from a virtual pin to an RF module and the receive through the hardware serial pins (0 & 1) which will send it to the serial monitor (assuming baud rate is set correctly)
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.
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.
could you please Guys advise the outcomes
To be honest, I think it's just me reading this thread...
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).