{"id":18759784,"url":"https://github.com/scruss/micropython-mcp3001","last_synced_at":"2026-05-15T18:32:41.134Z","repository":{"id":261474847,"uuid":"884372519","full_name":"scruss/micropython-MCP3001","owner":"scruss","description":"MicroPython library for the MCP3001 10-bit 1-channel SPI Analogue-Digital converter","archived":false,"fork":false,"pushed_at":"2024-11-06T18:21:04.000Z","size":143,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T04:13:37.481Z","etag":null,"topics":["adc","mcp3001","microchip","micropython"],"latest_commit_sha":null,"homepage":"https://github.com/scruss/micropython-MCP3001","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scruss.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-11-06T16:23:56.000Z","updated_at":"2024-11-06T18:21:08.000Z","dependencies_parsed_at":"2024-11-06T19:24:23.771Z","dependency_job_id":"3537bf61-d34e-4c3d-b0bd-e158bb8b18dc","html_url":"https://github.com/scruss/micropython-MCP3001","commit_stats":null,"previous_names":["scruss/micropython-mcp3001"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scruss/micropython-MCP3001","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scruss%2Fmicropython-MCP3001","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scruss%2Fmicropython-MCP3001/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scruss%2Fmicropython-MCP3001/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scruss%2Fmicropython-MCP3001/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scruss","download_url":"https://codeload.github.com/scruss/micropython-MCP3001/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scruss%2Fmicropython-MCP3001/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018015,"owners_count":26086237,"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-10-14T02:00:06.444Z","response_time":60,"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":["adc","mcp3001","microchip","micropython"],"created_at":"2024-11-07T18:07:38.493Z","updated_at":"2025-10-14T05:21:42.641Z","avatar_url":"https://github.com/scruss.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micropython-MCP3001\n\nMicroPython library for the MCP3001 10-bit 1-channel SPI\nAnalogue-Digital converter\n\nThis library enables an MCP3001 ADC to be used with any MicroPython\nimplementation that supports SPI. Almost all MicroPython-capable\nboards have adequate ADCs onboard, so you might only want to use this\nlibrary if:\n\n* your board has no ADC (like the Wemos\n  [W600-PICO](https://www.wemos.cc/en/latest/w600/w600_pico.html#w600-pico))\n  or a very limited one (as on the ESP8266); or\n  \n* you wish to use an external reference voltage source such as an\n  LM4040.\n  \n## Installation\n\nCopy the `mcp3001.py` file to your MicroPython board's filesystem,\ntypically to the root or `/lib` folder.\n\n## Usage\n\n```python3\nimport mcp3001\n# …\nadc = mcp3001.MCP3001(spi, cs)\n```\n\n### Initialization\n\n```\nMCP3001(spi, cs [, ref_voltage])\n```\n\n* `spi` is an instance of a [Serial Peripheral Interface\n  bus](https://docs.micropython.org/en/latest/library/machine.SPI.html)\n  object, for example `spi = machine.SPI(0)`\n  \n* `cs` is an instance of an [I/O\n  pin](https://docs.micropython.org/en/latest/library/machine.Pin.html)\n  object, configured for output and ideally initially set high. An\n  example might be `cs = machine.Pin(17, machine.Pin.OUT, value=1)`\n  \n* `ref_voltage` is an optional argument to manually set the\n  reference voltage. If it is not specified as a float, the value of\n  3.3 is assumed.\n  \n### Methods\n\n* `read()` — returns an integer ADC reading from 0–1023.\n\n* `read_u16()` — returns an integer ADC reading from 0—65535. This\n  is provided for compatibility with MicroPython's\n  [method of the same name](https://docs.micropython.org/en/latest/library/machine.ADC.html#machine.ADC.read_u16).\n  \n* `read_v()` — returns a floating-point ADC reading from\n  0.0 – *reference voltage* volts.\n  \n* `reference_voltage()` — returns the ADC reference voltage as a\n  floating-point value. Returns 3.3 if none was given during\n  initialization.\n\n## Example\n\nAn MCP3001 is used to read the value of a potentiometer into a\nRaspberry Pi Pico. The brown wires in the diagram indicate analogue\nground, and have been kept separate from the black system ground\nwires. If your board doesn't have a separate **AGND** connection, a\nregular **GND** connection will do.\n\nThe default `SPI(0)` pins have been used on the Raspberry Pi Pico:\nGP16 for RX, GP17 for CSn and GP18 for SCK. In the absence of an\nexternal reference voltage, **3V3(OUT)** has been connected to\n**V\u003csub\u003eREF\u003c/sub\u003e** on the MCP3001.\n\n\u003cimg src=\"img/Pico-MCP3001_bb.jpg\" width=\"704\" height=\"416\"\nalt=\"image of an electronics breadboard, with a green Raspberry Pi\nPico board connected to an 8-pin MCP3001 ADC chip, with the output of\na small blue potentiometer being fed into the ADC input\" /\u003e\n\nCode: [test_mcp3001.py](test_mcp3001.py)\n\n## Device information\n\nDatasheet: [MicroChip MCP3001 2.7V 10-Bit A/D Converter with SPI™\nSerial\nInterface](https://ww1.microchip.com/downloads/aemDocuments/documents/APID/ProductDocuments/DataSheets/21293C.pdf)\n\n### Pinout\n\n1. **V\u003csub\u003eREF\u003c/sub\u003e** — analogue reference voltage. Should not exceed\n   **V\u003csub\u003eDD\u003c/sub\u003e**.\n\n2. **IN+** — Positive analogue input. While **IN+** and **IN-** form a\n   pseudo-differential pair, they can't float completely unrelated to\n   system voltages. Please refer to the datasheet.\n\n3. **IN-** — Negative analogue input. Typically connected to\n   **V\u003csub\u003eSS\u003c/sub\u003e**, or analogue ground (**AGND**) if your\n   micro-controller has it.\n\n4. **V\u003csub\u003eSS\u003c/sub\u003e** — Ground.\n\n5. **\u003cspan style=\"text-decoration: overline;\"\u003eCS\u003c/span\u003e/SHDN** — SPI\n   Chip Select (active low) and combined ADC shutdown line.\n\n6. **D\u003csub\u003eOUT\u003c/sub\u003e** — SPI serial data out.\n\n7. **CLK** — SPI serial data clock.\n\n8. **V\u003csub\u003eDD\u003c/sub\u003e** — power supply, 2.7–5.5 V DC.\n\nNote that the MCP3001, unlike other chips in the MCP300x range, has no\nSPI **D\u003csub\u003eIN\u003c/sub\u003e** pin. Its entire operation is controlled by the\n**\u003cspan style=\"text-decoration: overline;\"\u003eCS\u003c/span\u003e/SHDN** pin, and\nonly the data out and clock lines are used.\n\n## Credits\n\n© Stewart Russell — scruss.com, 2024.\n\nBased on Romilly Cocking's\n[mcp3008.py](https://github.com/romilly/pico-code/blob/master/src/pico_code/pico/mcp3008/mcp3008.py)\nlibrary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscruss%2Fmicropython-mcp3001","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscruss%2Fmicropython-mcp3001","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscruss%2Fmicropython-mcp3001/lists"}