RF Transmitter and Receiver WRL-10535 and WRL-10533

You buy it on a board instead:

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=53

CrossRoads:
You buy it on a board instead:

SparkFun Transceiver Breakout - nRF24L01+ - WRL-00691 - SparkFun Electronics

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=53

Lol thanks, I actually found the board version on sparkfun after I posted that, but wasn't going to pay 20 dollars for it on a board, however $5.50, that I can probably swing :slight_smile:

9V's batteries are horrible... High Cost/Low Current.

You would do well to buy a $15-$20 radio control 9.6V rechargeable (usually comes with a charger too).

And the same module here for $2.75 US (this price is typical of many vendors on Ebay) 5.50 Ea should be for a pair... Check it out.
[price-up] NRF24L01 2.4G Wireless Module, Genuine Chip – ElectroDragon.
I recently bought 6 of those devices and a USB Receiver "Dongle" for $9.95... "Free Shipping"... Too ? $22.00 Ea... Yeah I'll Bet... that they would love to sell a bunch at that price, oh yeah and the Features on the $22.50 board are built into the Chip. All of the nRF24XX series Ic's have those features... They're part of what drove the original design and that was an inexpensive Chipset that could co-exist with all the other ISM stuff as well as Microwave Ovens @ 2450 Mhz and most capable of 1000 watts or more @ ~ 2450 mhz as the ovens use a "Power Oscillator" (A Klystron of Magnetron tube) neither of which has any external frequency control (Oscillating Frequency is set by internal cavity dimensions primarily).

Doc

Docedison:
And the same module here for $2.75 US (this price is typical of many vendors on Ebay) 5.50 Ea should be for a pair... Check it out.
[price-up] NRF24L01 2.4G Wireless Module, Genuine Chip – ElectroDragon.
I recently bought 6 of those devices and a USB Receiver "Dongle" for $9.95... "Free Shipping"... Too ? $22.00 Ea... Yeah I'll Bet... that they would love to sell a bunch at that price, oh yeah and the Features on the $22.50 board are built into the Chip. All of the nRF24XX series Ic's have those features... They're part of what drove the original design and that was an inexpensive Chipset that could co-exist with all the other ISM stuff as well as Microwave Ovens @ 2450 Mhz and most capable of 1000 watts or more @ ~ 2450 mhz as the ovens use a "Power Oscillator" (A Klystron of Magnetron tube) neither of which has any external frequency control (Oscillating Frequency is set by internal cavity dimensions primarily).

Doc

That $2.75 one doesn't look like the + model that sales for $5.50 at the other place. The + model adds a few features including a slower transmit speed for increased range and less power usage.

However you are correct they are cheaper on ebay http://www.ebay.com/itm/2PCS-Arduino-NRF24L01-Wireless-Transceiver-Module-/270977894613?pt=LH_DefaultDomain_0&hash=item3f178a88d5 is a + and 4.10 for 2 of them, so only $2.05 each free shipping.

Although I'd probably buy this one instead: nrf24l01 for sale | eBay a little bit more expensive but it's located in the US, so would get here 3 times quicker lol.

So, I'm testing the RF434, with VirtualWire. And is there a way to make it translate what it recieved into a text? Instead of hex codes for each letter.

Sure, just translate the hexcodes into letters. Translation is available at asciitable.com

Say you get 1 character at a time:

    // mapping from incoming character to font_array or other commands: \ + = < >
    // invalid characters are not defined and are ignored
    switch(incomingByte){
    case 0x20:
Serial.print(" ");
      break;
    case 0x21:
Serial.print("!");
break;
    case 0x2d:
      Serial.print("-");
      break;
    case 0x2e:
      Serial.print(".");
      break;
    case 0x2f:
      Serial.print("/");
      break;
    case 0x30:
      Serial.print("0");
      break;
    case 0x31:
      Serial.print("1");
      break;
 // etc.   
}

Thanks!

But I've ran into another problem, the VirtualWire library is hard to understand.

I'm using a DHT11 to measure the temperature, now getting the readings from the DHT11 is easy, getting em shown in the serial monitor is easy.

