{"id":27115396,"url":"https://github.com/tyeth/python_nordic_ppk2_wipper_secrets_brownout","last_synced_at":"2025-06-11T10:34:07.176Z","repository":{"id":264033482,"uuid":"869104552","full_name":"tyeth/python_nordic_ppk2_wipper_secrets_brownout","owner":"tyeth","description":"using a nordic PPK2 to power a device under test with varying voltages, repeatedly testing for brownout","archived":false,"fork":false,"pushed_at":"2024-12-05T21:49:49.000Z","size":608,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-05T22:28:08.847Z","etag":null,"topics":["brownout","nordic","ppk2","wippersnapper"],"latest_commit_sha":null,"homepage":"","language":"Python","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/tyeth.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}},"created_at":"2024-10-07T18:14:20.000Z","updated_at":"2024-12-05T21:49:53.000Z","dependencies_parsed_at":"2024-11-21T16:55:41.591Z","dependency_job_id":null,"html_url":"https://github.com/tyeth/python_nordic_ppk2_wipper_secrets_brownout","commit_stats":null,"previous_names":["tyeth/python_nordic_ppk2_wipper_secrets_brownout"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyeth","download_url":"https://codeload.github.com/tyeth/python_nordic_ppk2_wipper_secrets_brownout/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595332,"owners_count":20963943,"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","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":["brownout","nordic","ppk2","wippersnapper"],"created_at":"2025-04-07T04:55:00.688Z","updated_at":"2025-04-07T04:55:01.227Z","avatar_url":"https://github.com/tyeth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Voltage Cycle Test with PPK2 and ESP32-S3\r\n\r\n## Overview\r\nThis project automates the power cycling of an ESP32-S3 device using the Nordic Power Profiler Kit 2 (PPK2) to evaluate its performance under varying voltage conditions. \r\n\r\nThe project includes scripts to control the PPK2 and monitor the ESP32-S3 over serial communication to verify successful boot and operational stability. \r\n\r\nThe current code is expecting the [Adafruit WipperSnapper firmware](https://github.com/adafruit/adafruit_Wippersnapper_arduino/) to be running on the Device Under Test (DUT), and was written to test the loss/corruption of secrets.json in a fatfs partition when running on battery power after random number of reboots.\r\n\r\n## Requirements\r\n\r\n### Hardware\r\n- **Nordic PPK2**: Used as a programmable power supply and for measuring power consumption.\r\n- **ESP32-S3 Board**: Device under test.\r\n- **Computer**: To run the python script(s) and control the PPK2 and serial communication.\r\n- **USB Interruptor**: To manage isolating the power between USB VBUS and the Device Under Test while still allowing USB Communications with PC.\r\n\r\n### Software\r\n- **Python 3.8+**: Required to run the scripts (assume 3.12 or something more modern).\r\n- **IRNAS PPK2 API Library**: [ppk2-api-python](https://github.com/IRNAS/ppk2-api-python) \r\n  - While available with `pip install ppk2-api`, there may be things worth picking up in the PRs by using from git:\r\n  - Clone and install using the following commands:\r\n    ```bash\r\n    git clone https://github.com/IRNAS/ppk2-api-python.git\r\n    cd ppk2-api-python\r\n    echo 'checkout a PR branch now or in the future and it will be available immediately'\r\n    pip install -e .\r\n    ```\r\n- **PySerial**: For communication with the ESP32-S3. (Probably already available)\r\n  ```bash\r\n  pip install pyserial\r\n  ```\r\n- **Logging Module**: Configured to record test logs in a `voltage_test.log` file.\r\n\r\n## Setup\r\n\r\n[Fritzing diagram: ](brownout.fzz)\r\n\u003cimg src=\"brownout_bb.png?raw=true\"\u003e\r\n\r\n0. Disconnect all usb cables + depower all devices.\r\n1. **Connect Hardware**:\r\n   - Connect the **ESP32-S3** to the PPK2, I'm using the Battery input on an Adafruit QTPY ESP32S3 (n4r2) with Lipo BFF, using the battery input pins for the PPK2 connection.\r\n     - Alternatively use an appropriate connection method to power the board. e.g. A Metro board (debuggable) with StemmaQT MAX17048 taking the ppk2 supply as battery and then a two female jst-ph plugged cable (or jumper cables) from the MAX17048 second port to the Metro power in (battery jst).\r\n   - Use a **USB Switchable Breakout a.k.a. \"Isolator\"** [I used this one](https://www.adafruit.com/product/5972) to disconnect the USB VBUS from the computer and the ESP32s3/DUT.\r\n   - Ensure **ground connections** between all components (should be now).\r\n   - If using logic pins of PPK2 then include a vRef and ground connection to the 3v3 + Gnd from QTPY to the PPK2 logic pins labelled VCC + GND\r\n\r\n2. **Configure COM Ports**:\r\n   - Edit the Python scripts to set the correct COM ports for both the PPK2 and ESP32-S3 connections.\r\n   - Replace `PPK2_COM_PORT` and `SERIAL_PORT` with your specific port numbers (e.g., `COM34` for PPK2 and `COM36` for ESP32-S3).\r\n\r\n## Scripts\r\n- **Main Voltage Cycle Test Script**: This script powers on the DUT, runs through multiple voltage levels, and checks if the ESP32-S3 boots and connects to WiFi successfully.\r\n  - The voltage starts at `3.0V` and decrements down to `2.8V` with steps of `0.01V`. The ESP32-S3 is tested for each voltage level.\r\n  - Logs are saved in a file named `voltage_test.log`.\r\n  - The power cycle test is repeated `50` times per voltage level.\r\n  - Adjust the numbers to suite your needs, along with the conditionals for success+failure serial messages.\r\n  \r\n- **Power Toggle Test Script**: This script tests if the power from PPK2 is toggled on/off as expected. It cycles between `800mV`, `1500mV`, and `3000mV` every `3 seconds`, turning the device off for `2 seconds` between cycles.\r\n\r\n## Usage\r\n1. **Voltage Cycle Test Script**\r\n   - This script is used to evaluate the ESP32-S3 boot reliability under varying voltages.\r\n   - Run the script using:\r\n     ```bash\r\n     python voltage_cycle_test.py\r\n     ```\r\n   - Logs and measurement data will be saved to CSV files for each cycle.\r\n\r\n2. **Power Toggle Test Script**\r\n   - The script helps verify if the power from the PPK2 is reliably toggling between the defined voltage levels.\r\n   - Run the script using:\r\n     ```bash\r\n     python power_toggle_test.py\r\n     ```\r\n\r\n## Example output (logging level changed to DEBUG):\r\n![Example Serial Output Image](example.jpg)\r\n\r\n## Notes\r\n- Ensure that the **ESP32-S3** has time to settle after each power cycle.\r\n- Logs and power measurements are saved to help analyze device behavior.\r\n- The script retries connection to the ESP32-S3 serial port until it is successful, ensuring stable communication after power cycling.\r\n\r\n## License\r\nThis project uses the licenses of the respective dependencies and no others.\r\n\r\n## Acknowledgements\r\n- [IRNAS](https://github.com/IRNAS) for providing the **PPK2 Python API** to automate power monitoring and logging.\r\n- [Adafruit](https://www.adafruit.com) for providing me with gainful employment and the hardware to play with such things.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyeth%2Fpython_nordic_ppk2_wipper_secrets_brownout/lists"}