loading

In this project I will show you how make two Arduinos talk to each other using RF frequency (wireless)

In the past I published four instructables that lead to this one :

The first two are about connecting a serial LCD with I2C to an Arduino UNO and a NANO

https://www.instructables.com/id/How-to-connect-a-s...

https://www.instructables.com/id/How-to-connect-a-s...

Another one showing how to use an LM35 temperature sensor with Arduino and an LCD

https://www.instructables.com/id/Display-temperatur...

And the last one is about using an LM35 temperature sensor without an LCD

https://www.instructables.com/id/How-to-display-tem...

Now I will use the knowledge in all these project and improve on them by making one Arduino send data to another Arduino wirelessly using an RF433 module and displaying it on I2C serial LCD.

Step 1: What Is Needed for This Project

Here is what you'll need for this project:

  1. 2 Arduinos, I am using an UNO and a NANO
  2. 2 Solderless breadboards
  3. A pair of RF433 Wireless TX-RX
  4. An LM35 temperature sensor
  5. An I2C serial LCD
  6. And a bunch of jumper wires

The RF433 Wireless TX+RX Pair are ideal for this project because they have a good range about 14 meters or 47 feet without antenna and 31 meters or 102 feet if you attach a 17.4cm antenna on both modules. Those numbers are in theory, real life result may vary according to voltage, temperature, walls etc.... but the idea is that they are great for a 1$ piece of electronics.

Step 2: Connect the Uno, LM35 and the Transmitter

I selected the UNO for this part because it can be powered by an external source.

First connect the GND and the VCC from the Arduino to the bread board

Insert the LM35 on the breadboard and connect the GND and the VCC (see picture for the location of the VCC and the GND pin on the LM35) The middle prong connects to PIN A0 on the Arduino.

If you reverse the GND and the VCC on the LM35, it will heat up and produce readings in the range of 300 to 500 degrees C. (if this happens avoid touching it with your hands)

Insert the RF433-TX module, place it facing you and Pins should be DATA, VCC, GND from left to right (see picture)

Connect the VCC and the GND to the +/- rails on the breadboard and the Data pin connects on digital pin 12 on the Arduino.

This is it for this part, next I will discuss the transmitter sketch.

Step 3: Transmitter Sketch

Start by loading the VirtualWire library which is responsible for communication between the RF433 TX and RX modules

#include <VirtualWire.h>

Next I will define few variables

float temp;        This will be the variable I will use to store the temperature reading<br>int sensor = 0;    This is the A0 where the LM35 data pin is connected                   char msg[6];    This is a Char array called msg that I will use to transmit the data with

Next is the void setup

Here I will define the TX pin is on digital pin 12 on the Arduino and set the transfer rate to 2000 bps

vw_set_tx_pin(12);          // Sets pin D12 as the TX pin<br>vw_setup(2000);         // Bits per sec

In the void loop I read the temperature from the sensor and store it in the variable temp then convert it to Celsius by multiplying the result with 0.48828125

temp = analogRead(sensor);
temp = temp * 0.48828125;

Then I change the type of the variable temp from float to char and store the values in an array called msg to transmit it to the RF433-RX

dtostrf(temp, 6,2,msg);

The I transmit the data over to the RX

vw_send((uint8_t *)msg, strlen(msg)); <br>vw_wait_tx();                                                                            delay(200);

The transmitter code and the virtual Wire library are attached in this step.Rece

Step 4: Connect the NANO, the Receiver and the I2C LCD

In this section I will connect the NANO with the LCD and the RF433-RX module

Plug in the NANO on the breadboard

Then insert the RF433-RX module

Connect the VCC and the GND from the RF433-RX to the NANO GND and VCC and connect the Data PIN (left most pin) to the digital pin 12 on the NANO

Connect the GND and the VCC from the I2C serial LCD to the GND and the VCC pins on the NANO, then connect the SDA to analog pin 4 on the NANO and the SCL to analog pin 5 on the NANO.

Step 5: Receiver Sketch

There is more action in this sketch:

First load the libraries:

#include <VirtualWire.h>
#include<Wire.h> 
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

Then define the variables: and initialize the LCD

#define I2C_ADDR          0x27        //Define I2C Address where the PCF8574A is<br>#define BACKLIGHT_PIN      3
#define En_pin             2
#define Rw_pin             1
#define Rs_pin             0
#define D4_pin             4
#define D5_pin             5
#define D6_pin             6
#define D7_pin             7
int I;
//Initialise the LCD
LiquidCrystal_I2C      lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

