print("DS18B20 Auslesen") function read_temp(sensorPin) sensor = require("ds18b20") -- Sensor Initialisieren sensor.setup(sensorPin) -- Temperatur auslesen und ausgeben temperatur = sensor.read() t1 = temperatur/10000 t2 = temperatur % 10000 return temperatur,t1,t2 end --- read temp and send data to volkszähler function sendData() read_temp(4) read_temp(4) t3 = t1 t4 = t2 --read_temp(5) --read_temp(5) print("Temp:"..t3 .. ".".. t4 .." C\n") print("Temp:"..t1 .. ".".. t2 .." C\n") -- conection to volkszaehler print("Sending data Volkszaehler") conn=net.createConnection(net.TCP, 0) conn:on("receive", function(conn, payload) print(payload) end ) conn:connect(80,"192.168.7.76") conn:send("GET /middleware.php/data/12c56460-6f6e-11e5-a954-efa410011295.json? operation=add&value=".. t3 .. "." .. t4 .." HTTP/1.1\r\n Host: 192.168.7.76\r\n".."Connection: keep-alive\r\nAccept: */*\r\n\r\n") --conn:send("GET /middleware.php/data/2405f8e0-6f6e-11e5-86c4-317c1c0df60c.json? operation=add&value=".. t1 .. "." .. t2 .." HTTP/1.1\r\n Host: 192.168.7.76\r\n".."Connection: keep-alive\r\nAccept: */*\r\n\r\n") end -- send data every X ms to thing speak tmr.alarm(0, 20000, 1, function() sendData() end )