Introduction: NodeMCU (ESP8266) As Provider of Yahoo Weather

I've developed small library that can be used to access Yahoo Weather over NodeMCU and than provide it over serial port. This can be connected to anything with serial port with - for example Arduino. In such case you have simple way of accessing weather for your Arduino projects :)

When connecting ESP8266 to Arduino you will need voltage divider to convert 5v from Arduino to 3.3v.

Here is the source code:

Step 1: YahooWeather.lua

yahooWeather.lua script provides access to Yahoo weather.

yaw.start() will obtain weather immediately and keep refreshing it every yaw.syncPeriodSec seconds. Weather data itself is stored in yahooWeather.lua ->, you will find there further documentation. In the example below you can see how to get wether for Munich and update it periodically:

require "yahooWeather"
require "wlan" = "munich" = "de"   
wlan.setup("free wlan", "12345678") -- update weather every 17 minutes
yaw.syncPeriodSec = 1020
yaw.responseCallback = function()
    print("Weather for today:",[1].date) 
    print("Weather for tomorrow:",[2].date) 

-- start weather update timer
Weather for today:  01 Sep 2016 18  25  Partly Cloudy   
Weather for tomorrow:   02 Sep 201616  25  Partly Cloudy

Step 2: Serial API

Script below registers Serial API Interface providing access to weather. Weather itself will get updated every 17 minutes.

require "serialAPI"
require "serialAPIYahooWeather" = "munich" = "de"
yaw.syncPeriodSec = 1020 -- 17 min

-- setup wlan required by NTP clokc
wlan.setup("fred", "1234567890")

-- start serial API by enabling gpio and uart

-- start yahoo weather with serial API

Now you can execute few simple commands over serial:

# weather description for today

YF1 text
Rain And Snow

# weather description for tomorrow
YF2 text

# not existing command
YF1 min
ERR:serialAPIYahooWeather.lua:6: attempt to concatenate field '?' (a nil value)

# max temp for tomorrow 
>YF2 low

# weather date for today
>YF1 date
09 Nov 2016