This project reads electricity and voltage data from an energy monitor sensor and sends it to Google Sheets through HTTP and to Node-RED through MQTT. We proposed adding an AI component to detect electricity theft.
- NodeMCU board
- AC Current sensor
- AC Voltage sensor
- Arduino IDE
- Adafruit MQTT library
- ESP8266WiFi library
- A Google account
- Jupyter Notebook with TensorFlow installed
- Wire the voltage and current sensors to the NodeMCU board.
- Connect the NodeMCU board to your computer via USB.
- Install the Adafruit MQTT, WiFiManager, and ESP8266HTTPClient libraries by going to
Sketch > Include Library > Manage Libraries
in the Arduino IDE, and searching for each library. - Create a Google Sheets document and obtain a Google Sheets API key and spreadsheet ID.
- Follow the instructions on this Google Sheets API documentation to create a Google Sheets API key.
- Create a new Google Sheets document and copy the document ID from the URL. (e.g. https://docs.google.com/spreadsheets/d/DOCUMENT_ID/edit)
- Paste the document ID into the
GoogleSheets.h
file where indicated.
- Connect the NodeMCU board to your WiFi network.
- The NodeMCU board will create an access point (AP) named "NodeMCU Energy Monitor" when it cannot find the saved WiFi credentials.
- Connect to the "NodeMCU Energy Monitor" AP, then enter your WiFi credentials.
- Start Node-RED on your computer and create a new MQTT input node.
- Set the MQTT input node topic to "energy-monitor/data".
- Configure the MQTT input node to output to a chart or dashboard.
- Open Jupyter Notebook on your computer.
- Create a new Python 3 notebook.
- Install the necessary libraries
- Open the
energy_monitor.ino
file in the Arduino IDE. - Edit the code to include your WiFi network name and password, as well as your MQTT broker IP address and credentials.
- Click the
Upload
button in the top-left corner of the IDE.
- The NodeMCU board will connect to your WiFi network and the MQTT broker.
- The energy monitor sensor will start measuring electricity and voltage.
- The NodeMCU board will send data to Google Sheets and Node-RED every minute.
- The Google Sheets data will be stored in the sheet named "Energy Monitor Data".
- The Node-RED data will be sent to the MQTT input node and displayed on your chart or dashboard.
If you see an error message while uploading the code, make sure that the correct board and port are selected in the Arduino IDE. If you're still having trouble, check the NodeMCU forum for help.