Skip to content

NOAA Current and Forecast json-ld xml data pull for Atmel (Arduino and Adafruit) and STMicroelectronics (Particle) MCUs

License

Notifications You must be signed in to change notification settings

bethanysciences/Arduino_NOAA_JSON_Weather_Grabber-display

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Console Project

Runs out over WiFi or GSM to NOAA to grab forecast and current conditions weather reports. Displays Hi/Low/Current temperatures on 7-segment LED displays. Syncs to NTP servers and displays local time zone adjusted time in 12 or 24 hour format.

Designed to use (see tested integrations below)

For WiFi connections

  1. ATMEL SoC (System on Chip) ATSAMW25 ARM 32bit ultra low power WiFi equipped MCU's composed of three main blocks:
  1. Integrated STMicroelectronics STM32F205 120Mhz 32bit ARM Cortex M3 microcontroller and Cypress BCM43362 Single-Chip IEEE 802.11TM b/g/n MAC/Baseband/Radio
  • in production examples
    Particle Photon

For LTE/GSM connections

  1. Integrated Atmel SAMD21 Cortex-M0+ 32bit low power (<20ma) ARM MCU and u-blox SARA-U2 series HSPA / GSM Module
  1. Combined STM32F205 120Mhz 32bit ARM Cortex M3 microcontroller U-Blox SARA U260/U270 for 3G GSM
  • in production examples
    Particle Electron

Written in C++ for the Arduino, Particle and Atmel Studio 7 ecosystems
https://www.arduino.cc

https://www.particle.io

http://www.atmel.com/microsite/atmel-studio/

These projects are open source under the following Licenses

Resources

NOAA CURRENT Using aviation METAR pull

NOAA FORECAST using v3 JASON-LD pull

https://api.weather.gov/points/33.8774,-84.3046/forecast
User-Agent: [email protected]/arduinowx01
Accept: application/ld+json

Weather Underground

http://api.wunderground.com/api/<KEY>/conditions/ forecast/q/PDK.json

<KEY> required key see documentation to obtain and view pull limits

Components used and tested integrations

File and Library Structure

  • console.cpp (or console.ino for Arduino IDE) code base for most functions.

  • /icons referenced weather icons as 58x58 bmp files

Public libraries

  • WiFi101.h for integrated ATMEL ATSAMW25 wifi functions
  • RTCZero.h for ATMEL SAMD21 time functions
  • ArduinoHttpClient.h ATMEL ARM library used for HTTP (GET, POST, PUT, DELETE) web server requests and WebSocket servers message exchange.
    • Returns parsed status code and Content-Length header (if present).
    • Expects Client type object useable with any networking class
    • Derived from Adrian McEwen's HttpClient library
  • ArduinoJson.h Benoît Blanchon's library supports JSON serialization and deserialization.
    • parse directly from an input Stream or std::istream
    • serial port JsonObject& root = jsonBuffer.parse(Serial)
    • Ethernet connection JsonObject& root = jsonBuffer.parse(ethernetClient)
    • Wifi connection JsonObject& root = jsonBuffer.parse(wifiClient)
  • SimpleTimer.h for timer interrupts to make scheduled function calls - for weather gets
  • Adafruit_HX8357.h for the spi HX8357 TFT screen low level functions
  • Adafruit_LEDBackpack.h for the HX285 low level i2c 7-segment led functions
  • Adafruit_GFX.h for universal display driver functions
    • Fonts/FreeSans9pt7b.h font included with Adafruit-GFX-Library
    • Fonts/FreeSans12pt7b.h font included with Adafruit-GFX-Library

Contributed libraries

  • lib/convertTime.h timezone and 12/24 hr conversion
    convertTime(24hour, TIME24, &hour, &AorP)
    • 24hour as INT input hour in 24 hour format
    • TIME24 as BOOL output type (y=24 hour, n= 12 hour)
    • returns hour as INT output hour converted to 12 or 24 hour
    • returns AorP as AM or PM (if 12 hour selected) 0 = AM, 1 = PM
  • lib/dtostrf.h Convert float to string as avr-libc sprintf does not format floats
    char *dtostrf (val, width, prec, char *sout)
    • val double / float variable
    • width string length returned INCLUDING decimal point + sign
    • prec number of digits after the deimal point to print
    • sout destination of output buffer (must be large enough)
  • lib/WiFiCreds.h for credentials designating WiFi network SSID and password parameters, alter for your particulars
/*-----------------------------------------------------*  
   PRIVATE WIFI Credentials  
   for ATMEL series 32bit SAMD21 CPUs  
   © 2017 Bob Smith https://github.com/bethanysciences  
   MIT license  
*------------------------------------------------------*/  
   char ssid[] = "iotworld";  // your network SSID (name)  
   char pass[] = "iotworld";  // your network password  
  • lib/wxConversions.h library of useful weather conversion functions
    • Celc > Fahr double c2f(double [temp °celcius]) returns temperature in °fahrenheit as double
    • Fahr > Celc double f2c(double [temp °fahrenheit returns temperature in °celcius
    • Humidity double rh(double [dew point °celc], double [temp °celc]) returns % relative humidity as double
    • Windchill float wc(double [temp °celcius], int [MPH windspeed]) returns windchill in °celcius as float
    • Convert Barometric Pressure as Pascals (PA) to Inches Mercury("HG)
      double p2h(double pa)
    • Dew Point in °Celsius or °Fahrenheit
      double dp(double temp, int rh)
      • temp = °Celsius or °Fahrenheit]
      • rh = % relative humidity
    • Calc Heat Index temperature °Celsius or °Fahrenheit
      double hi(double temp, int rh, bool c)
      • temp = °Celsius or °Fahrenheit
      • rh = % relative humidity
      • c = °Celsius yes/no
      • returns heat index temperature °Celsius or °Fahrenheit as double
    • Calc minutes to Min Erythemal Dose (MED) or sunburn
      double med(int uvi, int alt, bool water, bool snow, int fitz, int spf)
      • uvi = UV Index
      • alt = altitude in meters
      • water = on water y/n
      • snow = on snow y/n
      • fitz = Fitzpatrick skin type (0-32)
      • spf = Sun Protection Factor value of applied sunblock
      • returns minutes to Min Erythemal Dose (MED) sunburn as integer
  • lib/xmlTakeParam.h Parse and extract elements from XML
    string xmlTakeParam(String inStr, String needParam)
    • inStr input string e.g. <temp_c>30.6</temp_c>
    • needParam parameter sought e.g. temp_c
    • returns value in string e.g. 30.6