A little Weather Station Example
Posted: Sun Mar 06, 2016 11:50 am
Hi all,
I published a video showing what can be done with the ESP8266 running Basic.
All the OpenWeather parsing and the control of the display is done in basic.
The display simply display the text sent by the ESP8266 via the serial port (I use the serial port 2 @ 115200).
The program parse the OpenweatherAPI for 2 towns and show the info on 2 scrolling lines.
As you can see you can do some nice things with the ESP8266 basic!
CiccioCB
For your info the program is the following :
I published a video showing what can be done with the ESP8266 running Basic.
All the OpenWeather parsing and the control of the display is done in basic.
The display simply display the text sent by the ESP8266 via the serial port (I use the serial port 2 @ 115200).
The program parse the OpenweatherAPI for 2 towns and show the info on 2 scrolling lines.
As you can see you can do some nice things with the ESP8266 basic!
CiccioCB
For your info the program is the following :
Code: Select all
memclear()
let memo = ramfree()
serial2begin 115200
delay 100
serial2println "@SPD1=0"
serial2println "@SUP=$F2$CcWEATHER "
delay 100
serial2println "@SPD2=0"
serial2println "@INF=$F3$C3DISPLAY "
delay 2000
serial2println "Good Morning Everybody!"
delay 5000
serial2println "@SPD1=10"
serial2println "@SPD2=15"
memclear()
serial2println
let memo = ramfree()
serial2begin 115200
timer 40000 [get.weather]
let altern = 1
[start]
cls
Button "Exit" [Exit.prog]
[get.weather]
altern = 1 - altern
'if altern = 1 then goto [town2]
query = "api.openweathermap.org/data/2.5/weather?q=London,uk&lang=en&units=metric&appid=YOUR_APP_ID"
'let ret = readopenweather(query,0)
let ret = wget(query)
let desc = json(ret,"weather.description")
let temp = json(ret,"main.temp")
let press = json(ret,"main.pressure")
let humid = json(ret,"main.humidity")
let tim = json(ret,"dt")
let tim = unixtime(tim)
let name = json(ret,"sys.name")
'serialprint ret
query = "api.openweathermap.org/data/2.5/forecast/daily?q=London,uk&lang=en&units=metric&cnt=1&appid=YOUR_APP_ID"
let ret = readopenweather(query,1)
let temp_min = json(ret,"temp.min")
let temp_max = json(ret,"temp.max")
let tim = json(ret,"dt")
let tim = unixtime(tim)
serialprint tim
let mess = "$F1$C3" & name
let mess = mess & " $Cf"
let mess = mess & temp
let mess = mess & "$C3dg $Cf"
let mess = mess & press
let mess = mess & "$C3mB $CcHum $Cf"
let mess = mess & humid
let mess = mess & "$C3% $CcTmin $Cf"
let mess = mess & temp_min
let mess = mess & "$C3dg $CcTmax $Cf"
let mess = mess & temp_max
let mess = mess & "$C3dg $Cf"
let mess = mess & desc
let mess = mess & " "
if instr(mess,"found") <> 0 then goto [town2]
serial2print "@SUP="
serial2println mess
serial2println name
serialprintln mess
serialprintln ramfree()
'wait
[town2]
query = "api.openweathermap.org/data/2.5/weather?q=Milan,it&lang=en&units=metric&appid=YOUR_APP_ID"
'let ret = readopenweather(query,0)
let ret = wget(query)
let desc = json(ret,"weather.description")
let temp = json(ret,"main.temp")
let press = json(ret,"main.pressure")
let humid = json(ret,"main.humidity")
let temp_min = json(ret,"main.temp_min")
let temp_max = json(ret,"main.temp_max")
let tim = json(ret,"dt")
let tim = unixtime(tim)
let name = json(ret,"sys.name")
serialprint ret
query = "api.openweathermap.org/data/2.5/forecast/daily?q=Milan,it&lang=en&units=metric&cnt=1&appid=YOUR_APP_ID"
let ret = readopenweather(query,1)
let temp_min = json(ret,"temp.min")
let temp_max = json(ret,"temp.max")
'serialprint ret
let tim = json(ret,"dt")
let tim = unixtime(tim)
serialprint tim
let mess = "$F1$C3" & name
let mess = mess & " $Cf"
let mess = mess & temp
let mess = mess & "$C3dg $Cf"
let mess = mess & press
let mess = mess & "$C3mB $CcHum $Cf"
let mess = mess & humid
let mess = mess & "$C3% $CcTmin $Cf"
let mess = mess & temp_min
let mess = mess & "$C3dg $CcTmax $Cf"
let mess = mess & temp_max
let mess = mess & "$C3dg $Cf"
let mess = mess & desc
let mess = mess & " "
if instr(mess,"found") <> 0 then goto [town3]
serial2print "@INF="
serial2println mess
serial2println name
serialprintln mess
serialprintln ramfree()
[town3]
wait
[reset.memory]
memclear()
wait
[Exit.prog]