Hi everyone,
I´m still kinda new to arduino and im having difficult time with programing my METEO station i need to send data from outside´s DHT22 sensor (with arduino uno) to my indoor´s arduino Mega with 433Mhz transmitter and receiver.
Im using "DHT sensor library" and "RC-Switch library".
From what i was able to write into code i got exactly this result:
Received 25
Received 25
Received 25
Received 25
Received 38
Received 38
Received 38
Received 38
The first fourth values is tempereture in °C and the last fourth values is humidity in % however what im trying to get is: Received 25 °C
Received 38%
but the arduino isnt able to recognize whether the number is meant for humidity or for temperature becouse of the way how is it written could you help me please ? Im starting to get desperate I also apologize for my english, i will put code for transmitter and for receiver below
Transmitter:
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 6
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
dht.begin();
// Optional set pulse length.
// mySwitch.setPulseLength(320);
// Optional set protocol (default is 1, will work for most outlets)
// mySwitch.setProtocol(2);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
}
void loop() {
delay(2000);
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
/* Same switch as above, but using decimal code */
mySwitch.send(h, 24);
delay(7000);
mySwitch.send(t, 24);
delay(20000);
}
and receiver:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
float value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
// Serial.print(" % ");
// Serial.print("*C ");
Serial.println(" ");
}
mySwitch.resetAvailable();
}
}