parent
af6044b2c3
commit
5d28d8648d
@ -0,0 +1,70 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// LilyGo T-Watch 2020 (v1) Example
|
||||
// This sketch retrieves the time from a nearby FDRS gateway using ESP-NOW.
|
||||
//
|
||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA
|
||||
// FDRS Timekeeping was developed and contributed by Jeff Lehman (aviateur17)
|
||||
//
|
||||
// Gratitude to Lewis He and LilyGo for building and supporting the T-Watch.
|
||||
//
|
||||
|
||||
#define UPTIME 3 // Seconds to remain on before sleeping
|
||||
#define LILYGO_WATCH_2020_V1
|
||||
|
||||
#include <LilyGoWatch.h>
|
||||
#include "fdrs_node_config.h"
|
||||
#include <fdrs_node.h>
|
||||
|
||||
TTGOClass *ttgo;
|
||||
TFT_eSPI *tft;
|
||||
PCF8563_Class *rtc;
|
||||
AXP20X_Class *power;
|
||||
|
||||
uint32_t interval = 0;
|
||||
|
||||
void fdrs_recv_cb(DataReading theData) {
|
||||
}
|
||||
|
||||
void setup() {
|
||||
ttgo = TTGOClass::getWatch();
|
||||
ttgo->begin();
|
||||
ttgo->openBL();
|
||||
rtc = ttgo->rtc;
|
||||
tft = ttgo->tft;
|
||||
power = ttgo->power;
|
||||
|
||||
tft->setTextColor(TFT_RED, TFT_BLACK);
|
||||
//Draw voltage in top right corner
|
||||
tft->drawString(String(power->getBattVoltage() / 1000.0), 180, 0, 4);
|
||||
|
||||
beginFDRS();
|
||||
uint32_t contact = pingFDRS(100);
|
||||
if (contact != UINT32_MAX) {
|
||||
// Draw ping response time (if any) in top left
|
||||
tft->drawString(String(contact), 0, 0, 4);
|
||||
addFDRS(fdrs_recv_cb);
|
||||
delay(100);
|
||||
rtc->syncToRtc();
|
||||
}
|
||||
|
||||
char strftime_buf[64];
|
||||
time_t local = time(NULL) + (isDST ? dstOffset : stdOffset);
|
||||
localtime_r(&local, &timeinfo);
|
||||
strftime(strftime_buf, sizeof(strftime_buf), "%m-%d-%Y", &timeinfo); // generate MM-DD-YYYY local time character array
|
||||
tft->setTextColor(TFT_BLUE, TFT_BLACK);
|
||||
tft->drawString(strftime_buf, 50, 200, 4);
|
||||
tft->setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
strftime(strftime_buf, sizeof(strftime_buf), "%I:%M:%S", &timeinfo); // generate HH:MM:SS local time character array
|
||||
tft->drawString(strftime_buf, 5, 75, 7);
|
||||
delay(UPTIME * 1000);
|
||||
|
||||
power->clearIRQ();
|
||||
ttgo->displaySleep();
|
||||
ttgo->powerOff();
|
||||
esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// Sensor Configuration
|
||||
|
||||
#include <fdrs_globals.h>
|
||||
|
||||
#define READING_ID 1 //Unique ID for this sensor
|
||||
#define GTWY_MAC 0x01 //Address of the nearest gateway
|
||||
|
||||
#define USE_ESPNOW
|
||||
//#define USE_LORA
|
||||
#define DEEP_SLEEP
|
||||
//#define POWER_CTRL 14
|
||||
#define FDRS_DEBUG
|
||||
|
||||
// LoRa Configuration
|
||||
#define RADIOLIB_MODULE SX1276
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO 26
|
||||
#define LORA_BUSY 33
|
||||
//#define USE_SX126X
|
||||
|
||||
#define LORA_TXPWR 17 // LoRa TX power in dBm (: +2dBm - +17dBm (for SX1276-7) +20dBm (for SX1278))
|
||||
#define LORA_ACK // Request LoRa acknowledgment.
|
||||
|
||||
//#define USE_LR // Use ESP-NOW LR mode (ESP32 only)
|
||||
|
||||
// Time settings
|
||||
#define USDST
|
||||
// #define EUDST
|
||||
#define STD_OFFSET (-6) // Local standard time offset in hours from UTC - if unsure, check https://time.is
|
||||
#define DST_OFFSET (STD_OFFSET + 1) // Local savings time offset in hours from UTC - if unsure, check https://time.is
|
||||
#define TIME_PRINTTIME 10 // Time, in minutes, between printing local time to debug
|
Loading…
Reference in New Issue