A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By kubi
#18944 Joy again !!! :D

I inserted a global 'owip' in init.lua and changed the structure a bit:

print("Connecting to wifi...")
wifi.setmode(wifi.STATION)
wifi.sta.config("xxx","xxx")
owip=nil

tmr.alarm(0, 1000, 1, function()
print(".")
ip = wifi.sta.getip()
if ( ( ip ~= nil ) and ( ip ~= "0.0.0.0" ) )then
print(ip)
tmr.stop(0)
sk=net.createConnection(net.TCP, 0)
sk:dns("api.openweathermap.org",function(conn,ip)
owip=ip
sk = nil
collectgarbage("collect")
dofile("weatherStation.lc")
end)
end
end )

In weatherStation.lua change the conn:connect line to:

conn:connect(80,owip)

Don't forget to compile. ;)

Since then I have no problems any more. Hope that works for you as well.
User avatar
By Mikejstb
#18964 Huzzah! (not the Adafruit one - LOL)

This works great!
I had tried to post some more of my results yesterday both here and on the Squix blog but for some reason they didn't show up.

I gave up on the accuracy issue and just put in an offset to correct my humidity number.

Excellent project - thanks to all!
User avatar
By Mikejstb
#18967 one of the many things I learned from this is that variables persist from the init.lua on to the program or sketch that init.lua calls.

I was trying to do the DNS lookup on api.openweather.org within WeatherStation .lua. and for one reason or another it wasn't working. Now I see that it can be created and assigned a value in init.lua and still accessed in ws.lc.

Good to know.
User avatar
By squix78
#18969 Hi everybody

Sorry, for the radio silence. It's great to see that the little project finds so much interest!
@Mike: I didn't get any more comments from you. Maybe it was a problem with the blogger.com platform..

You guys actually discovered several issues with my script, which I hope to fix soon on github (pull requests (AKA requests for change in my repository) are very welcome and it saves me a lot of work...
Summarizing the issues (let me know if I forgot sth):
[list=]
[*]Fixed ip for openweather.org: replace it with a DNS lookup. Could safe the trouble and do the initial connectivity test with openweather.org instead of google
[*]Update time doesn't work for 24 hours overflow: add modulo 24. 23 GMT + 3 hours then is not 27h but 2am
[/list]