Swiftpack.co - nallick/DHT as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nallick.
nallick/DHT 2.0.0
Read temperature and humidity from DHT11 and DHT22 sensors on a Raspberry Pi in Swift.
⭐️ 1
🕓 2 weeks ago
macOS
.package(url: "https://github.com/nallick/DHT.git", from: "2.0.0")

DHT

Read temperature and humidity from DHT11 and DHT22 sensors on a Raspberry Pi in Swift.

Adapted from C sample code provided by the nice people at AdaFruit.

Example:

This reads from pin 4 every five seconds, supplying a moving average after every twelve successful reads (provided the input changes):

import DHT
import SwiftyGPIO

let allGPIOs = SwiftyGPIO.GPIOs(for: .RaspberryPi3)
let dhtGPIO = allGPIOs[.P4]!
let dht = DHT(pin: dhtGPIO, device: .dht22)

dht.start(readInterval: 5.0, updateSampleCount: 12,
          humidity: { print("humidity: \($0)%") },
          temperature: { print("temperature: \($0)°C") })

Use:

To add DHT to your project, declare a dependency in your Package.swift file,

.package(url: "https://github.com/nallick/DHT.git", from: "2.0.0"),

and add the dependency to your target:

.target(name: "MyProjectTarget", dependencies: ["DHT"]),

GitHub

link
Stars: 1
Last commit: 2 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics