[Firmware] Added Beacon Mode
This commit is contained in:
parent
25feb944ca
commit
b68b526fc7
|
@ -1,7 +1,6 @@
|
|||
[env:attiny84]
|
||||
platform = atmelavr
|
||||
board = attiny84
|
||||
platform = atmelavr
|
||||
framework = arduino
|
||||
upload_protocol = stk500v2
|
||||
upload_flags =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
main.cpp - TinyLora BMP280 Firmware
|
||||
main.cpp - TinyLora / TinyTX Firmware
|
||||
Copyright (c) 2019, Stefan Brand
|
||||
All rights reserved.
|
||||
|
||||
|
@ -66,6 +66,16 @@
|
|||
// Global Variable used for deep sleep
|
||||
uint16_t sleep_interval;
|
||||
|
||||
void blink(uint8_t num) {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, 0);
|
||||
for (uint8_t i=0; i<num*2; i++) {
|
||||
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
|
||||
delay(100);
|
||||
}
|
||||
digitalWrite(LED_PIN, 0);
|
||||
}
|
||||
|
||||
// Setup Wakeup Interrupt Timer
|
||||
void init_wdt()
|
||||
{
|
||||
|
@ -137,32 +147,38 @@ void setup()
|
|||
radio.setPowerLevel(RFM69_TXPOWER);
|
||||
radio.sleep();
|
||||
#endif
|
||||
|
||||
// Setup LED if defined
|
||||
#ifdef LED_PIN
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
blink(1);
|
||||
#endif
|
||||
delay(50);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Buffer to send data
|
||||
int32_t data[4];
|
||||
// Without Sensor (Beacon Mode) just send the Battery Voltage
|
||||
#ifdef HAS_NO_SENSOR
|
||||
int32_t data[1];
|
||||
#endif
|
||||
|
||||
// Get Sensor Data
|
||||
#ifdef HAS_BME280
|
||||
int32_t data[4] = {0, 0, 0, 0};
|
||||
sensor.getData(&data[0], &data[1], &data[2]);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SHT21
|
||||
int32_t data[4] = {0, 0, 0, 0};
|
||||
data[0] = (int32_t)(sensor.getTemperature()*100);
|
||||
data[1] = 0;
|
||||
data[2] = (int32_t)(sensor.getHumidity()*100);
|
||||
#endif
|
||||
|
||||
data[3] = readVcc();
|
||||
#ifdef HAS_NO_SENSOR
|
||||
data[0] = readVcc();
|
||||
#else
|
||||
data[3] = readVcc();
|
||||
#endif
|
||||
|
||||
// LED On before Sending
|
||||
#ifdef LED_PIN
|
||||
|
|
Loading…
Reference in a new issue