To get every day from home to my work place I usually chose the bike. This Epaper-based project, mounted near the front-door, tells me in one glimpse the probability of starting rain within the next 60 minutes. It thus enables me in time to think about potential alternative transportation means.
It is based on a webhook towards the weather API of darksky.net (forecast.io) for a specific location and forecast duration. The usage of an Epaper display allows putting the MCU into deep sleep for most of the time to reduce power consumption.
Step 1 - Your Secret KeyTo get access to the Dark Sky API please sign-up to get your personal key at darksyk.net (its free for less than 1.000 API calls a day). You must supply this secret key in all future API requests.
Step 2 - Generate & test an API callNow we generate a HTTP GET request, based on the following syntax:
https://api.darksky.net/forecast/YOUR-API-KEY/LATITUDE,LONGITUDE?lang=de&exclude=currently,minutely,daily,flags,alerts&units=si
- YOUR-API-KEY - should be replaced by your secret key
- LATITUDE - Should be replaced by your location of interest
- LONGITUDE -Should be replaced by your location of interest
These coordinates are available e.g. at maps.google.com. You can learn more about the syntax at the docs.
Now it's time to test your generated HTTP request by copying this line in the browser URL field. As a result you should see something like this:
{"latitude":42.3601,"longitude":-71.0589,"timezone":"America/New_York","offset":-4,"currently":{"time":1503749950,"summary":"Clear","icon":"clear-day","nearestStormDistance":406,"nearestStormBearing":216,"precipIntensity":0,"precipProbability":0,"temperature":61.07,"apparentTemperature":61.07,"dewPoint":48.54,"humidity":0.63,"windSpeed":4.06,"windGust":7.51,"windBearing":313,"visibility":10,"cloudCover":0,"pressure":1024.15,"ozone":326.86,"uvIndex":1},"minutely":{"summary":"Clear for the hour.","icon":"clear-day","data": (...)
Step 3 - Create a Particle WebhookAt Particle's Console in the Web IDE, following the section "Integration" and "New Integration" we can generate a new Webhook via Browser IDE by selecting "Webhook". Pleae fillout the fields as follows:
- Event Name - WeatherForecast
- Full URL - The above generated & tested HTTP request string
- Request Type - GET
- Device - Please select the name of your device
- Response Template - Please fill in the following line
{{#hourly}}{{icon}}{{#data}}{{#time}}~{{temperature}}~{{precipProbability}}{{/time}}{{/data}}{{/hourly}}
This last line parses through the response and picks out only two values: Temperature and the Probability of rain within the next 60 mins.
Step 4 - Run the SketchOpen the attached INO sketch. Then add the two libraries Adafruit GFX
and PL_microEPD
via the Library Manager and verify that the name of the webhook is inserted correctly. Compile & run the sketch!
Comments