Hi,
I have two Arduino boards linked via RF 315Mhz and the output from one of them is very weird.
Here is the code on the transmitter :
#include <VirtualWire.h>
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
const int transmit_pin = 12;
void setup()
{
// Initialise the IO and ISR
vw_set_tx_pin(transmit_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
dht.begin();
}
void loop()
{
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity(); // Reading humidity
float t = dht.readTemperature(); // Read temperature as Celsius
// float f = dht.readTemperature(true); // Read temperature as Fahrenheit
int tempC1 = (int)t;
int tempC2 = (int)((t*100) - (tempC1*100)); // For two decimal points
if ((t*100) > (tempC1*100)) // Check to see if the value if higher then the temp
{
int tempC2 = (int)((t*100) - ((tempC1*100)-100)); // For two decimal points
}
char msg[18];
sprintf(msg, "Room D Temp: %i.%i", tempC1,tempC2);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
int humC1 = (int)h;
sprintf(msg, "Room D Humidit: %i", humC1);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
delay(10000); // Wait 10 Seconds
}
Here is the receiver code:
#include <VirtualWire.h>
const int receive_pin = 7;
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("Ready");
// Initialise the IO and ISR
vw_set_rx_pin(receive_pin);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
// Message with a good checksum received, dump it.
Serial.print((char*)buf);
Serial.println();
}
}
and the output I am getting is :
Room D Temp: 17.50Àû
Room D Humidit: 77û
Room D Temp: 17.50ÿ
Room D Humidit: 77
Room D Temp: 17.50ÿ
Room D Humidit: 77ÿ
Room D Temp: 17.50
Room D Humidit: 77@
Room D Temp: 17.40
Room D Humidit: 77þ
Room D Temp: 17.40
Room D Humidit: 77ÿ
Room D Temp: 17.40À×
Room D Humidit: 77
Room D Temp: 17.40À×
Room D Humidit: 77
Room D Temp: 17.40
Room D Humidit: 77
Room D Temp: 17.40ÿ
Room D Humidit: 77Àû
Room D Temp: 17.40ÿ
Room D Humidit: 77
Can anyone tell me what the random output is at the end ?
Thanks