In the void setup I define the LCD, turn on the backlight, set the RX pin on digital 12 on the NANO, set the transfer rate to 2000bps and tell the receiver to listen for incoming transmission.

//Define the LCD as 16 column by 2 rows <br>    lcd.begin (16,2);
    
//Switch on the backlight
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    lcd.setBacklight(HIGH);
    
//Define the receiver pin and rate
    vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
    vw_setup(2000);          // Bits per sec
    vw_rx_start();           // Start the receiver PLL running

In the void loop, the NANO checks for transmission, and if it receives one, it prints "The temp is:" on the first line on the LCD and then prints the value with degrees Celsius on the second line

uint8_t buf[VW_MAX_MESSAGE_LEN];<br>   uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
   if( vw_get_message(buf, &buflen) )
      {
        lcd.setCursor(0, 0);
        lcd.print("Temp inside is:");    
        lcd.setCursor(3,1);  
        
       for (i = 0; i < buflen; i++)
         { 
           lcd.write(buf[i]); 
                    
         }
        
           lcd.print((char)223);
           lcd.print("C");

The code is attached in this step

Have fun building it

<p>I need 1 more Sensor Valu Voltage ...Wt To do ...</p><p>i Mean Mufti sensor ...</p>
<p>Is it possible to do it on one Arduino only? I knew that IR modules on the same Arduino can communicate with each other. Is it possible to transmit and receive at the same time? </p>
<p>Hi! First of all, great tutorial!</p><p>Now<br> I have a question. Instead of &quot;writing&quot; the buf[i] I'm trying to save the result to a new int or string, whatever the received msg is. So how can I do that? If I save it to a new variable, I only get a string of ASCII values. I did search and I think, I need to use sscanf to transform the message back to normal, but couldn't figure out the syntax.</p><p>Any help appreciated!</p><p>Regards;<br>Filip</p>
<p>Hi There.</p><p>I notice that the transmitter.ino and receiver.ino files attached in the instrucible are not the ones for this project but simply send a count sequence from the transmitter to the receiver for display on the serial monitor on the Arduino. Was that intended?</p>
<p>Hi g4izp, you are correct, it took over 19000 views before someone realized that I uploaded the wrong code. I apologize for this mistake, it is already corrected.</p><p>Thank you</p>
<p>It works very nicely too. Nice piece of compact coding. Great stuff.</p>
<p>Thanks for the update . I've noticed before how many people tend to comment on instructibles without apparently ever having read the coding thats provided.</p><p>Thanks again though</p>
Great! =D
<p>I'm using codebender for my projects. When compiling the receiver file, I get error message:</p><p>Looks like your project uses header files or libraries that do not exist in our system, in your personal libraries or in your sketch. More info Receiver for LM35.ino:2:10: fatal error: 'LCD.h' file not found<br>#include <br> ^<br>1 error generated.</p><p>Q: Where do I get the header file LCD.h and where do I put it (if I've gotten it)</p><p><br></p>
<p>At what distance this weather station may work?</p>
<p>In theory it should work at 47 feet without an antenna and 102 feet with a 17cm antenna. However, since we are dealing with RF signal it could be shorter depends on what you have in between the walls. </p>
<p>my experience with the cheap 433MHz transmitter Receiver pair is that without antenna the reach is very limited and with the 17 cm straight wire is a couple of meters.<br>I have very good results however with this simple antenna. Really, made a heck of a difference: </p><p><a href="https://arduinodiy.wordpress.com/2015/07/25/coil-loaded-433-mhz-antenna/">https://arduinodiy.wordpress.com/2015/07/25/coil-l...</a></p>
<p>If you connect the output of the TX433 MHz up to a 5KW linear amplifier and use a piece of damp string as an antenna then you should be able reach the moon on a still night.</p>
<p>This will be very useful for me</p><p>thanks for sharing</p>
<p>I like how your projects have evolved and have come together to create this project. Very innovative and good work.</p>
<p>Thank you very much :) </p>

About This Instructable

45,302views

561favorites

License:

More by eliesalame:Game of Thrones Music Box One Pot 5 Vegetables Veal Shank Soup  Arduino 101 Fundamentals 
Add instructable to: