system
June 26, 2013, 12:36am
1
I work with Arduino Uno Atmega 328P.Comunicate over RF between two aduinos but one i put on breakboard with the 16Mhz crystal.The other is on the arduino uno socket to view serial port.
I use this RF Transmitter and receiver:
http://inmotion.pt/documentation/sparkfun/WRL-08946/MO-SAWR.pdf
http://inmotion.pt/documentation/sparkfun/WRL-08950/MO-RX3400.pdf
I use this code:
http://www.seeedstudio.com/wiki/Grove_-_433MHz_Simple_RF_Link_Kit
I only chance the receive code,like this:
if(vw_get_message(buf, &buflen)) // non-blocking I/O
{
int i;
// Message with a good checksum received, dump HEX
Serial.print("Got: ");
for(i = 0; i < buflen; ++i)
{
Serial.print(buf[i]);
}
Serial.println("");
}
I make this change because i want to receive a char.
The problem is i dont receive a char but numbers.If i put the code with any chance i have de Hex i convert manualy it to char and a have the char what is supose to receive.
I see many codes and no one have to convert manualy because VirtualWire.h send chars or arrays.
I dont have any schematics.
Any hepl for this?
If you want to send in hex then try Serial.write() or Serial.print(buf*,HEX);*
Mark
system
June 26, 2013, 12:45am
3
Thank you for the reply.
I want to receive the char "Hello" that transmmitter send but i just receive numbers.
Grrr - its up to you to decide if there numbers or not!
41 42 43 44 is ABCD if 41 etc are in hex.
65 66 67 68 is ABCD if 65 etc are in dec.
Mark
system
June 26, 2013, 1:18am
5
Change your output code to this:
for(i = 0; i < buflen; ++i)
{
Serial.print((char) buf[i]);
}
system
June 26, 2013, 1:26am
6
The transmitter have this code:
#include <VirtualWire.h>
int RF_TX_PIN = 2;
void setup()
{
vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
vw_setup(2000); // Transmission speed in bits per second.
}
void loop()
{
const char *msg = "hello";
vw_send((uint8_t *)msg, strlen(msg)); // Send 'hello' every 400ms.
delay(400);
}
The receive this:
#include <VirtualWire.h>
int RF_RX_PIN = 2;
void setup()
{
Serial.begin(9600);
Serial.println("setup");
vw_set_rx_pin(RF_RX_PIN); // Setup receive pin.
vw_setup(2000); // Transmission speed in bits per second.
vw_rx_start(); // Start the PLL receiver.
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if(vw_get_message(buf, &buflen)) // non-blocking I/O
{
int i;
// Message with a good checksum received, dump HEX
Serial.print("Got: ");
for(i = 0; i < buflen; ++i)
{
Serial.print(buf[i]);
}
Serial.println("");
}
}
Put like this:
Serial.print(buf[i]);
Like this is supose receive a array.I want to receive de "Hello" that the transmitter send. I receive like ones and zeros.I think wrong?
system
June 26, 2013, 1:39am
7
Thank you aarondc solve my problem.