Chat freely about anything...

User avatar
By twaymouth
#19872 I have uploaded my source files to the below address, however the only file that should be different to yours is ds18b20-web.lua. I would try updating this file first and if you still cannot get it working correctly delete init.lua, reboot and run file.format(). Once the ESP is formatted restart again and reload all the files in sequence.

https://drive.google.com/open?id=0B6gn-WoB7xpCfng2V3V3aDJiUENpS3huOEtuRXZVNXR3SURLUklZWmpVTHJ0TDVQZ1daWjg&authuser=0
User avatar
By Ambro
#19914 I can not get it working.
If I load the ds18b20-web.lua that you attached, there is no way to get respons on the web.

If I load the following I do have good response on the web:

require('ds18b20')
port = 80
-- ESP-01 GPIO Mapping
gpio0, gpio2 = 3, 4
ds18b20.setup(gpio0)
srv=net.createServer(net.TCP)
srv:listen(port,
function(conn)
conn:send("HTTP/1.1 200 OK\nContent-Type: text/html\nRefresh: 5\n\n" ..
"<!DOCTYPE HTML>" ..
"<html><body>" ..
"<b>ESP8266</b></br>" ..
"Temperature : " .. ds18b20.read() .. "<br>" ..
"Node ChipID : " .. node.chipid() .. "<br>" ..
"Node MAC : " .. wifi.sta.getmac() .. "<br>" ..
"Node Heap : " .. node.heap() .. "<br>" ..
"Timer Ticks : " .. tmr.now() .. "<br>" ..
"</html></body>")
conn:on("sent",function(conn) conn:close() end)
end
)

the console responds in this way:

NodeMCU 0.9.5 build 20150318 powered by Lua 5.1.4
> IP unavaiable, Waiting...
IP unavaiable, Waiting...
Connected, IP is 192.168.0.107

Ambro
User avatar
By Ambro
#19956 Where does " .. ds18b20.read() .. come from ?
I do not understand how this enviroment is organized !

the difference in the file is just those two lines:

"Temperature : " .. string.format("%02.1f",ds18b20.read()) .. "<br>" ..
and
"Temperature : " .. ds18b20.read() .. "<br>" ..

Ambro
User avatar
By twaymouth
#19982 ds18b20.read() is a function within ds18b20.lua how it works is that init.lua connects to the wireless network and then starts the web server with the line dofile("ds18b20-web.lua")

Once the web server (ds18b20-web.lua) is running it then uses the read() function within ds18b20.lua to get the current temperature value. i.e.ds18b20.read()

When you get no response do you get any error messages? are your 3 files named correctly? have you restarted the ESP module after making the changes? have you opened and closed the browser tab?

the steps to change ds18b20-web.lua should be as follows:

    Close browser tab
    Remove init.lua
    Reboot
    Upload new ds18b20-web.lua
    Reboot
    Upload init.lua
    Reboot
    Open browser and enter IP