Pages: [1] 2   Go Down
Author Topic: use pin 0 (RX) and 1 (TX) for wireless connection  (Read 6201 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

i would like to biuld a radio connection. Is there somebody having experience with that?

I have attached a sender (to TX pin 1) and a recipeint (RX) to my arduino board.

How can I send information between those two components?

Serial.write and Serial.read?

Thanks for your help!
Logged

Bremen, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,
some additional information about the type of your wireless sender and receiver, protocol, etc... might help to get a more detailed reply. until then here are some starting points:


reading this might help, the wiring code examples will also work on arduino (only Serial1 is missing):

http://wiring.org.co/reference/libraries/Serial/index.html


this is a little more advanced:

http://www.tigoe.net/pcomp/code/archives/arduino/000765.shtml#000765


some more examples all of them using serial communication:

http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/index.html



(in case you are using sparkfuns bluetooth modem all you need to know is right here:
http://wiring.org.co/learning/tutorials/wireless.html)
« Last Edit: September 11, 2006, 05:07:00 pm by kr1 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

Thanks for answering!

This is what I have:
transmitter:
   freq: 433.92 MHz
   HF modulation: AM
   Voltage: 3 to 12 V/DC
   Power consumption: 2 to 10 mA
   bandwidth: 2 kHz
   Input SIgnal: Square wave signal (Manchester encoding) - amplitude depending on strengh of operation voltage of transmitter

receiver:
   freq: 433.92 MHz
   HF modulation: AM
   Voltage: 5 V/DC
   Power consumption: 1 mA
   bandwidth: 2 kHz
   Output SIgnal: Hi +0.8 V; Lo 0 V

The desciption say:
Externally produced (I assume with the arduino) serial data are high-frequency modulated by the transmitting module and transmitted to the receiving module via radio link. The receiver demodulates the high-frequency signal and provides the transmitted serial data.

First I would like to test the radio link on just one arduino board. But later I will have a second arduino to allow radio communication between them.

I will have a look at the links, thank you!!



image taken from www.conrad.at
« Last Edit: September 12, 2006, 02:33:29 am by lenzfr » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

THis is some technical info about hte TX and RX module



http://www2.produktinfo.conrad.com/datenblaetter/125000-149999/130428-sp-01-en-Sender_Empfaenger_Modul_Set_433MHz.pdf

I have a general question. How do I say the arduino board to use pin 0 and pin 1 for serial communication?

pinMode(0, INPUT);   ??
pinMode(1, OUTPUT);  ??

FJ

« Last Edit: September 12, 2006, 02:38:22 am by lenzfr » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't have to do any setup to use pins 0 and 1 for Serial communication.  Just call the standard Serial commands - Serial.begin(), Serial.print(), etc.  But you might need to do other setup to get your particular transmitter/receiver pair working.
« Last Edit: September 12, 2006, 05:26:37 am by mellis » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, this is the code i tried to use:

int send = 5;
int income = 0;

void setup() {
  Serial.begin(9600);  
}

void loop(){

    // transmitter
    Serial.print("I sent: ");
    Serial.println(send, DEC);


    // reciever
    if (Serial.available()) {
        // read the incoming byte:
      income = Serial.read();

            // say what you got:
            Serial.print("I received: ");
            Serial.println(income, DEC);
    }
}


But I get an errror when i want to move the code to the arduino board. --> "Programmer is not responding." (even through pressing RESET)
When I remove the PINS from 1 (TX) and 0 (RX) installation is possible

THis is how I configured the board and the modules:


Thanks for your help
« Last Edit: September 12, 2006, 07:04:08 am by lenzfr » Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well, it's normal that uploading programs won't work when you've got RX of the board connected to your receiver. the RX and TX pins on arduino are more or less directly connected to your serial lines that go to the USB port.

i don't know if i fully understand what you're trying to do.
you want to receive serial data on arduino, but who is the sender?

for debugging, i propose, that you connect BOTH the transmitter and receiver to the SAME arduino board.

receiver> RX
transmitter> TX

and then have an led (on pin 13) blink whenever there is serial data arriving.

the board should receive what it sends now. you don't have to care for the baudrate settings on your sender like that. just start with 9600.

TIP: to test the code, i would suggest leaving the transmitter and receiver out. just connect RX and TX on arduino with a jumper cable.

if arduino receives "something". you should re-write the code to see if it receiving the correct date.
for example: if the received byte is a "5" light up the led on pin 13.

hope, i didn't misunderstood you.

your pdf/ data sheet wasn't very helpful. can you post the product link to conrad?

//kuk

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks  for answering.

I'll try what you posted.


The modul can be seen at www.conrad.at --> Article-Nr.: 130428 - 62

This is a better description http://www2.produktinfo.conrad.com/datenblaetter/125000-149999/130428-an-01-ml-Sender_Empfaenger_Modul_Set_de-en-fr.pdf

Bye!
« Last Edit: September 12, 2006, 09:40:40 am by lenzfr » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I tried it with connecting RX and TX with a jumper cable.

LED is blinking when it receives data.

int send = 5;
int income = 0;
int led = 12;

void setup() {
  pinMode(led, OUTPUT);
  Serial.begin(9600);  
}

void loop(){

    // transmitter
    Serial.print("I sent: ");
    Serial.println(send, DEC);

    // reciever
    if (Serial.available()) {
        digitalWrite(led, HIGH);   // sets the LED on
        delay(1000);                  // waits for a second
        digitalWrite(led, LOW);    // sets the LED off
        delay(1000);      
      
        income = Serial.read();
        Serial.print("I received: ");
      Serial.println(income, DEC);
       }
    delay(2000);
}



But the output is quiet strange:

I sent: 5
I received: 32
I sent: 5
I received: 115
I sent: 5
I received: 101
I sent: 5
I received: 110


The value of "I received" should be 5, I assume!?

Thanks for help!!
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hehe,

what you're receiving is actually totally correct. it's the ascii-code for the string "i sent:" which you were sending over the TX pin. see www.lookuptables.com

try just sending "5". if you're receiving a "53", tha's ascii again for the "5" :-)

better send you're values as BYTES rather then DEC. it's less confusing to mess with.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

AHA,

I am also sending "I sent". AHA :-)

