The code which works
// User Gareth https://www.robotshop.com/letsmakerobots/user/2941
// Project Node https://www.robotshop.com/letsmakerobots/node/12394
// Remote transmitting Temparature and Humidity over RF Link to SerialMonitor
// DHT11 Sensor
#include // library for RF RX/TX
#undef int
#undef abs
#undef double
#undef float
#undef round
#undef round
#include “DHT.h”
#define DHTPIN 4
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
float temp_c;
float humidity;
int packet = 0;
char charnum[10];
void setup()
{
// Debug Serial.begin(38400);
// Serial.println(“Starting up”);
// Initialise the IO and ISR
vw_set_tx_pin(3);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
dht.begin();
}
void loop()
{
byte error;
byte rh;
float humival_f;
float tempval_f;
float dew_point_f;
char str[15];
// Read values from the sensor
float temp_c;
float humidity;
temp_c = dht.readTemperature();
humidity = dht.readHumidity();
char buff[30];
sprintf(buff,"%c",255);
const char msg0 = buff;
vw_send((uint8_t )msg0, strlen(msg0)); // Send control character
vw_wait_tx(); // Wait until the whole message is gone
// Serial.print(“Temperature = “);
serialPrintFloat(temp_c);
sprintf(buff,”%cC “,223);
const char msg1 = buff;
vw_send((uint8_t )msg1, strlen(msg1));
vw_wait_tx(); // Wait until the whole message is gone
// Serial.print(“C”);
////////////////////////////////////////////////////////////////////////////////////////
sprintf(buff,”%c”,254);
const char msg5 = buff;
vw_send((uint8_t )msg5, strlen(msg5));
vw_wait_tx(); // Wait until the whole message is gone
// Serial.print(" Rel Humidity = “);
serialPrintFloat(humidity);
// Serial.print(”%");
const char msg2 = "% ";
vw_send((uint8_t )msg2, strlen(msg2));
vw_wait_tx(); // Wait until the whole message is gone
delay(1000);
}
void serialPrintFloat( float f){
//Serial.print((int)f);
itoa((int)f, charnum, 10);
vw_send((uint8_t )charnum, strlen(charnum));
vw_wait_tx(); // Wait until the whole message is gone
// Serial.print(".");
const char msg = “.”;
vw_send((uint8_t )msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
int temp = (f - (int)f) * 100;
// Serial.print( abs(temp) );
itoa(abs(temp), charnum, 10);
vw_send((uint8_t )charnum, strlen(charnum));
vw_wait_tx(); // Wait until the whole message is gone
}