{"id":13802279,"url":"https://github.com/matthias-bs/MicroPython-ADC_Cal","last_synced_at":"2025-05-13T13:30:27.784Z","repository":{"id":45591492,"uuid":"366173307","full_name":"matthias-bs/MicroPython-ADC_Cal","owner":"matthias-bs","description":"MicroPython ESP32 library for calibrated on-chip ADC conversion ","archived":false,"fork":false,"pushed_at":"2023-02-07T09:16:16.000Z","size":139,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T04:11:26.584Z","etag":null,"topics":["esp32","micropython","micropython-esp32"],"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/matthias-bs.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":"2021-05-10T20:54:51.000Z","updated_at":"2025-04-27T08:00:06.000Z","dependencies_parsed_at":"2023-02-18T19:25:33.564Z","dependency_job_id":null,"html_url":"https://github.com/matthias-bs/MicroPython-ADC_Cal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias-bs%2FMicroPython-ADC_Cal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias-bs%2FMicroPython-ADC_Cal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias-bs%2FMicroPython-ADC_Cal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthias-bs%2FMicroPython-ADC_Cal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthias-bs","download_url":"https://codeload.github.com/matthias-bs/MicroPython-ADC_Cal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253949907,"owners_count":21989272,"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":["esp32","micropython","micropython-esp32"],"created_at":"2024-08-04T00:01:40.986Z","updated_at":"2025-05-13T13:30:27.506Z","avatar_url":"https://github.com/matthias-bs.png","language":"Python","readme":"[![formatting: lint](https://github.com/matthias-bs/MicroPython-ADC_Cal/actions/workflows/code-formatting.yml/badge.svg)](https://github.com/matthias-bs/MicroPython-ADC_Cal/actions/workflows/ci.yml)\n[![GitHub release](https://img.shields.io/github/release/matthias-bs/MicroPython-ADC_Cal?maxAge=3600)](https://github.com/matthias-bs/MicroPython-ADC_Cal/releases)\n\n# MicroPython-ADC_Cal\n**MicroPython ESP32 library for calibrated on-chip ADC conversion**\n\n***Please refer to ESP32 documentation for maximum ADC input voltage ratings!!!***\n\nThe [Espressif IDF API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html) describes the limitations of the ESP32's built-in analog-to-digital converter - and provides a (partial) solution in terms of providing a method for improving its accuracy by using a chip specific calibration value (or two calibration values, respectively) stored in the efuse. It also provides useful information regarding *noise mitigation* and the *suggested range* of input voltages in each mode.\n\nThis [ADC calibration scheme](https://github.com/espressif/esp-idf/blob/master/components/esp_adc_cal/esp_adc_cal_esp32.c) is (in parts) provided by the ADC1Cal class.\n\nThe following restriction applies:\n* Only V_ref calibration mode is supported\u003cbr\u003e(This is due to the fact that the author does not have a proper ESP32 device to test two point calibration mode.)\n\n`ADC1Cal` extends MicroPython's ESP32 `machine.ADC` class. Please refer to the [MicroPython ESP32 ADC documentation](https://docs.micropython.org/en/latest/esp32/quickref.html#adc-analog-to-digital-conversion) for methods and attributes inherited from the `ADC` class.\n\n    Attributes:\n        name (string):      instance name (for debugging)\n        vref (int):         ADC reference voltage in mV (from efuse calibration data or supplied by programmer)\n\n    Methods:\n        @property\n        voltage()\n            Get voltage measurement [mV]\n\n            Returns:\n                float: voltage [mV]\n        \n        __str__()\n            Dump object info as a string\n            \n            Returns:\n                string: \"Name: \u003cn\u003e  width: \u003cw\u003e, attenuation: \u003ca\u003e, raw value: \u003craw\u003e, value: \u003cvoltage\u003e\"\n\n**Usage example:**\n\n        from machine import Pin\n        import adc1_cal\n        \n        ADC_PIN   = 35                # ADC input pin no.\n        DIV       = 1                 # div = V_measured / V_input; here: no input divider\n        AVERAGING = 10                # no. of samples for averaging (default: 10)\n        \n        # vref = None -\u003e V_ref calibration value is read from efuse\n        ubatt = ADC1Cal(Pin(ADC_PIN, Pin.IN), DIV, None, AVERAGING, \"ADC1 Calibrated\")\n        \n        # set ADC result width\n        ubatt.width(ADC.WIDTH_10BIT)\n    \n        # set attenuation\n        ubatt.atten(ADC.ATTN_6DB)\n    \n        print('ADC Vref: {:4}mV'.format(ubatt.vref))\n    \n        print('Voltage:  {:4.1f}mV'.format(ubatt.voltage))\n\n        \n","funding_links":[],"categories":["Libraries"],"sub_categories":["IO"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthias-bs%2FMicroPython-ADC_Cal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthias-bs%2FMicroPython-ADC_Cal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthias-bs%2FMicroPython-ADC_Cal/lists"}