Problem comes when I want to send the readings using VirtualWire, thats hard :stuck_out_tongue: Or I'm sure I'm missing something...

This is my code:

Problems starts in "char *msg = char(DHT11.temperature);" it seems.

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm 
double dewPoint(double celsius, double humidity)
{
	double A0= 373.15/(273.15 + celsius);
	double SUM = -7.90298 * (A0-1);
	SUM += 5.02808 * log10(A0);
	SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
	SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
	SUM += log10(1013.246);
	double VP = pow(10, SUM-3) * humidity;
	double T = log(VP/0.61078);   // temp var
	return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
	double a = 17.271;
	double b = 237.7;
	double temp = (a * celsius) / (b + celsius) + log(humidity/100);
	double Td = (b * temp) / (a - temp);
	return Td;
}


#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

#include <VirtualWire.h>

int tempsend;
char tempconv;
char fuck;

void setup()
{
    Serial.begin(9600);	  // Debugging only
    Serial.println("setup");
    Serial.println("DHT11 TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT11LIB_VERSION);
    Serial.println();

    // Initialise the IO and ISR
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
     Serial.println("\n");

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Read sensor: ");
  switch (chk)
  {
    case 0: Serial.println("OK"); break;
    case -1: Serial.println("Checksum error"); break;
    case -2: Serial.println("Time out error"); break;
    default: Serial.println("Unknown error"); break;
  }

  //Serial.print("Humidity (%): ");
  //Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (oC): ");
  Serial.println(DHT11.temperature);


   char *msg = char(DHT11.temperature);

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(2000);
 

}

Since it complains I can't do "'int' to 'char*'", I tried to set a char() conversion first. But then it complains about this "'char' to 'char*'". So I try to remove the * infront of MSG, but then I get the warning about a constant char...

I'm really confused here, anyone want to help me think this one out?

Sigh, I wish VirtualWire would have more examples showing how to send other values than 'const char'.

Change a couple of things:

Move these to the top of the sketch

#include <dht11.h>
#include <VirtualWire.h>

Delete this unless your transmitter needs a Push to Talk switch (most don't)

    vw_set_ptt_inverted(true); // Required for DR3100

put the data you want to send in an array
msg[ ]
then virtualwire will send the msg[] array out.

I can't tell what data type you want to send - DHT11.temperature is a float? thus 4 butes?
So put 4 byte in msg[0] thru msg[3] and let 'er rip.

Hm, sorry for not understanding. But the value I'm sending could just be a normal int.

   Serial.print("Temperature (oC): ");
  int convert = DHT11.temperature;
  Serial.println(convert);


   char *msg[3] = convert;

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(3));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(2000);

So after converting my float value to a int, it's basically the value of 23-25 around there. What do you mean by put 4 byte in msg[0] thru msg[3]?

Thanks for all the help so far! :slight_smile:

I didn't know how many bytes of data you were dealing with, so figured you had a float that was 4 bytes long.

I don't know what this does

char *msg[3] = convert;

I would personally do this:

msg[0] = highByte(convert);
msg[1] = lowByte(convert);

and then let virtualwire send the [msg] array out. Or just grab the low byte if its always <=255

I'd have to look at my remote control code at home to see if

vw_send((uint8_t *)msg, strlen(3));

had to change to support that.

Hm, got no compiling errors, but it won't send. Led 13 won't even light up, so it can't have gotten that far into the program :stuck_out_tongue:

#include <dht11.h>
dht11 DHT11;
#define DHT11PIN 2
#include <VirtualWire.h>

double dewPoint(double celsius, double humidity)
{
	double A0= 373.15/(273.15 + celsius);
	double SUM = -7.90298 * (A0-1);
	SUM += 5.02808 * log10(A0);
	SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
	SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
	SUM += log10(1013.246);
	double VP = pow(10, SUM-3) * humidity;
	double T = log(VP/0.61078);   // temp var
	return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
	double a = 17.271;
	double b = 237.7;
	double temp = (a * celsius) / (b + celsius) + log(humidity/100);
	double Td = (b * temp) / (a - temp);
	return Td;
}

int tempsend;
char tempconv;
char fuck;

void setup()
{
    Serial.begin(9600);	  // Debugging only
    Serial.println("setup");
    Serial.println("DHT11 TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT11LIB_VERSION);
    Serial.println();

    // Initialise the IO and ISR
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
     Serial.println("\n");

  int chk = DHT11.read(DHT11PIN);

  Serial.print("Read sensor: ");
  switch (chk)
  {
    case 0: Serial.println("OK"); break;
    case -1: Serial.println("Checksum error"); break;
    case -2: Serial.println("Time out error"); break;
    default: Serial.println("Unknown error"); break;
  }

  int convert = DHT11.temperature;

   char *msg;
   msg[0] = highByte(convert);
   msg[1] = lowByte(convert);

    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    delay(2000);
}

Are you getting any of these?

  switch (chk)
  {
    case 0: Serial.println("OK"); break;
    case -1: Serial.println("Checksum error"); break;
    case -2: Serial.println("Time out error"); break;
    default: Serial.println("Unknown error"); break;
  }

is this doing anything now?
char *msg;

I'm getting the Ok. But I found an example on a blog:

So I took it, and merged it with the DHT11.

Transmitter:

// 
//   FILE:  dht11_test1.pde
// PURPOSE: DHT11 library test sketch for Arduino
//

//Celsius to Fahrenheit conversion

#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

#include <VirtualWire.h>

// LED's
const int ledPin = 13;

// Sensors

int Sensor1Data;
//int Sensor2Data;
char Sensor1CharMsg[4]; 

double Fahrenheit(double celsius)
{
	return 1.8 * celsius + 32;
}

//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
	return celsius + 273.15;
}

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm 
double dewPoint(double celsius, double humidity)
{
	double A0= 373.15/(273.15 + celsius);
	double SUM = -7.90298 * (A0-1);
	SUM += 5.02808 * log10(A0);
	SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
	SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
	SUM += log10(1013.246);
	double VP = pow(10, SUM-3) * humidity;
	double T = log(VP/0.61078);   // temp var
	return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
	double a = 17.271;
	double b = 237.7;
	double temp = (a * celsius) / (b + celsius) + log(humidity/100);
	double Td = (b * temp) / (a - temp);
	return Td;
}


void setup()
{
  Serial.begin(9600);
   // LED 
 pinMode(ledPin,OUTPUT);
  // VirtualWire setup
 vw_setup(2000);     // Bits per sec
 
}

void loop()
{

  
  
   // Read and store Sensor 1 data
  int chk = DHT11.read(DHT11PIN);
  Sensor1Data = DHT11.temperature;
  delay(2000);
  // Convert integer data to Char array directly 
  itoa(Sensor1Data,Sensor1CharMsg,10);
  
  // DEBUG
  Serial.print("Sensor1 Integer: ");
  Serial.print(Sensor1Data);
  Serial.print(" Sensor1 CharMsg: ");
  Serial.print(Sensor1CharMsg);
  Serial.print("RawSensor: ");
  Serial.print(DHT11.temperature);
  Serial.println(" ");
  delay(1000);

  // END DEBUG
 
 digitalWrite(13, true); // Turn on a light to show transmitting
 vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));
 vw_wait_tx(); // Wait until the whole message is gone
 digitalWrite(13, false); // Turn off a light after transmission
 delay(200); 
}
//
// END OF FILE
//

