battery sensor

This commit is contained in:
2021-04-04 18:42:39 +02:00
parent 34d33d05f0
commit c685867d51
2 changed files with 50 additions and 17 deletions

View File

@@ -14,12 +14,12 @@ RH_ASK driver(RH_SPEED, RH_RX_PIN);
float t = 0;
float h = 0;
uint8_t bat_percent = 0;
uint8_t bat_raw = 0;
long bat = 0;
#define MSG_START 0x00
#define MSG_TEMP 0x01
#define MSG_HUMID 0x02
#define MSG_BAT 0x03
#define MSG_ERR 0xee
void setup() {
@@ -55,6 +55,13 @@ void loop() {
Serial.print(t);
Serial.print("%");
break;
case MSG_BAT:
// battery data
Serial.println("0x03 Battery");
memcpy(&bat, &rh_buf[1], 4);
Serial.print(bat);
Serial.print("mV");
break;
case MSG_ERR:
// error
Serial.println("0xEE error");