This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wifi.setmode(wifi.STATION) | |
wifi.sta.config("2337","clearfield") | |
wifi.sta.connect() | |
wifi.sta.autoconnect(1) -- connect on boot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create an MQTT client with a 2m keep-alive interval. | |
client = mqtt.Client(wifi.sta.getmac(), 120) | |
-- Connect to the broker | |
client:connect( | |
"amesbielenberg.com", -- broker hostname | |
1883, -- default MQTT port | |
0, -- no security | |
function(client) -- on-connect callback | |
print ("connected.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Publish a message to the MQTT Broker | |
client:publish( | |
"temp/0", -- topic name | |
tF, -- message payload | |
1, -- QOS level | |
1, -- retain | |
function(conn) -- on-send callback | |
print("sent.") | |
end | |
) |