Hey there! I need help! Can you control my sketch. A arduino should send via 433 MHZ temperature data from an dht 22 sensor to an second arduino. this arduino should recieve it and show it on the serial monitor. Thanks for helping
transmitting:
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <VirtualWire.h>
#define DHTPIN 4
#define DHTTYPE DHT22 //type DHT22
int SE_PIN = 8;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("Sender-bereit-Im folgenden werden die Temperaturdaten ausgegeben!");
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_set_tx_pin(SE_PIN);
dht.begin();
}
void loop() {
int temp = dht.readTemperature(); //Temperatur auslesen
Serial.print("Temperatur: ");
Serial.print(temp);
Serial.println(" C");
vw_send((uint8_t *)temp, strlen(temp));
vw_wait_tx();
delay(4000);
}
Reciever
#include <VirtualWire.h>
boolean DEBUG = true;
int rxPin = 7;
void setup ()
{
if(DEBUG)
{
Serial.begin(9600);
Serial.println(F("Empfänger startet"));
}
vw_setup(2000);
vw_set_rx_pin(rxPin);
vw_rx_start();
if(DEBUG) Serial.println(F("Verbunden"));
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
Serial.print("Gesendet: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(' ');
}
Serial.println();
}
}