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: https://github.com/maciejmiklas/NodeMCUUtils

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 -> yaw.weather, 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"

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

-- 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"

yaw.city = "munich"
yaw.country = "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

About This Instructable




More by Maciej Miklas:Weather Station Based on Arduino and NodeMCU NodeMCU (ESP8266) As Provider of Yahoo Weather NodeMCU as provider of NTP date and time over serial port 
Add instructable to: