From 5a112f40042dfa5ebbb5cc1c62d7a8032ebfafbf Mon Sep 17 00:00:00 2001 From: Stefan Ostermann Date: Sat, 17 Apr 2021 16:14:56 +0200 Subject: [PATCH] lower baud rate again, higher frequency after switching on --- esp-receiver/src/main.cpp | 2 +- sensor433/src/main.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/esp-receiver/src/main.cpp b/esp-receiver/src/main.cpp index f5fb8ad..ffcbcf1 100644 --- a/esp-receiver/src/main.cpp +++ b/esp-receiver/src/main.cpp @@ -13,7 +13,7 @@ * Baud Rate for the 433 Mhz connection. * Caution: Must be the same for sender & receiver! **/ -#define RH_SPEED 2000 +#define RH_SPEED 1000 /** * Pin for the receiver diff --git a/sensor433/src/main.cpp b/sensor433/src/main.cpp index c98f7a9..6111899 100644 --- a/sensor433/src/main.cpp +++ b/sensor433/src/main.cpp @@ -23,7 +23,7 @@ #define RH_OWN_ADDR 0xca // 202 // RadioHead bitrate in bit/s -#define RH_SPEED 2000 +#define RH_SPEED 1000 /* define when to wake up @@ -33,7 +33,7 @@ #define WATCHDOG_WAKEUP 9 // Sleep this many again before waging up. Sleep time in s = WATCHDOG_WAKEUP s * WATCHDOG_SLEEP_FURTHER, e.g. 8*8s = 64s -#define WATCHDOG_SLEEP_FURTHER 8 +#define WATCHDOG_SLEEP_FURTHER 4 // pins for the radio hardware #define RH_RX_PIN 6 // not used, set to a non-existent pin @@ -141,7 +141,7 @@ void loop() long battery = 0; // wait for everything the transistor switched on: - delay(25); + delay(50); if (counter % 4 == 0) { @@ -152,12 +152,12 @@ void loop() } else if (dht_read_data(&dht, &t, &h) == 1) { - rh_buf[0] = MSG_HEADER; - memcpy(&rh_buf[1], &t, 4); - memcpy(&rh_buf[5], &h, 4); - soil = analogRead(SOIL_PIN); - memcpy(&rh_buf[9], &soil, 2); - + rh_buf[0] = MSG_HEADER; + memcpy(&rh_buf[1], &t, 4); + memcpy(&rh_buf[5], &h, 4); + soil = analogRead(SOIL_PIN); + memcpy(&rh_buf[9], &soil, 2); + rh_send(RH_BUF_LEN); } else @@ -177,6 +177,10 @@ void loop() for (uint8_t i = 0; i < WATCHDOG_SLEEP_FURTHER; i++) { system_sleep(); + // if first loop sleep less long: + if (counter==1) { + break; + } } } }