fixed dht11 support
This commit is contained in:
33
main.cpp
33
main.cpp
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user