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