{"id":13802574,"url":"https://github.com/mcauser/micropython-lm75a","last_synced_at":"2025-07-28T05:32:48.679Z","repository":{"id":150620663,"uuid":"296008171","full_name":"mcauser/micropython-lm75a","owner":"mcauser","description":"MicroPython driver for the LM75A digital temperature sensor","archived":false,"fork":false,"pushed_at":"2020-09-25T07:33:05.000Z","size":580,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T13:30:43.542Z","etag":null,"topics":["cjmcu-75","lm75a","micropython"],"latest_commit_sha":null,"homepage":"","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/mcauser.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-09-16T11:09:02.000Z","updated_at":"2024-08-04T00:07:25.116Z","dependencies_parsed_at":"2023-05-06T09:32:18.140Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/micropython-lm75a","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mcauser/micropython-lm75a","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-lm75a","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-lm75a/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-lm75a/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-lm75a/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/micropython-lm75a/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-lm75a/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267468383,"owners_count":24092332,"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-07-28T02:00:09.689Z","response_time":68,"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":["cjmcu-75","lm75a","micropython"],"created_at":"2024-08-04T00:01:47.731Z","updated_at":"2025-07-28T05:32:48.345Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# MicroPython LM75A Digital Temperature Sensor\n\nA MicroPython library for interfacing with an [NXP LM75A](https://www.nxp.com/products/sensors/ic-digital-temperature-sensors/digital-temperature-sensor-and-thermal-watchdog:LM75A) I2C digital temperature sensor and thermal watchdog.\n\nThis sensor is featured on the CJMCU-75 module.\n\n![demo](docs/lm75a.jpg)\n\nThe NXP version of LM75A has 11 temperature bits, improving the precision from 0.5°C to 0.125°C with a temperature range of -55 to 125°C.\n\nThe device operates in two modes normal and shutdown.\n\nIn normal mode, the temperature is calculated every 100ms and saved to the temperature register.\n\nIn shutdown mode, the temperature register contains the last known value and the ADC and comparator are idle to reduce power consumption.\nThe device remains active on the I2C bus for reads and writes.\n\nThere are two temperature thresholds over-temperature shutdown (Tos) and hysteresis (Thyst).\nAfter the temperature is calculated in normal mode, the value is compared with the threshold values Tos and Thyst to trigger OS output.\n\nThe temperature value has 11-bit precision (0.125°C per bit), however the Tos and Thyst values are 9-bit (0.5°C per bit).\nWhen comparing the temperature with the thresholds, the 9 most significant bits of temperature are used.\n\nThe OS output (over-temperature shutdown) can be configured to run as a comparator (default) or as an interrupt.\n\nIn comparator mode, OS behaves like a thermostat and becomes active and holds when the temperature exceeds Tos and only deactivates once the temperature falls below Thyst.\nA real world example for using comparator mode would be to switch on a fan once the temperature exceeds Tos, then switch it off once the temperature falls below Thyst.\n\nIn interrupt mode, OS activates when the temperature exceeds the Tos value and remains active until any register is read.\nIt will only retrigger once the temperature falls below Thyst, where it OS goes active again until any register is read.\n\nIn both cases OS output is only activated after a programmable number of consecutive faults.\nTo help reduce noise, there is a fault queue for counting consecutive faults.\n\nThe OS output polarity can also be configured.\nOn the CJMCU-75 module, when OS is active, the onboard red LED illuminates.\n\nTos temperature must be greater than Thyst, otherwise the OS output is erratic.\n\nPower on defaults: Normal mode, OS comparator mode, Tos: 80°C, Thyst: 75°C, OS output active LOW\n\n\n# Examples\n\n## Basic Usage\n\n```python\nimport lm75a\nfrom machine import I2C, Pin\ni2c = I2C(scl=Pin(22), sda=Pin(21))\nsensor = lm75a.LM75A(i2c)\n\n# Single measurement\nprint(sensor.temp())\n\n# Continuous measurement\nwhile True:\n\tprint(sensor.temp())\n\ttime.sleep_ms(100)\n\n# Using interrupts\nos = Pin(5, Pin.IN, Pin.PULL_UP)\n\ndef os_int(pin):\n\tprint(\"IRQ: Temp \u003c Thyst\" if pin.value() == 1 else \"IRQ: Temp \u003e Tos\")\n\nos.irq(handler=os_int, trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING)\n\nlast = 0\nwhile True:\n\tt = sensor.temp()\n\tif t != last:\n\t\tprint(t)\n\t\tlast = t\n\ttime.sleep_ms(100)\n\n# Disable os interrupt\nos.irq(handler=None, trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING)\n\n# Shutdown mode\nsensor.config(shutdown=1)\n# Reduced power consumption mode. Reading the temp register returns the last known value.\n\n# Normal mode\nsensor.config(shutdown=0)\n# Back online, temperature read every 100ms.\n\n# Set OS comparator mode\nsensor.config(os_mode=0)\n# In this mode, os is active when temp has exceeded Tos and inactive when temp dropped below Thyst.\n\n# Set Thyst temperature (-55 to 125°C)\nsensor.thyst(24)\n# When temp goes below 24°C, os deactivates.\n\n# Set Tos temperature (-55 to 125°C)\nsensor.tos(27)\n# When temp goes above 27°C, os activates.\n\n# Set OS polarity\nsensor.config(os_polarity=1)\n# 1 means os is active HIGH.\n# 0 means os is active LOW.\n\n# Set OS interrupt mode\nsensor.config(os_mode=1)\n# In this mode, os goes active when the temp crosses thyst or tos, and holds until any register is read.\n# After clearing the tos crossing interrupt, it wont fire on another tos crossing until first crossing thyst,\n# where it holds active again until any register is read.\n```\n\n## Pins\n\nPin | Name | Description\n:--:|:----:|:--------------------------------\n1   | VCC  | Power supply 2.8 to 5.5V\n2   | GND  | Ground\n3   | SDA  | I2C serial data\n4   | SCL  | I2C serial clock\n5   | OS   | Over-temp shutdown output\n6   | A0   | I2C address bit 0\n7   | A1   | I2C address bit 1\n8   | A2   | I2C address bit 2\n\n# Methods\n\n## __init__(i2c=None, address=0x48)\n\nInitialise the driver. Set default configuration.\n\n## config(shutdown=None, os_mode=None, os_polarity=None, os_fault_queue=None)\n\nConfigure shutdown, os_mode, os_polarity, os_fault_queue.\n\nshutdown: 0=normal, 1=shutdown\n\nos_mode: 0=comparator, 1=interrupt\n\nos_polarity: 0=active LOW, 1=active HIGH\n\nos_fault_queue: 0=1x consecutive fault, 1=2x consecutive faults, 2=4x consecutive faults, 3=6x consecutive faults\n\n## check()\n\nScans the I2C bus for matching device and raises an error if not found.\n\n## temp()\n\nReads the temperature from the temperature register -55 to 127°C in 0.125°C increments.\n\n## tos(temp=75)\n\nSets the Tos temperature -55 to 125°C in 0.5°C increments.\n\n## thyst(temp=80)\n\nSets the Thyst temperature -55 to 125°C in 0.5°C increments.\n\n## _twos_comp(val, bits)\n\nHelper for converting 2s complement register values to temperatures.\n\n## _rev_twos_comp(val, bits)\n\nHelper for converting temperatures to 2s complement register values.\n\n## _temp_to_9bit_reg(temp)\n\nHelper for converting Tos and Thyst temperatures to how they are stored in the register.\n\n\n## I2C interface\n\nThis sensor uses an I2C interface and requires pull-ups on the SDA and SCL lines. The CJMCU-75 modules has these onboard.\n\n### I2C address\n\nThe device can be found at addresses 0x48 through 0x4F based on address select pins A0, A1, A2.\n\nA0  | A1  | A2  | Address\n:--:|:---:|:---:|:-------:\nGND | GND | GND | 0x48\nVCC | GND | GND | 0x49\nGND | VCC | GND | 0x4A\nVCC | VCC | GND | 0x4B\nGND | GND | VCC | 0x4C\nVCC | GND | VCC | 0x4D\nGND | VCC | VCC | 0x4E\nVCC | VCC | VCC | 0x4F\n\n## Parts\n\n* [CJMCU-75](https://www.aliexpress.com/item/32686562091.html) $0.92 AUD\n* [TinyPICO](https://www.tinypico.com/) $20.00 USD\n* [Lolin D1 Mini Pro](https://www.aliexpress.com/item/32724692514.html) $6.95 AUD\n\n## Connections\n\nCJMCU-75 | TinyPICO | ESP8266\n:-------:|:--------:|:-------:\nVCC      | 3V3      | 3V3\nGND      | GND      | GND\nSDA      | GPIO21   | GPIO4\nSCL      | GPIO22   | GPIO5\nOS       | GPIO5    | GPIO0\n\nOn ESP8266, GPIO0 may have a pull-up, so use another pin if you wish to invert the OS polarity.\n\nIf you do not wish to use the OS output, you can leave this pin not connected and just read the temperature register.\n\n## Links\n\n* [NXP LM75A product page](https://www.nxp.com/products/sensors/ic-digital-temperature-sensors/digital-temperature-sensor-and-thermal-watchdog:LM75A)\n* [NXP LM75A datasheet](https://www.nxp.com/docs/en/data-sheet/LM75A.pdf)\n* [micropython.org](http://micropython.org)\n* [TinyPICO Getting Started](https://www.tinypico.com/gettingstarted)\n* [WeMos D1 Mini](https://wiki.wemos.cc/products:d1:d1_mini)\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright (c) 2019 Mike Causer\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-lm75a","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicropython-lm75a","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-lm75a/lists"}