FJ
« Last Edit: September 12, 2006, 11:49:18 am by lenzfr » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And how can I transform those numbers to readable signs?

Thanks.

FJ
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm, why do you want them to be "readable"?

let me try to explain:

arduino is ALWAYS sending out bytes. that is 8 bits, which represent a number between 0 and 255.

these bytes/numbers MAY be interpreted as ascii code. which is what a terminal application on you computer does.
if you want your computer to display the letter "H", arduino actually sends out the number 72 in binary.

if you want your computer terminal application to display the decimal number 72, you have to send each digit binary encoded: 55 & 50.

arduino has built in serial functions for this:
"serial.write(72, INT);" does exactly what i described: it sends both digits (7 & 2) ascii encoded. so it is sending TWO bytes

if you do "serial.write(72)" just one byte is sent. that is 72 in binary. you're terminal application nevertheless will interpret this data ascii-wise and display the letter "H".

this might seem confusing at the first glance. and someone please correct me if i'm wrong. once you get the concept of serial communication everything is logical. but i remember myself going nuts on this.

// best, kuk





Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your help!!

I think I have a problem with transmitter or receiver - dont know.

If I direktly connect PIN 0 and PIN 1 everything works great. Butt if I replace TX with the transmitter module and RX with the receiver module nothing happens nothing happens. SOmetimes receiver gets any values. How do I best debug this problem?

As said, I'm using the  www.conrad.at module --> Article-Nr.: 130428 - 62  

This is the code I have - I attached RX and TX module on one arduino board:

int send = 52;
int income = 0;

int receiveLED = 12;

void setup() {
  pinMode(receiveLED, OUTPUT);
  Serial.begin(9600);  
}

void loop(){
    income = 0;    
    
    //transmitt
    delay(700);  
    Serial.print(send, BYTE);
 

    //receive
    if (Serial.available() > 0) {
           income = Serial.read();
           //Serial.print("receive:");
           //Serial.println(income);

           if (income == 52){
              for (int i=0; i < 3; i++){  
              digitalWrite(receiveLED, HIGH);   // sets the LED on
              delay(300);                          // waits
              digitalWrite(receiveLED, LOW);    // sets the LED off
              delay(300);      
            }      
           }
    }    
}


Thanks for helping me!!
fj
« Last Edit: September 18, 2006, 01:58:31 pm by lenzfr » Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 295
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well i wanted to write you that it should just work now. but then i read the datasheet you provided a third time :-)

sending and receiving probably works right now. the problem is your receiver's output signal. it's 0 volts for LOW but only 0.8 volts for a HIGH. arduino expects 5V with a little (!) tolerance.

you need to amplify the signal, which should be no hard task. but i don't think i'm the best person to help you here. i guess a single transistor could do the job. there should be plenty of infos on the internet.

keep us updated!

best, kuk
Logged

Pages: [1] 2   Go Up
Jump to: