Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reading temperature from ds18b20 on NodeMCU
-- Pin Mapping
gpio2 = 4
-- Prepare the Thermo Module
ds18b20 = require("ds18b20")
ds18b20.setup(gpio2)
-- The 1-Wire protocol allows many sensors to communicate over the same wire.
-- If addr is nil, a search is performed and the first device is used.
addr = nil
-- Read the temperature and convert to Fahrenheit
tF = ds18b20.readNumber(nil, ds18b20.F)
print("Temperature: "..tF.." 'F")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.