Commit 0863a4c2 authored by Sebastian Schildt's avatar Sebastian Schildt
Browse files

Fix unit constants to be consistent with code

Extend example to show querying different units or specific sensors
parent c8037568
...@@ -13,6 +13,14 @@ end ...@@ -13,6 +13,14 @@ end
-- Just read temperature -- Just read temperature
print("Temperature: "..t.read().."'C") print("Temperature: "..t.read().."'C")
-- Get temperature of first detected sensor in Fahrenheit
print("Temperature: "..t.read(nil,t.F).."'F")
-- Query the second detected sensor, get temperature in Kelvin
if (table.getn(addrs) >= 2) then
print("Second sensor: "..t.read(addrs[2],t.K).."'K")
end
-- Don't forget to release it after use -- Don't forget to release it after use
t = nil t = nil
ds18b20 = nil ds18b20 = nil
......
...@@ -33,9 +33,9 @@ setfenv(1,M) ...@@ -33,9 +33,9 @@ setfenv(1,M)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Implementation -- Implementation
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
C = 0 C = 'C'
F = 1 F = 'F'
K = 2 K = 'K'
function setup(dq) function setup(dq)
pin = dq pin = dq
if(pin == nil) then if(pin == nil) then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment