WeatherMojo

IoT project to get weather information from the web and display it on a weather station.

It periodically downloads data and sets the position of stepper motors to display weather information on analog gauges. It's built for a Particle Photon running DeviceOS 1.2.0-beta-1.

Build details at https://www.powerfulmojo.com/weather/
Source code is on GitHub at https://github.com/powerfulmojo/WeatherMojo/

Files

  • forecastmojo.ino : Firmware to run a weather station showing forecast hi temp

  • weathermojo.ino : Firmware to run a weather station showing observed hi temp

  • steppertest.ino : Firmware to mess with your stepper motors for testing and calibration

The weathermojo and forecastmojo firmwares use different weather APIs and they use the high temperature stepper motor differently. 

forecastmojo.ino uses weatherbit.io and displays today's forecast high.
weathermojo.ino uses openweathermap.org and displays the highest temperature so far today. 

Weather Forecasting Firmware

(forecastmojo.ino)

Retrieves weather conditions and forecast from weatherbit.io. Displays current temperature on the "big hand" of the temperature dial. Displays the forecast high temperature on a "needle" on the same dial. Displays the dew point on a separate small dial.

Sets current temperature dew point every 15 minutes by default. You can make updates more or less frequently by calling set_polling_interval(milliseconds)

Sets the forecast high temperature once daily at 4:00am Arizona time. Changing the time zone requires recompiling the firmware. The station doesn't do anything about daylight saving time because we don't play that game in Arizona.

Particle Variables

  • TempC The current temperature in Celsius

  • DewPointC The current dew point in Celsius

  • HiTempC The last updated high temperature in Celsius

  • LastUpdate The time of the last temperature and high temperature update

Particle Functions

  • int set_polling_interval(String Command
    Sets the polling interval to Command ms (minimum 5000). Returns 0 on success. If you give it a non-integer or a number less than 5000, it sets the polling interval to the default value of 900,000 ms.

  • int trim_temp(String Command
    Moves the temperature needle Command steps, but does not update the TempC variable. This is useful for fine calibration of the needle right after system start-up. Negative numbers go counterclockwise, positive go clockwise. Returns 0 on success.

  • int trim_hitemp(String Command
    Moves the high temperature needle Command steps, but does not update the HiTempC variable. Negative numbers go counterclockwise, positive go clockwise. Returns 0 on success.

  • int trim_dew(String Command
    Moves the dew point needle Command steps, but does not update the DewPointC variable. Negative numbers go counterclockwise, positive go clockwise. Returns 0 on success.

  • int set_temp_needle(String Command
    Sets the current temperature to Command degrees C. The needle position will be updated accordingly. Returns 0 on success. If the dial isn’t calibrated correctly don’t use this to fix it. It will just get over-written with the next weather update. You probably want to use trim_temp to change the station’s idea of where to point when showing the current temperature.

  • int set_hi_needle(String Command
    Sets the forecast high temperature to Command degrees C. The needle position will be updated accordingly. Returns 0 on success. If the dial isn’t calibrated correctly don’t use this to fix it. It will just get over-written tomorrow. You probably want to use trim_hitemp to change the station’s idea of where to point when showing the hi temperature.

  • int set_dew_needle(String Command
    Sets the dew point temperature to Command degrees C. The needle position will be updated accordingly. Returns 0 on success. If the dial isn’t calibrated correctly don’t use this to fix it. It will just get over-written with the next weather update. You probably want to use trim_dew to change the station’s idea of where to point when showing the dew point.

  • int set_city_code(String Command
    Sets the city code to use for weather conditions. A full list is at https://www.weatherbit.io/api/meta. Returns 0 on success. Setting it to an invalid value will cause the WeatherMojo to stop updating temperatures.

  • int set_api_key(String Command
    Sets the weatherbit.io API key to use for getting weather conditions. Sign up for one at https://www.weatherbit.io/account/create. Returns 0 on success. Setting it to an invalid value will cause the WeatherMojo to stop updating temperatures.

Dependencies

WeatherMojo includes these libraries:

Wiring

The firmware is written to control 3 stepper motors: temp, hi temp, and dew point. Each L293D controls one motor. Each has 4 connections to the photon & 4 connections to its motor. The other half of the pins are just power & ground.

L293D_1 controls the high temp needle:

                L293D_1
        PWR  → 1      16 ← PWR
   Photon D5 → 2      15 ← Photon A5
X40 Inner A1 → 3      14 ← X40 Inner B1
         GND → 4      13 ← GND
         GND → 5      12 ← GND
X40 Inner A2 → 6      11 ← X40 Inner B2
   Photon D4 → 7      10 ← Photon D6
         PWR → 8       9 ← PWR

L293D_2 controls the main temp needle:

                L293D_2
        PWR  → 1      16 ← PWR
   Photon D3 → 2      15 ← Photon D0
X40 Outer A1 → 3      14 ← X40 Outer B1
         GND → 4      13 ← GND
         GND → 5      12 ← GND
X40 Outer A2 → 6      11 ← X40 Outer B2
   Photon D2 → 7      10 ← Photon D1
         PWR → 8       9 ← PWR

L293D_3 controls the dew point needle:

                L293D_3
        PWR  → 1      16 ← PWR
   Photon A0 → 2      15 ← Photon A3
      X27 A1 → 3      14 ← X27 B1
         GND → 4      13 ← GND
         GND → 5      12 ← GND
      X27 A2 → 6      11 ← X27 B2
   Photon A1 → 7      10 ← Photon A2
         PWR → 8       9 ← PWR