{"id":30196400,"url":"https://github.com/hnz1102/mini-current-meter","last_synced_at":"2025-08-13T05:19:30.353Z","repository":{"id":309341550,"uuid":"1026252695","full_name":"hnz1102/mini-current-meter","owner":"hnz1102","description":"Mini Current Meter using INA228A ultra-precise digital power monitor","archived":false,"fork":false,"pushed_at":"2025-08-11T09:39:36.000Z","size":3899,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T11:37:20.670Z","etag":null,"topics":["battery","digital","esp32-c3","ina228","influxdb","logger","meter","rust","wifi"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hnz1102.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T15:05:07.000Z","updated_at":"2025-08-11T09:38:05.000Z","dependencies_parsed_at":"2025-08-11T11:37:45.075Z","dependency_job_id":"5fba200b-456b-460d-b585-5a06b1c1ef9c","html_url":"https://github.com/hnz1102/mini-current-meter","commit_stats":null,"previous_names":["hnz1102/mini-current-meter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hnz1102/mini-current-meter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnz1102%2Fmini-current-meter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnz1102%2Fmini-current-meter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnz1102%2Fmini-current-meter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnz1102%2Fmini-current-meter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hnz1102","download_url":"https://codeload.github.com/hnz1102/mini-current-meter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hnz1102%2Fmini-current-meter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270183685,"owners_count":24541363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["battery","digital","esp32-c3","ina228","influxdb","logger","meter","rust","wifi"],"created_at":"2025-08-13T05:19:26.900Z","updated_at":"2025-08-13T05:19:30.330Z","avatar_url":"https://github.com/hnz1102.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003eMini Current Meter\u003c/code\u003e\u003c/h1\u003e\n  \u003cp\u003e\n    \u003cimg src=\"doc/front.jpg\"/\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n# Mini Current Meter - Mini Size High-resolution Digital Power Monitor and Logger\n\nThis tool provides a logging function that captures data on voltage, current and power consumption. Voltage input range is from 0 to 35V, maximum current input is 10A. \n\n# Features\n\n**High-resolution** - By using Texas Instruments INA228 IC - 20-bit delta-sigma ADC, it can obtain measurement data with 195µV bus voltage and 163.84mV shunt voltage resolution.\n\n**Microcontroller on board** - No need for a client PC when measuring. Data is sent directly to the server.\n\n**Transfer measurement data via WiFi** - This logger can transfer data to a Linux PC via WiFi network and you can view the dashboard graph in InfluxDB.\n\n**Calibration Function** - Built-in calibration functionality with persistent storage. Long press the center button for 2+ seconds to perform automatic calibration that corrects voltage and current measurement offsets. Calibration results are automatically saved to non-volatile storage and restored on power-up.\n\n**Change Channel** - This logger allows you to change the measurement channel by pushing the center button with a pin. Once you push the center button, the channel will change to the next channel. The channel cycles through 1, 2, 3, 4, and back to 1.\n\n**Battery Powered** - Uses LiPo battery. It can run for 12 hours on a single charge. The battery is charged via USB Type-C port.\n\n**Mini Size** - The dimensions are 37mm(W) x 67mm(D) x 55mm(H). It can be used in various locations.\n\n# How to Use the Logger\n\n![PinOut](doc/pinout.png)\n\nThis meter has a pin socket with three pins: VBUS/VIN+, GND, and VIN-. The VBUS/VIN+ pin is connected to the voltage input or the current input. The GND pin is connected to the ground of the voltage or current input. The VIN- pin is connected to the load side of the voltage or current input.\n\n![How to connect](doc/howtomeasure.png)\n\nDO NOT CONNECT WITH REVERSE POLARITY BETWEEN VBUS/VIN+ AND GND. IF CONNECTED INCORRECTLY, THE ADC IC WILL BE DAMAGED.\n\nThe measurement interval time is fixed at 100ms. Each measurement data is sent to the server every 1 second.\n\nThe display shows the current voltage, current, power consumption, battery voltage, buffer consumption, WiFi connection status, and channel number.\nIf the WiFi Access Point cannot establish a connection, the display will not show the WiFi indicator. If voltage is measured while WiFi is not connected, the data is stored in the logger's internal memory buffer. The buffer that is not being sent to the server is indicated by a buffer bar on the display. When the buffer is full (the bar reaches the right edge of the display), measurement stops automatically. When WiFi is connected and data is transmitted to the server, the buffer bar shrinks to the left. When the buffer is full and measurement is stopped, measurement will resume automatically after the buffer drops below 50%.\n\n![board](doc/board.jpg)\n\n![Display](doc/display.jpg)\n\nIf you send data to the server, you can see real-time data using the Dashboard in [InfluxDB](https://www.influxdata.com/influxdb/). If you have 3 meters, you can view data on the dashboard with different channels simultaneously.\n\nThese meters are small and light, so you can use them in various locations. For example, you can use them to measure circuit current on your breadboard, or you can measure the current at each measurement point on your breadboard circuit. \n\n![breadboard](doc/meter_with_breadboard.jpg)\n\n![dashboard](doc/dashboard_4ch.png)\n\nTo charge the battery, simply connect to a USB Type-C port from a bus-powered USB port. During charging, the CHG LED is RED. After charging is complete, the FUL LED is GREEN and charging will stop automatically. However,\n\nDO NOT CONTINUE CHARGING IF THE BATTERY IS FULL FOR A LONG TIME.\n\n# Calibration Function\n\nThe Mini Current Meter includes built-in calibration functionality to correct measurement offsets and improve accuracy.\n\n## How to Perform Calibration\n\n1. **Prepare for calibration**: Ensure no current is flowing through the shunt resistor and no voltage is applied to the measurement inputs (VBUS/VIN+ and GND should be at the same potential).\n\n2. **Start calibration**: Press and hold the center button for **2-5 seconds**. The display will show \"Calibrating...\" message.\n\n3. **Calibration process**: The device automatically takes 300 samples over 3 seconds to calculate average voltage and current offsets.\n\n4. **Completion**: When calibration is complete, the display will show \"Calibration OK\" for 2 seconds, and the offset values will be automatically saved to non-volatile storage.\n\n## Button Functions\n\n- **Short press** (\u003c 2 seconds): Change measurement channel (1-4)\n- **Long press** (2+ seconds): Perform calibration\n\n## Calibration Features\n\n- **Automatic offset correction**: Calibration corrects both voltage and current measurement offsets\n- **Persistent storage**: Calibration results are automatically saved to NVS (Non-Volatile Storage) and restored on power-up\n- **High accuracy**: Uses 300-sample averaging for precise offset calculation\n- **User feedback**: Real-time status display during calibration process\n\n## When to Calibrate\n\n- **Initial setup**: Perform calibration when first using the device\n- **Temperature changes**: Recalibrate if operating temperature changes significantly\n- **Accuracy concerns**: If measurements appear to have a systematic offset\n- **After firmware updates**: Recalibration recommended after major firmware changes\n\n**Note**: Always ensure zero current flow and zero voltage difference during calibration for best results.\n\n# Recent Updates\n\n## Version 2025.08 - Calibration and Accuracy Improvements\n\n- **Added calibration functionality**: Built-in calibration system with persistent storage\n- **Improved measurement accuracy**: Automatic offset correction for voltage and current readings\n- **Enhanced button handling**: Added debouncing and multi-function button support (channel change, calibration, reset)\n- **NVS integration**: Calibration data automatically saved and restored across power cycles\n- **User interface improvements**: Real-time calibration status display and user feedback\n- **Error correction**: Fixed voltage measurement accuracy issues and ADC offset handling\n\n# How to Build from Code and Install to the Unit\n\nUsing Ubuntu 22.04 LTS\n\n1. Install Rust Compiler\n```bash\nsudo apt update \u0026\u0026 sudo apt -y install git python3 python3-pip gcc build-essential curl pkg-config libudev-dev libtinfo5 clang libclang-dev llvm-dev udev libssl-dev python3.10-venv\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\nselect No.1\n\nAfter installation, you need to set the environment variable for Rust.\nAdd the following line to your shell configuration file (e.g., `~/.bashrc`, `~/.zshrc`, etc.):\n```bash\nsource \"$HOME/.cargo/env\"\n```\n\n2. Install toolchain for ESP32-C3\n```bash\ncargo install ldproxy\ncargo install espup\ncargo install cargo-espflash\n```\n\nAt this time (2025-07-25), espup cannot be compiled. If you get an error, please use the following command to install the toolchain.\n```bash\ncargo install cargo-binstall\ncargo binstall espup\n```\n\n```bash\nespup install\nespup update\n```\n\nThen, run the following command to set the environment for the ESP32-C3 toolchain:\n```bash\n. ./export-esp.sh\n```\n\n3. Add UDEV rules\n```bash\nsudo sh -c 'echo \"SUBSYSTEMS==\\\"usb\\\", ATTRS{idVendor}==\\\"303a\\\", ATTRS{idProduct}==\\\"1001\\\", MODE=\\\"0666\\\"\" \u003e /etc/udev/rules.d/99-esp32.rules'\nsudo udevadm control --reload-rules\nsudo udevadm trigger\n```\n\n4. Download Mini Current Meter code\n```bash\ngit clone https://github.com/hnz1102/mini-current-meter.git\ncd mini-current-meter/code\n``` \n5. Setting WiFi SSID, Password, and InfluxDB Server IP Address\n\nYou need to set the WiFi SSID, password, and InfluxDB server IP address in the configuration file.\nYou can find the configuration file 'cfg.toml.samp' in the `code` directory. You need to copy this file to `cfg.toml` and edit it.\n\n```bash\nnano code/cfg.toml\n\n[mini-current-meter]\nwifi_ssid = \"XXXXXXXXXXXX\"  # Set your WiFi SSID.\nwifi_psk = \"XXXXXXXXXXXXX\"  # Set your WiFi Password.\nshunt_resistance = \"0.005\"\ninfluxdb_server = \"\u003cIP Address\u003e:8086\"  # Set your InfluxDB server IP address.\ninfluxdb_api_key = \"\u003cAPI_KEY\u003e\" # Set your InfluxDB API Key.\ninfluxdb_api = \"/api/v2/write?org=\u003cORG\u003e\u0026bucket=LOGGER\u0026precision=ns\" # Set your InfluxDB API URL. You must set \u003cORG\u003e same as Initial Organization Name.\ninfluxdb_tag = \"ch\"\ninfluxdb_measurement = \"minicurrent\"\nmax_records = \"1023\"\n```\n\n6. Connecting the Board and Setting Device and Toolchain\n```bash\nConnect the mini-current-meter via USB to this build code PC. Then, \n$ cargo espflash board-info\nselect /dev/ttyACM0\nChip type:         esp32c3 (revision v0.4)\nCrystal frequency: 40MHz\nFlash size:        4MB\nFeatures:          WiFi, BLE\nMAC address:       xx:xx:xx:xx:xx:xx\n\n$ rustup component add rust-src --toolchain nightly-2023-06-10-x86_64-unknown-linux-gnu\n```\n\n7. Build Code and Write to Flash\n```bash\n$ cargo espflash flash --release --monitor\nApp/part. size:    964,240/3,145,728 bytes, 30.23%\n[00:00:00] [========================================]      12/12      0x0                                                                       \n[00:00:00] [========================================]       1/1       0x8000                                                                    \n[00:00:11] [========================================]     546/546     0x10000                                                                   [2023-11-11T10:17:05Z INFO ] Flashing has completed!\n\nAutomatically boots!\n```\n# How to Install InfluxDB\n\n1. Download [InfluxDB](https://docs.influxdata.com/influxdb/v2.7/install/?t=Linux) and Install\n```bash\n$ wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.7.0-amd64.deb\n$ sudo dpkg -i influxdb2-2.7.0-amd64.deb\n$ sudo service influxdb start\n```\n\n2. Configure InfluxDB\n\n```\nConnect to 'http://\u003cInfluxDB installed PC Address\u003e:8086'\n```\nClick `GET STARTED` and set `Username`, `Password`, `Initial Organization Name`, and `Initial Bucket Name`\n|Term|Value|\n|---|---|\n|Username|Set login username as InfluxDB administrator web console|\n|Password|Set login password as InfluxDB administrator web console|\n|Initial Organization Name| Organization Name ex. ORG|\n|Initial Bucket Name| LOGGER |\n\nAfter setting these, click `CONTINUE`.\n\n3. Copy the Operator API Token\n\nYou can see the operator API token in the browser. YOU WON'T BE ABLE TO SEE IT AGAIN!\nIf you want to get a new API token, click `API Tokens` menu from `Sources` Icon, then click `GENERATE API TOKEN` and select `All access token`, click `Save`.\nYou can see the new API token and copy it.\nAfter copying the token, click `CONFIGURE LATER`.\n\n4. Import the Dashboard Template\n\nClick the `Dashboard` icon, and select `Import Dashboard` from the `CREATE DASHBOARD` menu.\n\nDrop the `mini-current-meter/dashboard/mini-current-meter.json` file to `Drop a file here`, then click `IMPORT JSON AS DASHBOARD`.\n\nYou can see the `Mini Current Meter Dashboard` panel on the Dashboards page.\n\nClick this panel, and you can see the Mini Current Meter Dashboard.\n\nIf you want to customize the dashboard design, click the configure mark. You can change the graph design.\n\n6. Start Mini Current Meter Logging and Send Data\n\nTurn on the power switch. Logging data will be sent to InfluxDB. You can see the data on the dashboard.\n\n## Schematic, PCB Gerber and Container 3D Data\n\nThere is schematic data in the hardware directory including 3D printing data as 3MF format files. \n\n![Container](doc/container.jpg)\n\n## LICENSE\nThis source code is licensed under MIT. Other Hardware Schematic documents are licensed under CC-BY-SA V4.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhnz1102%2Fmini-current-meter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhnz1102%2Fmini-current-meter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhnz1102%2Fmini-current-meter/lists"}