Home Weather v3

Home Weather v3

The ‘Dashboard’ has received rework to improve existing and display additional information. Yes there are several home weather dashboards out there but by the time you install, register and integrate into existing systems it was more fun to build own. The interface may be blocky but I understand what is going on behind the scenes. This gives me a view as to what I’m recording, what is being recorded around me what is being forecast.

As it stands the dashboard supports;

  • Recorded external conditions from Arduino device via LoRa to Pi gateway
    • Pi Zero with BME680 conditions and AS3935 lightning
  • Recorded internal conditions via Arduino and Pi devices using LoRa to Pi gateway
    • Arduino with BME280
    • Pi Zero with MS340 conditions and AS3935 lightning
  • P4 based gateway using LAMP stack for storage and processing
  • BOM via FTP for Radar and warnings
  • Incidents by Vic Emergency RSS feed.
  • Forecasts and Incidents via WillyWeather API
  • Fronius Inverter status via API with JSON
  • NBN throughput via speedtest cli


V3 included a voltage divider to monitor the input voltage, support for SPI RTC, Lightning detector, LoRa and SD card reader. I2C support for display and BM680. Analogue inputs for the wind, rain detectors. Multiple SPI devices provided challenges during dev however the addition of pull-up resistors on the SPI bus and CS lines fixed that. Currently the SD card has been disable in this code as the string class was consuming 32bytes each use and crashing the device. The discrete components are 805 SMD form factor on new PCBs.

Weather station v3
define SERIAL_BAUD 115200
 const bool TRUE = 1;
 const bool FALSE = 0;
 const int deviceID = 8;
 const char* ssid = "Harvie-Home";
 const char* password =  "password";
 const char* ntpServer = "";
 const char* cBanner = "Weather V4.0";
 const char* outputFile = "/WX-v4.json";
 define pinLED  5
 // I2C 
 // I2C device found at address 0x3C  SSD1306
 // I2C device found at address 0x57  AT24C32 - eeprom
 // I2C device found at address 0x68  DS3231
 // I2C device found at address 0x76  BME280 
 define SDA         21
 define SCL         22
 // SSD1306 display connected to default I2C (SDA, SCL) pins.
 define oledRST      -1   // or use U8X8_PIN_NONE
 define SCREEN_WIDTH 128  // OLED display width, in pixels
 define SCREEN_HEIGHT 64  // OLED display height, in pixels
 // VSPI SPI Defaults
 // lora 1278x & AS3935 
 define SCK         18  // VSPI_CLK/SCK = GPIO18
 define MISO        19  // VSPI_MISO = GPIO19
 define MOSI        23  // VSPI_MOSI = GPIO23
 // #define CS          5   // VSPI_CS/SS = GPIO5
 // LORA 
 define loraBAND    433E6
 define loraCS      4         // NSS
 define loraRST     -1        // connect the reset pin of the MCU 38
 define pinLORA     2
 // AS3935
 define INDOOR 0x12
 define OUTDOOR 0xE
 define LIGHTNING_INT 0x08
 define DISTURBER_INT 0x04
 define NOISE_INT 0x01
 define AS3935CS 33
 define pinLIGHTNING 15
 define pinRTC 16
 define SDCardCS 32
 define pinVOLTAGE 36
 define SEALEVELPRESSURE_HPA (1013.25)
 define pinVoltge 36
 // Sensor variables
 RTC_DATA_ATTR volatile unsigned long lastDataSent = 0; // Time since last data send
 RTC_DATA_ATTR volatile int numRevsAnemometer = 0;     // Incremented in the interrupt
 RTC_DATA_ATTR volatile int numDropsRainGauge = 0;     // Incremented in the interrupt
 RTC_DATA_ATTR volatile int bootCount = 0;             // Incremented on sleep wakeup
 RTC_DATA_ATTR volatile int timerCount = 0;            // Incremented on timer wakeup
 RTC_DATA_ATTR volatile int intCount = 0;              // Incremented on INT wakeup
 RTC_DATA_ATTR volatile int numLightning = 0;          // I
 Anemometer (Digital pin 2 - pin 2 of RJ11, pin 3 to ground),
 wind vane (Analog pin 3 -> pin 1 of RJ45, pin 4 to ground) 
 rain gauge (Digital pin 3)
 There are issues with using pins 32-39 to trigger wake up from deep sleep. 
 It will wake but you can’t determine which int its was (returns inf) whilst you can determine who called for the lower pins. 
 DIGITAL Anemometer - pinANEMOMETER  27  // 34         
 DIGITAL rain gauge - pinRAINGAUGE   26  // 35
 ANALOGUE wind vane - pinWINDVANE    25  // 15  Dos not raise INAT so goes highrr
 define pinANEMOMETER  26
 define pinRAINGAUGE   27
 define pinWINDVANE    35
 Only RTC IO can be used as a source for external wake
 source. They are pins: 0,2,4,12-15,25-27,32-39.
 LIGHTNING  15  32768  
 RTC        16  65536
 ANEMOMETER  26  67108864
 RAINGAUGE 27  134217728
 = 201424896
 2^15 + 2^16 + 2^26 + 2^27 in hex
 #define BUTTON_PIN_BITMASK 0xC018000
 define BUTTON_PIN_BITMASK 0xC018000
 Other pins. will have a header on board
 pinTBA     35  Forth input on the weather sensors
 pinRELAY01 34  Used to trigger relay ?
 pinRELAY02 33  Used to trigget another relay ?
 These wont be used to raise INTS
 *#define pin037  37
 *#define pin035  35
 *#define pinTBA  36 

