{"id":19184525,"url":"https://github.com/temirlan504/tmp36-tutorial","last_synced_at":"2026-05-14T21:01:47.390Z","repository":{"id":251139996,"uuid":"836034807","full_name":"Temirlan504/TMP36-tutorial","owner":"Temirlan504","description":"TMP36 Tutorial from Scratch without Libraries","archived":false,"fork":false,"pushed_at":"2024-08-02T03:48:38.000Z","size":287,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-29T01:25:49.461Z","etag":null,"topics":["analog-sensor","micropython","temperature-sensor","tmp36"],"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/Temirlan504.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-07-31T03:13:16.000Z","updated_at":"2024-08-04T03:46:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"83b63a1f-323e-4b92-9900-22db8a7eb4a0","html_url":"https://github.com/Temirlan504/TMP36-tutorial","commit_stats":null,"previous_names":["temirlan504/tmp36-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Temirlan504/TMP36-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Temirlan504%2FTMP36-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Temirlan504%2FTMP36-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Temirlan504%2FTMP36-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Temirlan504%2FTMP36-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Temirlan504","download_url":"https://codeload.github.com/Temirlan504/TMP36-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Temirlan504%2FTMP36-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33043249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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":["analog-sensor","micropython","temperature-sensor","tmp36"],"created_at":"2024-11-09T11:07:26.379Z","updated_at":"2026-05-14T21:01:47.373Z","avatar_url":"https://github.com/Temirlan504.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TMP36 Tutorial using MicroPython\n### Описание проекта на русском, смотри ниже ↓\n---\n\nThis tutorial will show you how to use the [TMP36](https://www.analog.com/media/en/technical-documentation/data-sheets/tmp35_36_37.pdf) analog temperature sensor with MicroPython and Tiny2040 (Raspberry Pi Pico). The TMP36 provides a voltage output ***linearly proportional*** to the Celsius temperature, allowing us to use the equation of a line *y = mx + b* for temperature calculations.\n\n### Hardware Required\n1. Raspberry Pi Pico or Tiny2040\n2. TMP36 Temperature Sensor\n3. Breadboard\n4. Jumper Wires\n\n### Circuit Diagram\n\n![TMP36 Circuit Diagram](tmp36_circuit_diagram.png)\n\nUsing the TMP36 datasheet, we see the sensor pins as follows:\n\n![TMP36 Pinout](tmp36_pinout.png)\n\nWith the legs facing you, the left pin is the voltage pin, the middle pin is the output voltage, and the right pin is the ground pin.\n\nConnect the output voltage pin to the ADC pin (GP26) of the Tiny2040. Connect the voltage pin to the 3.3V (as the datasheet specifies testing under 3V of power), and the ground pin to the GND pin of the Raspberry Pi Pico.\n\n### Deriving the Formula for Temperature Calculation\nThe TMP36 sensor provides an output voltage linearly proportional to the Celsius temperature. Using the equation of a line \"y = mx + b\", we can calculate the temperature:\n- y = Temperature in Celsius\n- m = Slope of the line = (y2 - y1) / (x2 - x1)\n- x = Output voltage of the sensor\n- b = Y-intercept (calculated later)\n\nThe TMP36 datasheet provides the following graph:\n\n![TMP36 Graph](tmp36_graph.png)\n\nFrom the graph, we can take any two points (x1, y1) and (x2, y2) to calculate the slope. For this example, we use the points (1V, 50°C) and (0.4V, -12.5°C).\n\nUsing the slope formula, we get:\n\n$\\ m = \\frac{50 - (-12.5)}{1 - 0.4} = \\frac{62.5}{0.6} = 104.1667 \\$\n\nNext, we calculate the y-intercept (b) by substituting the values of m, x, and y in the line equation. Using the point (1V, 50°C):\n\n$\\ 50 = 104.1667 \\cdot 1 + b \\$\n\n$\\ b = 50 - 104.1667 \\$\n\n$\\ b = -54.1667 \\$\n\nSo, the temperature calculation formula is:\n$\\ y = mx + b \\$\n\n$\\ \\text{Temperature} = 104.1667 \\cdot \\text{Output Voltage} + (-54.1667) \\$\n\nNow that the hardest part is done, we can use this formula in the code to get the temperature in Celsius.\n\n### Code\n[main.py](main.py)\n\n---\n\nВ этом руководстве показано, как пользоваться аналоговым датчиком температуры [TMP36](https://www.analog.com/media/en/technical-documentation/data-sheets/tmp35_36_37.pdf) с MicroPython и Tiny2040 (Raspberry Pi Pico). TMP36 выдаёт выходное напряжение ***линейно пропорциональное*** температуре по цельсию, что позволяет нам использовать уравнение линии *y = kx + b* для расчетов температуры.\n\n### Требуемое оборудование\n1. Raspberry Pi Pico или Tiny2040.\n2. Датчик температуры TMP36.\n3. Макетная плата\n4. Провода\n\n### Принципиальная электрическая схема\n\n![Схема TMP36](tmp36_circuit_diagram.png)\n\nВ даташите TMP36, мы видим распиновку датчика следующим образом:\n\n![Распиновка TMP36](tmp36_pinout.png)\n\nНоги датчика смотрят на нас, тогда левый контакт — это контакт питания, средний контакт — выходное напряжение, а правый контакт — контакт заземления.\n\nПодключите вывод выходного напряжения к выводу ADC0 (GP26). Подключите контакт напряжения к 3,3 В (потому-что в даташите указано тестирование при напряжении 3В), а контакт заземления — к контакту GND Raspberry Pi Pico.\n\n### Вывод формулы для расчета температуры\nДатчик TMP36 обеспечивает выходное напряжение, линейно пропорциональное температуре Цельсия. Используя уравнение линии «y = kx + b», мы можем рассчитать температуру:\n- y = температура в градусах Цельсия\n- k = Наклон линии = (y2 - y1) / (x2 - x1)\n- x = Выходное напряжение датчика\n- b = точка пересечения Y (посчитаем позже)\n\nВ дашите TMP36 представлен следующий график:\n\n![График TMP36](tmp36_graph.png)\n\nИз графика мы можем взять любые две точки (x1, y1) и (x2, y2) для расчета наклона. В этом примере мы используем точки (1В, 50°C) и (0,4В, -12,5°C).\n\nИспользуя формулу наклона, получаем:\n$\\ k = \\frac{50 - (-12,5)}{1 - 0,4} = \\frac{62,5}{0,6} = 104,1667 \\$\n\nЗатем мы вычисляем точку пересечения оси y (b), подставляя значения k, x и y в уравнение линии. Используя точку (1В, 50°C):\n\n$\\ 50 = 104,1667 \\cdot 1 + b \\$\n\n$\\ b = 50 - 104,1667 \\$\n\n$\\ b = -54,1667 \\$\n\nИтак, формула расчета температуры такова:\n\n\\$ у = kx + b \\$\n\n$\\ \\text{Температура} = 104,1667 \\cdot \\text{Выходное напряжение} + (-54,1667) \\$\n\nТеперь, когда самое сложное сделано, мы можем использовать эту формулу в коде, чтобы получить температуру в градусах Цельсия.\n\n### Код\n[main.py](main.py)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemirlan504%2Ftmp36-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftemirlan504%2Ftmp36-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftemirlan504%2Ftmp36-tutorial/lists"}