{"id":13667179,"url":"https://github.com/micheltlutz/DHT-SwiftyGPIO","last_synced_at":"2025-04-26T15:32:17.162Z","repository":{"id":38009088,"uuid":"174843576","full_name":"micheltlutz/DHT-SwiftyGPIO","owner":"micheltlutz","description":"SwiftyGPIO with RaspberryPi + DHT11 Module","archived":false,"fork":false,"pushed_at":"2020-04-10T19:39:11.000Z","size":88,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-14T03:56:15.153Z","etag":null,"topics":["dht11","dht22","gpio","iot","raspberry-pi","swift","swiftygpio"],"latest_commit_sha":null,"homepage":"https://micheltlutz.me/post/raspberry-pi-dhtswiftygpio","language":"Swift","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/micheltlutz.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}},"created_at":"2019-03-10T15:37:09.000Z","updated_at":"2025-02-13T01:58:07.000Z","dependencies_parsed_at":"2022-09-12T13:03:57.418Z","dependency_job_id":null,"html_url":"https://github.com/micheltlutz/DHT-SwiftyGPIO","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheltlutz%2FDHT-SwiftyGPIO","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheltlutz%2FDHT-SwiftyGPIO/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheltlutz%2FDHT-SwiftyGPIO/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micheltlutz%2FDHT-SwiftyGPIO/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micheltlutz","download_url":"https://codeload.github.com/micheltlutz/DHT-SwiftyGPIO/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251008766,"owners_count":21522174,"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":["dht11","dht22","gpio","iot","raspberry-pi","swift","swiftygpio"],"created_at":"2024-08-02T07:00:33.076Z","updated_at":"2025-04-26T15:32:16.913Z","avatar_url":"https://github.com/micheltlutz.png","language":"Swift","funding_links":[],"categories":["Sensors"],"sub_categories":["Networking, IoT, Bus Protocols, …"],"readme":"# DHT-SwiftyGPIO\n\nUsing Swift to display temperature and humidity of a DHT11 module\n\n\n## Requirements\n\nRaspberry Pi 2+ or Raspberry Pi 3 Model B\n\nModel DHT11 or DHT22\n\n\u003cp align=\"center\" style=\"padding-bottom:50px;\"\u003e\n\u003cimg width=\"250\" height=\"250\" src=\"https://github.com/micheltlutz/DHT-SwiftyGPIO/raw/master/midia/DHT11.jpg\"/\u003e\n\n\u003cimg width=\"250\" height=\"250\" src=\"https://github.com/micheltlutz/DHT-SwiftyGPIO/raw/master/midia/DHT22.jpg\"/\u003e\n\u003c/p\u003e\n\n##  Installing Dependencies\n\nTo use the provided prebuilt binaries you'll need the install the following dependencies:\n\n```sudo apt install clang libicu-dev libcurl4-nss-dev```\n\n\n## Starting \n\n\u003cp align=\"center\" style=\"padding-bottom:50px;\"\u003e\n\u003cimg src=\"https://github.com/uraimo/SwiftyGPIO/raw/master/logo.png\"/\u003e\n\u003c/p\u003e\n\n[https://github.com/uraimo/SwiftyGPIO](https://github.com/uraimo/SwiftyGPIO)\n\nDownload last version swift ARM compatible with your board, see table:\n\n[Build Swift On ARM prebuilt-binaries](https://github.com/uraimo/buildSwiftOnARM#prebuilt-binaries)\n\nand Download\n\n```wget https://github.com/uraimo/buildSwiftOnARM/releases/download/4.2.3/swift-4.2.3-RPi23-RaspbianStretch.tgz```\n\nUnzip the files to a folder of your choice:\n\nFor example: /home/michel/swift-4.2.3/\n\nAfter unzip, export path:\n\n``` export PATH=/home/michel/swift-4.2.3/usr/bin:\"${PATH}\" ```\n\nTest if everything went right run command:\n\n``` swift --version ```\n\nAnd the output should be like this:\n\n```\nSwift version 4.2.3 (swift-4.2.3-RELEASE)\nTarget: armv7-unknown-linux-gnueabihf\n```\n\n# Clone and run project\n\n```$ git clone https://github.com/micheltlutz/DHT-SwiftyGPIO ```\n\n```$ cd DHT-SwiftyGPIO```\n\n```$ swift run ```\n\nWaiting output should be like this:\n\n```Temperatura: 25.0  Humidade: 41.0```\n\n\n## Reference files\n\nThe DHT.swift was based on the project [dhtxx](https://github.com/pj4533/dhtxx) But with modifications\n\nDHT class init allows you to select the sensor type and data conversion by default is used Celcius\n\n### Enums Types\n\n```swift \npublic enum SupportedSensor {\n    case dht11, dht22\n}\n\npublic enum ConversionType {\n    case Fahrenheit, Celsius\n}\n\ninit(pin: GPIO, for sensor: SupportedSensor, conversion: ConversionType = .Celsius) { }\n\n...\n\n\n```\n\n### Example create module DHT11 Object\n```swift\nlet dht = DHT(pin: gpios[.P4]!, for: .dht11)\n\n```\n\n### Issues\n\nInitial reading errors occur due to initial pulse failure\n\nUsually get a good reading within the past 60s, many times more often than that\n\n\nI hope this project helps start with the creation of IoT projects with Swift\n\n\n[My Blog Post](https://micheltlutz.me/post/raspberry-pi-dhtswiftygpio)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheltlutz%2FDHT-SwiftyGPIO","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicheltlutz%2FDHT-SwiftyGPIO","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicheltlutz%2FDHT-SwiftyGPIO/lists"}