The header file is above. Hopefully you will see the pin assignments align with the schematic. Its getting busy and the device is keeping up and I’m very happy with the end result.

Have two lightning sensors now deployed. Internally a DFRobot and externally a SparkFun unit. Both based on the AS3935 chip. The AS3935 Franklin chip is capable of detecting lightning up to 40km away with an accuracy of 1km to the storm front. The device is designed to pick up lightning events in the 500kHz band. Both will detect lighting events but not at the same time.

A RTC clock has been added to the external station to keep time. The time is currently set via NTP over wireless. Will be moving the station to the antenna tower. This is behind the house with the wireless behind colour bond walls. LoRa will be used so send readings however expecting wireless connectivity to be unavailable.

SD card unit has been added to support data logging. Current code is not deployed as using strings and they are fragmenting the heap. Both devices now read and send back the heap so I can monitor. Current code is solid as heap does not change.

The Hall sensor is recorded and sent back. Not sure what to make of these readings. They are indicating changes in the presence and magnitude of a magnetic field using the Hall effect. Currently the data looks random.

The voltage divider is using two 10k resistors from VUSB. Need to take an average to come up with a usable number.

voltage = ((float)sum / (float)NUM_SAMPLES * 5.015) / 1024.0;

Still seeing occasionally hangs for the external device . The BME680 sensor stops sending data. Suspect the unit currently deployed is marginal as a no name unit. Have a replacement unit here. This replacement unit is a SparkFun unit so expecting better quality but will need to update the code to use the SparkFun library before replacing.

Currently the external station is still on the edge of the deck. This spot is too protected to take usable wind speed readings. Not an accident as the house was positioned below the ‘ridge’ and we planted and grew a wind break (Koala trees) .

Happy to share code or KiCAD files on request. No promise they are of any value. There is also two spare boards available. Send me an email if you intent to use.

V4 updates will include;

  • Multiple sources (APRS via RF for redundancy when iNet down) for alerts
  • Automated control of battery charging when storms approaching (webiopi)
  • Additional air quality and CO2 level reporting
  • Update BME680 code with SparkFun libraries
  • Calculations to make sense of the voltage readings

So yes could have purchased a commercial unit by now but where would the fun be in that ?