use pin 0 (RX) and 1 (TX) for wireless connection

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!!

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" :slight_smile:

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

AHA,

I am also sending "I sent". AHA :slight_smile:

FJ

And how can I transform those numbers to readable signs?

Thanks.

FJ

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

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

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

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

Hi!

I tried to build a direct connection between two arduino boards. So there is a direct connection between TX of the one board and RX of the other board. And it works - sometimes. If I remove the direct connetion and again plug it in, I receive total different values. After disconnecting and connecting again there is the right value again (SOmetimes I get 19, sometimes 164, and then 52, which is correct then).

This is the code I used.



RECEIVER:
int income = 0;

int receiveLED = 12;

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

void loop(){
income = 0;

if (Serial.available() > 0) {
income = Serial.read();
Serial.println(income);
if (income == 79){
digitalWrite(receiveLED, HIGH); // sets the LED on

}else{

digitalWrite(receiveLED, LOW);

}
}else{
digitalWrite(receiveLED, LOW);

}

}



TRANSMITTER:

int send = 52;

int sendLED = 12;

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

void loop(){
Serial.print(send, BYTE);
}


Thanks for your help!!

are both boards connected on ground?

Hi!

You told me that there arduino accepts 5V (with a little tolerance) as HIGH. And 0V for LOW. Is there somewhere some information which range of tolerance arduino accepts?

Thanks!!

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

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

are both boards connected on ground?

Mhm, what do you mean by that? Recipient and Transmitter module are connected to ground.

Thanks for your help!!

if you leave out your transmitter and receiver and connect two arduino boards directly (by cable), it is important that you not only connect RX to TX but also ground to ground. did you do that? the board-to-board thing should work reliable before you start on the over-air transmission.

about the HI/LOW voltage:
i don't know if there is a page on arduino's electronic specs. but i think that the atmega8 and arduino use TTL standard. see wikipedia for an explanation. logical values (0 or 1) are defined as ~0V and ~5V.

i think the max856 might be the IC specially made for your needs. but as i said, a transistor plus a resistor should be enough to amplify your 0.8V signal to a 5V. maybe you should start another thread in the forum to find somebody who can help you with the values/models. though i never needed to boost a signal yet, it seems quite a standard problem to me. (with an easy solution)

your pdf at conrad.at isn't reachable at the moment. so i searched on google for similar modules. one thing you could try (at your own risk!) is putting a 10kOHM between +5V on arduino and the RX pin, where your receiver is connected to on the same board. if your receiver's output is "open-collector" it might work. in this case the resistor will work as a pull-up resistor and boost the HIGH signal.

but you should definetely switch to a lower baudrate, say 2400bps. AM modulation is slower than i thought at first. similar products to yours recommend 2400 to 4800bps maximum.

//kuk

Hello everyone!

Forgive me if the following is a stupid question, but I'm rather new to this world of electronics in general and Arduino.
I find it rather interesting though :slight_smile:

I was wondering if it is (of ever will be) possible to connect an Arduino board via WIFI to a computer. My search attempts so far only yielded Bluetooth as a solution.. or hacking a Linksys router (great but I don't have one).

Looking forward to a reply.

Kind regards,

Ethan :slight_smile:

hi ethan,

i think the linksys solution is the cheapest solution to get arduino on a wifi-network.

arduino only supports communivation over a serial line. but even if you'd find a serial wifi-adapter, the protocol to implement would be too big for the board.

i think that there are"adapters" wifi<>serial that are in fact small pcs running a kind of linux. and they don't come for cheap. that's why everyone uses the linksys routers, which are basically the same thing for less money.

bluetooth on the other hand was designed to be a serial cable replacement. that's why bluetooth would be the easiest way.

//kuk

Wow, thank you for the both informative and quick reply.

I am not looking for wireless communication across an extreme distance, so perhaps I should indeed take a closer look at Bluetooth.

After a quick search, I noticed that there are possibilities for extending ranges a bit, lol :wink:
http://www.wifi-toys.com/wi-fi.php?a=articles&id=21

A small bump with two small questions, just to make sure I understand everything correctly, being the beginner that I am :wink:

  1. It is only possible to connect 1 device to the Arduino via the Serial (rx, tx) port, right?

  2. Is it possible to connect multiple SPI device to the Arduino? Arduino being the master with multiple slaves?

Thank you once again! :slight_smile:

  1. Yes, only one device per serial port. if more than one device sends at once, your data is unreadable. You can connect a different device to the RX pin than to the TX pin though. if you don't need bidirectional communication that is. There's also a tutorial on a software-based serial-port, which basically means RX and TX capabilities on other pins than 0 or 1.
    i don't know how fast and stable this is though.

  2. Yes. I think there's a tutorial on SPI. you probably need to adjust the code.

Ah, ok. Thank you! :slight_smile:

And wow, what a fast reply again :wink:

:sunglasses: