fixed dht11 support

This commit is contained in:
2019-11-10 10:48:11 +01:00
parent dbf9adcde8
commit 3b04b070a4
2 changed files with 42 additions and 32 deletions

View File

@ -20,7 +20,7 @@ EMPTY_INTERRUPT(WDT_OVERFLOW_vect);
static constexpr uint8_t id = 4;
static constexpr bool WATCH_DOOR = false;
static constexpr bool BMP_280 = false;
static constexpr bool BMP_280 = true;
static constexpr bool DHT22 = true;
@ -84,65 +84,64 @@ int main()
}
PORTD &= ~(1 << LED_PIN);
uint32_t paketUint;
uint8_t * const paket = reinterpret_cast<uint8_t*>(&paketUint);
paket[1] = id;
uint8_t paket[4] = {0};
paket[1] = 4;
//temperature sensor
if constexpr (DHT22)
{
debugBlink(false);
tempSensor.read();
paket[0] = 1;
//debugBlink(false);
uint8_t readret = tempSensor.read();
paket[0] = readret;
paket[2] = tempSensor.temperature >> 8;
paket[3] = tempSensor.temperature;
transmiter.sendPacket(paketUint);
transmiter.send(paket, 4);
}
//humidity sensor
if constexpr (DHT22)
{
debugBlink(false);
//debugBlink(false);
paket[0] = 2;
paket[2] = tempSensor.humidity >> 8;
paket[3] = tempSensor.humidity;
transmiter.sendPacket(paketUint);
transmiter.send(paket, 4);
}
//low battery waring
if(comp.compare())
{
debugBlink(false);
//debugBlink(false);
paket[0] = 128;
paket[2] = 0;
paket[3] = id;
transmiter.sendPacket(paketUint);
transmiter.send(paket, 4);
}
//presure sensor
if constexpr(BMP_280)
{
debugBlink(false);
//debugBlink(false);
uint16_t pressure = pressSensor.getPressure();
paket[0] = 3;
paket[2] = pressure >> 8;
paket[3] = pressure;
transmiter.sendPacket(paketUint);
transmiter.send(paket, 4);
}
//door
if constexpr(WATCH_DOOR)
{
debugBlink(false);
//debugBlink(false);
paket[0] = 0;
paket[1] = 2;
paket[2] = 0;
paket[3] = readPin(&PIND, DOOR_PIN);
transmiter.sendPacket(paketUint);
transmiter.send(paket, 4);
}
comp.off();
power(false);
//power(false);
}
sleep_mode();
}