DS18B20
info
Currently unused, soon to be discontinued.
- Overview
- Arguments
- Returns
- Examples
Returns temperature in milli degrees of Celsius (m°C) from DS18B20.
info
In case of using multiple DS18B20 connected to one data pin, it's possible to address one DS18B20 with ID.
warning
Disabled by default, FW & HW changes required.
- pwrpin (integer) - Power pin number
- datapin (integer) - Data pin number
- address (array, optional) - Array of numbers used as address (8 bytes)
info
When no array is specified, get temperature from first 1W device.
- (integer) - number in millidegrees Celsius
-- Search all devices on the 1-Wire bus
found=api.ds18b20Search(1,2)
-- `found` contains a table of addresses of found devices
-- or `nil` when no device was found
-- Print count of devices found
if (found)
then
print("Found " .. #found .. " devices")
-- Loop over all addresses
for i = 1,#found,1
do
temp=api.ds18b20GetTemp(1,2,found[i])
temp = temp/1000
print("Teplomer #" .. i .. " " .. temp .. "C")
end
else
print("No devices found!")
end
--Without addressing (one sensor=one data pin)
res1 = api.ds18b20GetTemp(1, 2) -- get temperature from sensor connected to data pin 2
print("Temperature: "..tostring(res).." mDeg.C")
- Overview
- Arguments
- Return
- Example
Searches for DS18B20 devices on the 1-Wire bus.
api.ds18b20Search(pwrpin, datapin, num)
- pwrpin (integer) - Power pin number
- datapin (integer) - Data pin number
- numdev (integer, optional) - Number of found devices to stop the scan after
- (integer) -
nil
or array of addresses found on specified bus
--Find addresses of 3 sensors
api.ds18b20Search(1, 2, 3)