![]() |
Data Gator
Hardware and software documentation for the Data Gator project.
|
Initializes device and calls routines. More...
#include <Arduino.h>
#include <cstring>
#include "SDReader.hpp"
#include <version.hpp>
#include <pinout.hpp>
#include <config.hpp>
#include <firebeetle_sleep.hpp>
#include <update.cpp>
#include <logging_util.cpp>
#include <mqtt_util.hpp>
#include <setup_util.hpp>
#include <scheduler.hpp>
#include <logger.hpp>
#include <SPI.h>
#include <HttpsOTAUpdate.h>
#include <Preferences.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
Functions | |
PubSubClient | mqtt_client (wifi_client) |
MQTT client object. | |
void | setup () |
Setup initializes sensor interfaces, NVS, wireless protocols, and logging options. | |
void | loop () |
Read sensors, log data, and hibernate. | |
Variables | |
Adafruit_ADS1115 | ads |
Analog to digital converter object (I2C) | |
Adafruit_MAX17048 | maxlipo |
MAX17048 battery Fuel Gauge. | |
bool | maxlipo_attached |
Fuel Gauge successfully initialized? | |
int | reset_count |
number of resets retrieved for NVS | |
const bool | USB_DEBUG = DEBUG |
USB serial debugging enabled. | |
WiFiClient | wifi_client |
WiFi stack object. | |
Preferences | gator_prefs |
NVS memory object. | |
Initializes device and calls routines.
Uses the Arduino framework to initialize devices and call routines to collect data and manage power. This file is required for compilation in the Arduino framework. Furthermore it contains implementations of the Arduino required functions setup()
and loop()
.
The Arduino model of execution has been adapted to fit a different executional model which prioritizes intermittent, low power data collection. Arduino defaults to running the code within loop an infinite number of times until the device is stopped or runs out of a resource such as power.
In many precision agriculture scenarios the rate of change of any monitored variable such as temperature likely needs to be polled no more than once a minute. Any more than this degree of resolution is probably a waste of energy. To accomodate this norm, the Data Gator (DG) firmware is configured to run the code in loop once and then shutdown (enter low power mode) to conserve battery life.
This file implements main.
Read sensors, log data, and hibernate.
Although specified to loop infinitely by the Arduino API, this function does the following in one iteration:
Setup initializes sensor interfaces, NVS, wireless protocols, and logging options.
This function initializes all global resources and bus based protocols. A list (non-exhaustive but pretty complete) can be found below:
|
extern |
Analog to digital converter object (I2C)
Interface for the analog to digital converter.
Preferences gator_prefs |
NVS memory object.
Reference to non-volatile-storage on ESP32.
NVS memory access interface.
|
extern |
MAX17048 battery Fuel Gauge.
Interface for the battery fuel gauge.
|
extern |
Fuel Gauge successfully initialized?
External flag indicating whether maxlipo was initialized successfully.
|
extern |
number of resets retrieved for NVS
External variable holding the number of resets recorded by the system. Stored and loaded from non-volatile storage.