#include <SoftwareSerial.h>#include <ArduinoOTA.h>#include <FS.h>#include "Config.h"#include "ConfigOverride.h"#include "Utils.h"#include "StringList.h"#include "Gps.h"#include "Options.h"#include "Data.h"#include "Voltage.h"#include "DeepSleep.h"#include "WebServer.h"#include "GsmPower.h"#include "GsmGps.h"#include "SmsCmd.h"#include "Mqtt.h"#include "BME280.h"Go to the source code of this file.
Macros | |
| #define | SIM808_CONNECTED |
| #define | USE_CONFIG_OVERRIDE |
| Switch to use ConfigOverride. | |
| #define | PIN_POWER D3 |
| power on/off to DC-DC LM2596 | |
| #define | PIN_BME_GRND D4 |
| Ground pin to the BME280 module. | |
| #define | BME_ADDRESS 0x77 |
| BME280 port address (Default 0x77, China 0x76) | |
| #define | PIN_TX D5 |
| Transmit-pin to the sim808 RX. | |
| #define | PIN_RX D6 |
| Receive-pin to the sim808 TX. | |
Functions | |
| MyMqtt | myMqtt (myGsmGps.gsmClient, myOptions, myData) |
| Helper class for the mqtt communication via gsm. | |
| void | yield (void) |
| void | myDebugInfo (String info, bool fromWebserver, bool newline) |
| void | myDelayLoop () |
| long | secondsSincePowerOn () |
| void | setup () |
| void | loop () |
Variables | |
| MyOptions | myOptions |
| The global options. | |
| MyData | myData |
| The global collected data. | |
| MyVoltage | myVoltage (myOptions, myData) |
| Helper class for deep sleeps. | |
| MyDeepSleep | myDeepSleep (myOptions, myData) |
| Helper class for deep sleeps. | |
| MyWebServer | myWebServer (myOptions, myData) |
| The Webserver. | |
| MyBME280 | myBME280 (myOptions, myData, PIN_BME_GRND, BME_ADDRESS) |
| Helper class for the BME280 sensor communication. | |
| MyGsmPower | myGsmPower (myData, PIN_POWER) |
| Helper class to switch on/off the sim808 power. | |
| MyGsmGps | myGsmGps (myOptions, myData, PIN_RX, PIN_TX) |
| sim808 gsm/gps communication class. | |
| MySmsCmd | mySmsCmd (myGsmGps, myOptions, myData) |
| sms controller class for the sms handling. | |
| bool | gsmHasPower = false |
| Is the DC-DC modul switched on? | |
| bool | isStarting = false |
| Are we in a starting process? | |
| bool | isStopping = false |
| Are we in a stopping process? | |
Main file with setup() and loop() functions
Definition in file tracker.ino.
| void loop | ( | ) |
Main loop function. Read the power supply voltage. Checks for console inputs and send them to the SIM808 modul. Checks for OTA activities. Start or stop the gsm and/or gps activities. Check for receiving sms and process them. Checks the gps and send the overall information to a mqtt server if needed. Starts the deep sleep mode if needed.
Definition at line 174 of file tracker.ino.
References MyGsmGps::begin(), MyData::consoleCmds, gsmHasPower, MyGsmGps::handleClient(), MySmsCmd::handleClient(), MyMqtt::handleClient(), MyWebServer::handleClient(), MyDeepSleep::haveToSleep(), StringList::isEmpty(), MyData::isGsmActive, MyOptions::isMqttEnabled, MyData::isOtaActive, MyOptions::isSmsEnabled, isStarting, isStopping, myBME280, myDeepSleep, myGsmGps, myGsmPower, myMqtt(), mySmsCmd, myVoltage, myWebServer, MyGsmPower::off(), MyGsmPower::on(), MyOptions::powerOn, MyBME280::readValues(), MyVoltage::readVoltage(), StringList::removeHead(), MyGsmGps::sendAT(), MyDeepSleep::sleep(), MyGsmGps::stop(), MyGsmGps::waitingForGps(), MyMqtt::waitingForMqtt(), and yield().
| void myDebugInfo | ( | String | info, |
| bool | fromWebserver, | ||
| bool | newline | ||
| ) |
Overwritten Debug Function It logs all the debug calls to the console string-list And call a refresh of the webserver for not blocking the system.
Definition at line 92 of file tracker.ino.
References StringList::addTail(), MyWebServer::handleClient(), MyData::logInfos, myWebServer, StringList::removeTail(), secondsSincePowerOn(), and yield().
Referenced by MyDbg().
| void myDelayLoop | ( | ) |
Overwritten delay loop for refreshing the webserver on waiting processes.
Definition at line 122 of file tracker.ino.
References MyWebServer::handleClient(), myWebServer, and yield().
Referenced by MyDelay().
| long secondsSincePowerOn | ( | ) |
Returns the seconds since power up (not since last deep sleep).
Definition at line 132 of file tracker.ino.
References MyData::secondsSincePowerOn().
Referenced by MyDeepSleep::begin(), MyGsmGps::getGps(), MyGsmGps::getGpsFromGsm(), MyGsmGps::handleClient(), MyMqtt::handleClient(), MyDeepSleep::haveToSleep(), myDebugInfo(), secondsElapsed(), secondsElapsedAndUpdate(), and MyDeepSleep::sleep().
| void setup | ( | ) |
Main setup function. This is also called after every deep sleep. Do the initialization of every sub-component.
Definition at line 139 of file tracker.ino.
References MyGsmPower::begin(), MyDeepSleep::begin(), MyVoltage::begin(), MyBME280::begin(), MySmsCmd::begin(), MyMqtt::begin(), MyWebServer::begin(), MyOptions::load(), myBME280, MyDbg(), myDeepSleep, myGsmPower, myMqtt(), mySmsCmd, myVoltage, and myWebServer.
| void yield | ( | void | ) |
***** IMPORTANT ***** It seems that the yield function of ESP does not feed the watch dog timer. So we overwrite the yield() function here. If not the program crashed on some waits. ***** IMPORTANT *****
Definition at line 83 of file tracker.ino.
Referenced by loop(), myDebugInfo(), MyDelay(), and myDelayLoop().
1.8.6