Reciever:

/* 

Sensor Receiver 
By Markus Ulfberg 2012-07-06

Gets a sensor reading 0-1023 in a char array
from RF Transmitter unit via VirtualWire 
converts char array back to integer

*/

#include <VirtualWire.h>

// LED's
int ledPin = 13;

// Sensors 
int Sensor1Data;

// RF Transmission container
char Sensor1CharMsg[4]; 

void setup() {
  Serial.begin(9600);
  
  // sets the digital pin as output
  pinMode(ledPin, OUTPUT);      
    
    // VirtualWire 
    // Initialise the IO and ISR
    // Required for DR3100
    vw_set_ptt_inverted(true); 
    // Bits per sec
    vw_setup(2000);     
    
    // Start the receiver PLL running
    vw_rx_start();       

} // END void setup

void loop(){
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    
    // Non-blocking
    if (vw_get_message(buf, &buflen)) 
    {
    int i;
        // Turn on a light to show received good message 
        digitalWrite(13, true); 
    
        // Message with a good checksum received, dump it. 
        for (i = 0; i < buflen; i++)
    {            
          // Fill Sensor1CharMsg Char array with corresponding 
          // chars from buffer.   
          Sensor1CharMsg[i] = char(buf[i]);
    }
        
        // Null terminate the char array
        // This needs to be done otherwise problems will occur
        // when the incoming messages has less digits than the
        // one before. 
        Sensor1CharMsg[buflen] = '\0';
        
        // Convert Sensor1CharMsg Char array to integer
        Sensor1Data = atoi(Sensor1CharMsg);
        
        
        // DEBUG 
        Serial.print("Temp Outside: ");
        Serial.println(Sensor1Data);
        
       
        
        
        // END DEBUG
                
        // Turn off light to and await next message 
        digitalWrite(13, false);
    }
}

Now it's working. :stuck_out_tongue: Not sure I understand exactly how it parses the int over. I sure need to study arrays more. And just experiment with em.

Seems to be here:

  // Convert integer data to Char array directly 
  itoa(Sensor1Data,  Sensor1CharMsg,  10);

then sends it out
vw_send((uint8_t *)  Sensor1CharMsg  , strlen(  Sensor1CharMsg  ));

itoa is one of those C things that you have to know about to be able to look it up:
http://www.arduino.cc/playground/Code/PrintingNumbers

So, there are many other functions other than those listed on Arduino.cc-Reference?

Thanks so much for the help :slight_smile: I understand much much more than before I read your answers :smiley:

Oh yeah, there's all kinds of C stuff out there.

There's an enlarged Reference page

Try some of the links at the lower right of the page too:

"Looking for something else? See the libraries page for interfacing with
particular types of hardware. Try the list of community-contributed code.
The Arduino language is based on C/C++. It links against AVR Libc and allows
the use of any of its functions; see its user manual for details. "

Hi,

I want to sent data through RF transmitters using simple UART in arduino instead of using virtualWire library. I tried with virtualWire library its working fine. But when i used UART its not working. My data packet format is like this... "$$(DATA)(INVERTEDDATA)Z ". I tried connecting with baud rates 2400,1200,300 but none of this works.

Anyway serial communication is working fine when i connect two controllers with a wire(i.e Connecting TX of one with RX of the other). But when i introduce RF transmitter in the middle its not working. I think RF transmitter is transmitting data and RF receiver is receiving it but since iam connecting DATAOUT of reciever directly to RX pin(0th pin in arduino) serial port is not considering the data packets as valid bits.

Can anyone tell me what is the problem?

genn,

I'm not sure what Rx hardware you're using, but a lot of them have a PLL that requires a nearly even distribution of ones and zeros to work properly. By default, the hardware UARTs send a constant HIGH that will confuse the Rx hardware (and it's not so good for battery life either). So, you want to turn the transmitter's serial port or RF unit OFF until you want to send a packet. Then you send a "preamble" of one or two bytes consisting of either 01010101 or 10101010 to allow the Rx unit's PLL to lock in. Then try sending your data. If your data contains long strings of 1s and 0s, you may need to use Manchester encoding on your data to keep the Rx PLL locked -- hence the popularity of the VirtualWire library (which does the preamble and Manchester [and some error checking too] for you).

As above, and the other problem with trying to use a hardware usart with simple radio modules
is that in the absence of any transmission , the receiver outputs continuous random data transitions
which are not at any constant baud rate , and this will cause the usart at the receiving end to continuously
generate overrun and framing errors, which must be cleared before it will work properly.
To do what you want using radio needs intelligent Transmitters / receivers which will simulate correctly a hard wired
connection.
Look at using Xbee modules, some of which can do this.