DS18B20
Currently unused, soon to be discontinued.
api.ds18b20GetTemp(pwrpin, datapin, id)
- Overview
- Arguments
- Returns
- Example #1
- Example #2
Returns temperature in milli degrees of Celsius (m°C) from DS18B20. In case of using multiple DS18B20 connected to one data pin, it's possible to address one DS18B20 with ID.
DS18B20 is functional after hardware changes. Also has to be allowed by the firmware.
- pwrpin (integer) - Number of pin used as power pin
- datapin (integer) - Number of pin used as data pin
- address (array)(optional) - Array of numbers used as address (has to have 8 elements aka. bytes). 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")
api.ds18b20Search(pwrpin, datapin, num)
- Overview
- Arguments
- Return
- Example
Prints into console address of all the devices.
- pwrpin (integer)
- datapin (integer)
- numdev (integer)(optional) - Stop the scan after numdev devices
- (integer) - nil or Array of addresses found on specified bus.
--Find addresses of 3 sensors
api.ds18b20Search(1, 2, 3)