Skip to content

ESP32 Power Meter with Web Interface and SD Card support

License

Notifications You must be signed in to change notification settings

shreyask21/powermeter

Repository files navigation

Power Meter

A) What is it?

It is a current/voltage sensor based on the texas instruments INA219 current+voltage sensor and the ST7789 TFT display combined with powerful ESP32. It can measure voltage, current and power at the same time.

B) Features

1. Captive Portal Webpage

When the ESP32 boots up it acts as a wifi access point and serves a captive portal webpage on address meter.local or 192.168.43.1

1

2. AJAX Based Live Graphs

The live readings are fetched automatically without refreshing the webpage with customizable polling rate!

2

3. Live Readings on a TFT Display

Displays live data on ST7789 TFT display asynchronously.

3 4

4. SD Card Support

The data is logged on the SD card in .CSV format with timestamps so plotting is easy later. The file is saved as latest.csv and the previous session files are automaically renamed so they dont get overridden.

5

6

5. Windows app

7

C) Pin Mapping

Here is a quick look at the pin connection mapping:

1. INA219

INA219 Pin ESP32 Pin
VCC 3V3
GND GND
SCL GPIO22
SDA GPIO21
VIN- N/C
VIN+ N/C

2. ST7789

ST7789 Pin ESP32 Pin
GND 3V3
VCC GND
SCL (SPI) GPIO22
SDA (SPI) GPIO21
RES (Reset) GPIO4
D/C GPIO2
CS GPIO15
BLK 3V3

Note:

If your display does not have a CS (Chip Select) pin then you have two options:

  1. You have to remove the SD Card circuitary and optionally comment out the SD card code from program. This is because the SPI bus is shared between two devices, SD card and the display. For both of them to work, each must have a seperate CS pin.

    OR

  2. Modify your display and break out the CS pin. For that, follow my guide.

3. SD Card

SD Pin ESP32 Pin
GND VIN(5V)
VCC GND
MISO GPIO19
MOSI GPIO21
SCK GPIO22
CS GPIO13

D) Required Libraries/Tools:

  1. Arduino SPIFFS Plugin
  2. Adafruit GFX Library
  3. TFT_eSPI Library
  4. Adafruit INA219 Library
  5. ESP32 AsyncTCP Library
  6. ESPAsyncWebServer Library

7