{"id":14966013,"url":"https://github.com/jonathanstowe/rpi-device-ds18b20","last_synced_at":"2026-01-22T12:03:00.755Z","repository":{"id":66980495,"uuid":"450825132","full_name":"jonathanstowe/RPi-Device-DS18B20","owner":"jonathanstowe","description":"Interface to the DS18B20 digital thermometer from Maxim Integrated","archived":false,"fork":false,"pushed_at":"2022-08-07T14:27:59.000Z","size":304,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-15T09:35:22.244Z","etag":null,"topics":["ds18b20","one-wire","raku","raspberry-pi","thermometer"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2022-01-22T13:27:56.000Z","updated_at":"2022-11-18T12:17:03.000Z","dependencies_parsed_at":"2023-05-16T10:00:40.479Z","dependency_job_id":null,"html_url":"https://github.com/jonathanstowe/RPi-Device-DS18B20","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"20c21a8c3a78f13b4a42c94ca1f7e2489e1ca630"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DS18B20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DS18B20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DS18B20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DS18B20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/RPi-Device-DS18B20/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248060410,"owners_count":21041156,"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":["ds18b20","one-wire","raku","raspberry-pi","thermometer"],"created_at":"2024-09-24T13:35:41.760Z","updated_at":"2026-01-22T12:03:00.708Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RPi::Device::DS18B20\n\nInterface to the DS18B20 digital thermometer from Maxim Integrated\n\n[![CI](https://github.com/jonathanstowe/RPi-Device-DS18B20/actions/workflows/main.yml/badge.svg)](https://github.com/jonathanstowe/RPi-Device-DS18B20/actions/workflows/main.yml)\n\n## Synopsis\n\n\n\n```raku\nuse RPi::Device::DS18B20;\n\nmy $t = RPi::Device::DS18B20.new;\n\nfor $t.thermometers -\u003e $thermometer {\n    say $thermometer.name, \":\\t\", $thermometer.temperature;\n}\n```\n\nOr asynchronously:\n\n```raku\nuse RPi::Device::DS18B20;\n\nmy $t = RPi::Device::DS18B20.new;\n\nreact {\n    whenever $t -\u003e $reading {\n        say $reading.when, \"\\t\", $reading.name, \"\\t\", $reading.temperature;\n    }\n}\n```\n\nThe source is in the [examples](examples) directory of the distribution.\n\n## Description\n\nThe [DS18B20](https://www.maximintegrated.com/en/products/sensors/DS18B20.html) is a handy and inexpensive digital thermometer that uses the [Dallas 1-Wire bus](https://en.wikipedia.org/wiki/1-Wire).\n\nThe Linux kernel has support for 1-Wire which can be enabled with `raspi-config` (via `Interface Options -\u003e 1-Wire`,) which by default enables the 1-Wire interface on GPIO 4 as per:\n\n![Raspberry Pi GPIO pins](https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png)\n\nThe minimum viable circuit will be something like:\n\n[![Minimal Circuit](examples/hardware/ds18b20.png)](examples/hardware/ds18b20.png)\n\nThe 4.7K resistor is required as a pull up on the data wire, only one appears to be needed for multiple sensors on the same bus.\n\nIt can be configured on another pin (or pins,) as described [here](https://blog.oddbit.com/post/2018-03-27-multiple-1-wire-buses-on-the/)\n\nEach thermometer has a unique identifer (in common with all 1-Wire sensors,) which means that multiple thermometers can be used on the same bus at once, however there is no way of distinguishing the devices without querying them, so a programme may need to provide its own mapping of identifier to thermometer (location etc,) this can be achieved by either wiring them in one by one, running something like the synopsis code and noting the identifier (and presumably labelling the sensor,) or by applying some heat source to each one in turn (if you have one of the encapsulated \"waterproof\" sensors a cup of hot water is ideal, but holding the sensor in your hand should work if the ambient temperature is lower than body temparature,) and similarly noting the identifier.\n\nThe module provides for the enumeration of the thermometers detected on the 1-Wire bus providing a list of `Thermometer` objects, having a name attribute and a `temperature` method that returns the degrees Celcius with a precision of a thousandth of a degree (though the device is commonly stated as having ±0.5⁰ accuracy so this precision may or may not be useful to you.)  The default \"conversion time\" for the device is 750 milliseconds so requesting the temperature more frequently than that is likely to be fruitless.\n\nAlternatively  the `RPi::Device::DS18B20` object provides a `Supply` \"coercion\" method which allows it be used anywhere a `Supply` can be used (such as a `whenever` in a `react` block,) this will emit a `Reading` object with a `name` attribute of the sensor id, a `temperature` attribute with the measured temperature and a `when` attribute, for every sensor detected at minimum frequency determined by the `supply-interval` attribute as supplied to the constructor (the default is 30 seconds.) The readings may not be emitted in a predictable order at each interval as each sensor may take a different length of time to produce a reading, plus the bus protocol will, by necessity, serialise the readings. \n\n\n## Install\n\nAssuming you have a working copy of Rakudo you can install with *zef* :\n\n```\nzef install RPi::Device::DS18B20\n```\nIt is unlikely to work on anything else than a Raspberry Pi.\n\n##  Support\n\nThis is difficult to test in a completely automated fashion without the actual device attached and knowing what the temparature should be so there may be bugs which I haven't noticed.\n\nPlease send any patches/suggestions/issues via [Github](https://github.com/jonathanstowe/RPi-Device-DS18B20/issues). \n\nIdeally any reports should include the Raspberry Pi and OS versions and some indication of how the device was wired up.\n\nThis may work with other 1-Wire thermometer sensors [supported by the Linux kernel](https://www.kernel.org/doc/html/latest/w1/slaves/w1_therm.html) by adjusting the `device-class` passed to the constructor, but as I don't have any to test with right now I can't make any guarantees, it also appears that DS18B20 is by far and away the most commonly used.\n\n## Copyright \u0026 Licence\n\nThis is free software, please see the [LICENCE](LICENCE) in the distribution.\n\n© Jonathan Stowe 2022\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Frpi-device-ds18b20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Frpi-device-ds18b20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Frpi-device-ds18b20/lists"}