ESP8266: Unterschied zwischen den Versionen
Alex (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Alex (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 4: | Zeile 4: | ||
Datei:AlexN900 02 20141118 003.jpg | Datei:AlexN900 02 20141118 003.jpg | ||
</gallery> | </gallery> | ||
<gallery widths=300px heights=200px perrow=3 > | |||
Datei:Alex lotta 20150119.IMG 0294.jpeg | |||
</gallery> | |||
<highlightSyntax language="lua"> | |||
require('ds18b20') | |||
port = 80 | |||
gpio0, gpio2 = 3, 4 | |||
ds18b20.setup(gpio2) | |||
t="" | |||
gpio.mode(gpio0,gpio.OUTPUT) | |||
for i=1,10 do | |||
gpio.write(gpio0,gpio.LOW); | |||
tmr.delay(100000) | |||
gpio.write(gpio0,gpio.HIGH); | |||
tmr.delay(100000) | |||
end | |||
ip = wifi.sta.getip() | |||
print (ip) | |||
if ( ip == nil ) then | |||
while 1 do | |||
gpio.write(gpio0,gpio.LOW); | |||
tmr.delay(50000) | |||
gpio.write(gpio0,gpio.HIGH); | |||
tmr.delay(50000) | |||
end | |||
node.restart() | |||
end | |||
srv=net.createServer(net.TCP) | |||
srv:listen(port, function(conn) | |||
conn:on("receive",function(conn,request) | |||
local buf = ""; | |||
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); | |||
if(method == nil)then | |||
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); | |||
end | |||
local _GET = {} | |||
if (vars ~= nil)then | |||
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do | |||
_GET[k] = v | |||
end | |||
end | |||
if (_GET.pin == "on")then | |||
gpio.write(gpio0,gpio.LOW); | |||
elseif(_GET.pin == "off")then | |||
gpio.write(gpio0,gpio.HIGH); | |||
end | |||
print(node.heap()) | |||
t = ds18b20.read() | |||
conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\n\n" .. | |||
"<!DOCTYPE HTML>" .. | |||
"<html><body>" .. | |||
"Temperature : " .. t .. "<br>" .. | |||
"</html></body>") | |||
end) | |||
conn:on("sent",function(conn) conn:close() end) | |||
collectgarbage("collect") | |||
end) | |||
</highlightSyntax> | |||
Aktuelle Version vom 18. Januar 2015, 23:40 Uhr
ESP8266 is a complete and self-contained Wi-Fi network chip.
<highlightSyntax language="lua">
require('ds18b20')
port = 80
gpio0, gpio2 = 3, 4 ds18b20.setup(gpio2)
t=""
gpio.mode(gpio0,gpio.OUTPUT)
for i=1,10 do
gpio.write(gpio0,gpio.LOW);
tmr.delay(100000)
gpio.write(gpio0,gpio.HIGH);
tmr.delay(100000)
end
ip = wifi.sta.getip() print (ip)
if ( ip == nil ) then
while 1 do gpio.write(gpio0,gpio.LOW); tmr.delay(50000) gpio.write(gpio0,gpio.HIGH); tmr.delay(50000) end node.restart()
end
srv=net.createServer(net.TCP) srv:listen(port, function(conn) conn:on("receive",function(conn,request) local buf = ""; local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); if(method == nil)then _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); end local _GET = {} if (vars ~= nil)then for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do _GET[k] = v end end if (_GET.pin == "on")then gpio.write(gpio0,gpio.LOW); elseif(_GET.pin == "off")then gpio.write(gpio0,gpio.HIGH); end print(node.heap()) t = ds18b20.read()
conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\n\n" .. "<!DOCTYPE HTML>" .. "<html><body>" .. "Temperature : " .. t .. "
" .. "</html></body>") end)
conn:on("sent",function(conn) conn:close() end) collectgarbage("collect") end)
</highlightSyntax>
- Software Development Kit (SDK)
- ESP8266_lubuntu_20141021.ova Mein mirror vom 20141021