# Program Flow

Overview:
--------

The whole application is event driven.

At bootup, two timers are started. One ticking every second and the other every 15s.

* The timer ticking every 1 second, checks and maintains the network connectivity.
* Timer ticking every 15 second, pushes the data to the cloud.

Steps:
------

Step 1: Connect to WiFi.

For this, the esp32 starts and AP (`ssid=powersense, password=password`). Connect to the AP and Sign In to the network. Give the WIFI credentials and done.

Step 2: Connect to MQTT.

After WiFi is successfully connected, the device connects to the `nodesense.baseapp.com` through MQTT.

Step 3: Poll ATM90E26 every 15s via SPI and get the data.
The readings are pushed to `nodesense.baseapp.com`.