Skip to content
Snippets Groups Projects
Verified Commit 7faa9539 authored by Zoe Michaela Dietmar Pfister's avatar Zoe Michaela Dietmar Pfister :gay_pride_flag:
Browse files

move INA219 readout in client_central_mast to be the first reading.

parent b16f5d50
No related branches found
No related tags found
2 merge requests!43don't fail if there is no rtc at host, log ESPNow.cpp time response for debugging.,!41Config to definitions
......@@ -11,8 +11,8 @@
static const char *TAG = "MAIN";
#define TIME_TO_SLEEP 1 /* Time ESP32 will go to sleep (in seconds) */
// #define DEBUG
constexpr int TIME_TO_SLEEP = 1; /* Time ESP32 will go to sleep (in seconds) */
#define DEBUG
// #define POWER_MEASUREMENT_EXTRA
TEROS11 teros11_0{0, SDI12_DATA_PIN};
......@@ -25,7 +25,7 @@ INA219 ina219{};
RS485 rs485{};
void readout();
void readout(std::list<Message> ina219Messages);
void setup() {
Serial.begin(115200);
......@@ -70,15 +70,17 @@ void setup() {
RS485::disablePower();
ESP_LOGD(TAG, "Setting up INA219");
ina219.setup();
ESP_LOGD(TAG, "Reading INA219");
auto ina219_messages = ina219.buildMessages();
ESP_LOGD(TAG, "Enabling power to ESPCam");
ESPCamUtilities::enableESPCam();
delay(15000);
ESP_LOGD(TAG, "Disabling power to ESPCam");
ESPCamUtilities::disableESPCam();
ESP_LOGD(TAG, "Setting up INA219");
ina219.setup();
ESP_LOGD(TAG, "Setting up RS485");
rs485.setup();
......@@ -91,7 +93,7 @@ void setup() {
teros11_1.setup();
teros11_2.setup();
readout();
readout(ina219_messages);
ESP_LOGD(TAG, "Tearing Down RS485");
rs485.teardown();
......@@ -126,9 +128,10 @@ void setup() {
}
DeepSleep::deepSleepSeconds(1);
#endif
DeepSleep::deepSleepSeconds(100000 - (millis() / 1000));
// DeepSleep::deepSleepSeconds(100000 - (millis() / 1000));
DeepSleep::deepSleepSeconds(TIME_TO_SLEEP);
}
void readout() {
void readout(std::list<Message> ina219_messages) {
ESP_LOGD(TAG, "Reading Teros11");
auto teros11_0_messages = teros11_0.buildMessages();
......@@ -143,10 +146,6 @@ void readout() {
auto rs485_messages = rs485.buildMessages();
RS485::disablePower();
// TODO: READ INA VALUE BEFORE EVERYTHING ELSE (BEFORE CAM)
ESP_LOGD(TAG, "Reading INA219");
auto ina219_messages = ina219.buildMessages();
std::list<Message> messages;
messages.insert(messages.end(), rs485_messages.begin(), rs485_messages.end());
messages.insert(messages.end(), teros11_0_messages.begin(), teros11_0_messages.end());
......@@ -162,7 +161,7 @@ void readout() {
std::copy(messages.begin(), messages.end(), messages_array.begin());
#ifdef DEBUG
for (auto &message : messages_array) {
for (auto const &message : messages_array) {
ESP_LOGD(TAG, "Message: %s", message.getMessageAsMinifiedJsonString().c_str());
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment