Chapter 8: A Power Struggle

Day 24: Energy Consumption Tracker

Day 24: Energy Consumption Tracker

Managing energy consumption is crucial for the efficient operation of the Nebula Raider. As a cadet, you are tasked with developing an energy consumption tracker that monitors and logs the energy usage of various systems on the ship. This system will help the crew optimize

energy usage and ensure that critical systems have the power they need.


Components Needed:


Raspberry Pi Pico WH Microcontroller

LCD 1602 I2C

220 ohm Resistors

LEDs

Buttons

Breadboard

Jumper wires


Instructions:


Set Up the Circuit:


Connect the LCD 1602 display to the Raspberry Pi Pico using the I2C interface (SDA to GP0, SCL to GP1).

Connect the LEDs and buttons on GPIO pins.

Use jumper wires to make all necessary connections on the breadboard, ensuring a secure and organized setup.

Circuit Diagram

Write the Code:


Open your coding environment and write the following Python code to create the energy consumption tracker.


Test the System:

Save and run the code on your Pico.


The LCD should display the initial energy consumption of each device.

When a button is pressed, the corresponding device’s energy consumption should increase by 1 kWh, and the LED should briefly light up.

The updated energy consumption should be displayed on the LCD.


Learning Outcomes:


Energy Management: Understand the principles of monitoring and managing energy consumption.

Microcontroller Programming: Develop skills in writing code to read buttons and array values and display it on an LCD screen


Extension Ideas:


Data Logging: Implement data logging to record energy consumption over time.

Remote Monitoring: Create a web interface to remotely monitor energy usage and receive alerts for high consumption.

Advanced Analysis: Add more sensors to gather additional data and perform advanced analysis of energy consumption patterns.