This project monitors the storage usage on a macOS system and displays the information on a Heltec ESP32 OLED board. The project consists of two main components: a Rust program running on the macOS system and a C++ program running on the ESP32.
The Rust program on the macOS system:
- Monitors the total and used storage space.
- Retrieves the macOS version.
- Sends the storage information and macOS version to the ESP32 via HTTP POST requests.
The C++ program on the ESP32:
- Connects to a WiFi network.
- Hosts a web server to receive storage information and macOS version.
- Displays the received information on the OLED screen.
- Rust (https://www.rust-lang.org/)
reqwest
crate for HTTP requestsstd
library for system commands and threading
- Arduino IDE (https://www.arduino.cc/en/software)
- Heltec ESP32 library (https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series)
- WiFi library
- WebServer library
- U8g2 library for OLED display
-
Install Rust: Follow the instructions at https://www.rust-lang.org/tools/install to install Rust.
-
Clone the Repository:
git clone https://github.com/yourusername/macos-storage-monitor.git cd macos-storage-monitor
-
Add Dependencies: Add the
reqwest
crate to yourCargo.toml
file:[dependencies] reqwest = "0.11"
-
Run the Rust Program:
cargo run
-
Install Arduino IDE:
Download and install the Arduino IDE from https://www.arduino.cc/en/software.
-
Install Heltec ESP32 Library:
- Open the Arduino IDE.
- Go to
File
>Preferences
. - In the "Additional Board Manager URLs" field, add:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
- Go to
Tools
>Board
>Boards Manager
. - Search for "Heltec ESP32" and install the latest version.
-
Install Required Libraries:
- Go to
Sketch
>Include Library
>Manage Libraries
. - Install the following libraries:
WiFi
WebServer
U8g2
- Go to
-
Connect the Heltec ESP32 Board:
- Connect the Heltec ESP32 board to your computer using a USB cable.
- Select the correct board and port in the Arduino IDE:
- Go to
Tools
>Board
and selectHeltec WiFi Kit 32
. - Go to
Tools
>Port
and select the port corresponding to your ESP32.
- Go to
-
Upload the C++ Program:
- Open the
esp32_storage_monitor.ino
file in the Arduino IDE. - Click the "Upload" button to upload the program to the ESP32.
- Open the
The Heltec ESP32 OLED board is a development board that features an ESP32 microcontroller and a built-in OLED display. It is ideal for IoT projects that require both connectivity and display capabilities.
- ESP32 microcontroller with WiFi and Bluetooth capabilities
- Built-in 0.96-inch OLED display
- Multiple GPIO pins for connecting sensors and peripherals
-
Connect the Board:
- Use a USB cable to connect the Heltec ESP32 board to your computer.
-
Install Drivers:
- If necessary, install the USB-to-serial drivers for the ESP32. You can find the drivers at: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers
-
Select the Board and Port:
- In the Arduino IDE, go to
Tools
>Board
and selectHeltec WiFi Kit 32
. - Go to
Tools
>Port
and select the port corresponding to your ESP32.
- In the Arduino IDE, go to
-
Rust Program:
- The Rust program runs on the macOS system and periodically retrieves the total and used storage space using the
diskutil
command. - It also retrieves the macOS version using the
sw_vers
command. - The program sends the storage information and macOS version to the ESP32 via HTTP POST requests.
- The Rust program runs on the macOS system and periodically retrieves the total and used storage space using the
-
ESP32 Program:
- The ESP32 connects to a WiFi network and hosts a web server.
- It receives the storage information and macOS version from the Rust program.
- The information is displayed on the built-in OLED screen.
This project is licensed under the MIT License. See the LICENSE file for details.
### Conclusion