{"id":13802290,"url":"https://github.com/openfablab/mcp4728","last_synced_at":"2025-05-13T13:30:30.994Z","repository":{"id":215170603,"uuid":"276468297","full_name":"openfablab/mcp4728","owner":"openfablab","description":"Helpful libraries and other stuff for micropython","archived":false,"fork":false,"pushed_at":"2020-07-01T20:19:35.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T12:34:43.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/openfablab.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}},"created_at":"2020-07-01T19:48:23.000Z","updated_at":"2023-11-21T10:32:29.000Z","dependencies_parsed_at":"2024-01-07T21:53:24.115Z","dependency_job_id":null,"html_url":"https://github.com/openfablab/mcp4728","commit_stats":null,"previous_names":["openfablab/mcp4728"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfablab%2Fmcp4728","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfablab%2Fmcp4728/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfablab%2Fmcp4728/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openfablab%2Fmcp4728/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openfablab","download_url":"https://codeload.github.com/openfablab/mcp4728/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253949917,"owners_count":21989273,"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":[],"created_at":"2024-08-04T00:01:41.213Z","updated_at":"2025-05-13T13:30:30.693Z","avatar_url":"https://github.com/openfablab.png","language":"Python","readme":"# MCP4728 library for micropython\n\nHelper library for the Microchip MCP4728 I2C 12-bit Quad DAC \n\nIt is based on Adafruit_CircuitPython_MCP4728 library by Bryan Siepert\nhttps://github.com/adafruit/Adafruit_CircuitPython_MCP4728/blob/master/adafruit_mcp4728.py\n\nPorted to microPython by Alexander Olikevich (openfablab) with some changes:\n\n* Channel properties read from device not only at init but at every call\n* Added power down control function\n* Added config() function for laconic channel initial setup\n* Changed \"raw_value\" to \"value\" and channel names from \"channel_a\" to \"a\", etc.\n* Removed confusing emulation of 16 bit interface\n* Fixed incorrect register values types on initialisation \n* Gains values read and write as 1 or 2\n* Rewrited Vref control for simplicity\n\n# Usage example (on ESP32):\n\nfrom machine import Pin, I2C\n\nimport mcp4728\n\ni2c = I2C(0, scl=Pin(27), sda=Pin(4), freq=400000)\n\n\n\n#Create the MCP4725 drivers specifying the I2C bus the MCP4728 is connected to and the I2C slave address of the sensor\n\ndac1=mcp4728.MCP4728(i2c,0x60)\n\ndac2=mcp4728.MCP4728(i2c,0x61)\n\n\n\n#Get channel b 12-bit current value\n\ndac1.b.value\n\n\n#Set channel b 12-bit value\n\ndac1.b.value=4095\n\ndac1.b.value=0\n\ndac1.b.value=123\n\n\n#Get channel b value as a floating point number in the range 0.0 to 1.0\n\ndac1.b.normalized_value\n\n\n#Set channel b value as a floating point number in the range 0.0 to 1.0\n\ndac1.b.normalized_value=0.51123\n\n\n#Get channel d Vref\n\ndac1.d.vref\n\n\n#Set channel d Vref (voltage reference source). Set 0 for VDD or 1 for internal 2.048V reference.\n\ndac1.d.vref=1\n\n\n#Get channel c gain\n\ndac1.c.gain\n\n\n#Sets the gain of the channel c if the Vref for the channel is 1 (INTERNAL). Has no effect if the Vref for the channel is 0 (VDD)\n\n#With gain set to 1, the output voltage goes from 0v to 2.048V. If a channel's gain is set 2, the voltage goes from 0v to 4.096V.\n\ndac1.c.gain=1\n\n\n#Get channel b power state\n\ndac1.b.pdm\n\n#Set channel b power state. 0 for normal operation, or other to turn off most of the channel circuits and connect VOUT to GND by resistor (1: 1 kΩ, 2: 100 kΩ, 3: 500 kΩ).\n\ndac1.b.pdm=0\n\n\n#Set value, vref, gain and power mode for channel a\n\ndac1.a.config(0,1,1,0) \n","funding_links":[],"categories":["Libraries"],"sub_categories":["IO"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenfablab%2Fmcp4728","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenfablab%2Fmcp4728","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenfablab%2Fmcp4728/lists"}