hello to all
I'm making a small weather station .. now I'm testing rf modules 433 MHz, because I would have sensors (temperature, wind) on the outside, and the "central" inside the house.
So I would like Arduino 1 (transmitter) sends variable data from sensor to the central station (arduino mega,receiver) .
For now I am only able to send a single data element.
how should I do to be able to send and read more data? eg. temperature, wind speed,
I enclose the sketch I use to send variables
thanks for the help
Transmitter
#include <VirtualWire.h>
const int led_pin = 11;
const int transmit_pin = 8;
const int receive_pin = 52;
const int transmit_en_pin = 3;
float temp = 19.20 ; //EXAMPLE
void setup()
{
// Initialise the IO and ISR
vw_set_tx_pin(transmit_pin);
vw_set_rx_pin(receive_pin);
vw_set_ptt_pin(transmit_en_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
pinMode(led_pin, OUTPUT);
}
byte count = 1;
void loop()
{
char msgt[6] ;
dtostrf(temp,2,2, msgt);
msgt[6] = count;
digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
vw_send((uint8_t *)msgt, 7);
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(led_pin, LOW);
delay(1000);
count = count + 1;
}
Receiver
#include <VirtualWire.h>
const int led_pin = 13;
const int transmit_pin = 12;
const int receive_pin = 52;
const int transmit_en_pin = 3;
void setup()
{
delay(1000);
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
vw_set_tx_pin(transmit_pin);
vw_set_rx_pin(receive_pin);
vw_set_ptt_pin(transmit_en_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
pinMode(led_pin, OUTPUT);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(led_pin, HIGH); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(char(buf [i] ));
Serial.print(' ');
}
Serial.println();
digitalWrite(led_pin, LOW);
}
}