I can't figure out what is wrong
*** it's waiting for a serial input from a 7 inch monitor with Micromite basic on it which sends either * or ** when it want's a weather reading from the ESP8266***
The ESP8266 waits for EITHER * or ** as the first character received on the serial port input
IF the first character is * THEN GOSUB TODAY
IF the first character is ** THEN GOSUB WEEK
LOOP
Do
serialbranch [input] ' get a record
Print "Searching For start character"
IF A$ LEFT (1) = "*" THEN
GOSUB TODAY
ELSE
IF A$ LEFT (1) = "**" THEN
GOSUB WEEK
END IF
LOOP
TODAY
let appid = "APPID"
let query = "api.openweathermap.org/data/2.5/weather?q=Haughton%20Green,uk&lang=en&units=metric&appid=" & appid
let ret = wget(query)
let icon = json(ret,"main.icon")
serialprintln "today" & "," & icon & "*"
serialflush
RETURN
WEEK
let query = "api.openweathermap.org/data/2.5/forecast/daily?&units=metric&q=HaughtonGreen,uk&appid=" & appid
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)
let speed = json(ret,"speed")
let dir = json(ret,"deg")
let pressure = json(ret,"pressure")
let humid = json(ret,"humidity")
let cloud = json(ret,"clouds")
let rain = json(ret,"description")
let icon = json(ret,"icon")
serialprintln "day1" & "," &tim & "," & temp_min "," & temp_max & "," speed & "," &dir & "," & pressure & "," & humid & "," & rain & "," & icon & "*"
let ret = readopenweather(query,2)
let temp_min = json(ret,"temp.min")
let temp_max = json(ret,"temp.max")
let tim = json(ret,"dt")
let tim = unixtime(tim)
let speed = json(ret,"speed")
let dir = json(ret,"deg")
let pressure = json(ret,"pressure")
let humid = json(ret,"humidity")
let cloud = json(ret,"clouds")
let rain = json(ret,"description")
let icon = json(ret,"icon")
serialprintln "day2" & "," &tim & "," & temp_min "," & temp_max & "," speed & "," &dir & "," & pressure & "," & humid & "," & rain & "," & icon & "*"
let ret = readopenweather(query,3)
let temp_min = json(ret,"temp.min")
let temp_max = json(ret,"temp.max")
let tim = json(ret,"dt")
let tim = unixtime(tim)
let speed = json(ret,"speed")
let dir = json(ret,"deg")
let pressure = json(ret,"pressure")
let humid = json(ret,"humidity")
let cloud = json(ret,"clouds")
let rain = json(ret,"description")
let icon = json(ret,"icon")
serialprintln "day3" & "," &tim & "," & temp_min "," & temp_max & "," speed & "," &dir & "," & pressure & "," & humid & "," & rain & "," & icon & "*"
let ret = readopenweather(query,4)
let temp_min = json(ret,"temp.min")
let temp_max = json(ret,"temp.max")
let tim = json(ret,"dt")
let tim = unixtime(tim)
let speed = json(ret,"speed")
let dir = json(ret,"deg")
let pressure = json(ret,"pressure")
let humid = json(ret,"humidity")
let cloud = json(ret,"clouds")
let rain = json(ret,"description")
let icon = json(ret,"icon")
serialprintln "day4" & "," &tim & "," & temp_min "," & temp_max & "," speed & "," &dir & "," & pressure & "," & humid & "," & rain & "," & icon & "*"
serialflush
RETURN
[input]
let a$ = serialinput
return