shred / kaminari

AS3935 and ESP8266 based Franklin Lightning Detector
GNU General Public License v3.0
42 stars 10 forks source link
3d-printing arduino as3935 esp8266 lightning weather

Kaminari

This is an ESP8266 and AS3935 based Franklin Lightning Detector. It connects to a WiFi network, and offers a JSON web service for detected lightnings.

WARNING: This project is for educational purposes only. This is just a toy. It is not intended to be used as an early warning indicator for lightning related storms. It does not guarantee accuracy or predict exact strike locations. It it not a replacement for a professional lightning detector. Again: This is just a toy.

Features

Building and Installation

Prototype

Hardware

You need:

The lightning detector is connected like this:

All other terminals of the detector are connected to GND of the ESP board.

Optionally, a single SK6812 RGBW LED can be added as a status LED. It is must be powered by 5 V, and its data input is directly connected to IO4.

No other components are required.

To fully understand the functionality of the lightning detector, please read the AS3935 datasheet.

Important Notes

Firmware

To build the firmware, you need to install the Arduino IDE. After installation, just open the kaminari.ino file.

Dependencies

Please make sure these libraries are installed in the Library Manager of the Arduino IDE:

Configuration

Before you build the project for the first time, please copy the myWiFi.h.example file to myWiFi.h, and adapt it to your needs:

To send lightning events via MQTT, these additional options need to be configured:

Installation

Now you can build the project in ArduinoIDE.

After that, connect your ESP8266 via USB. In the Tools menu, please set all parameters so you can upload the sketch to your ESP8266. The settings depend on the brand of your module and on your computer's operating system, so there are no generic settings that can be recommended here.

When everything is completed, upload the sketch to your module. That's all.

You can open the Serial Monitor to read some debug output of Kaminari as it starts up. You will find the WiFi status, the IP address, and the calibration results there.

Connection

There is a small web server running in Kaminari. You can connect to it by pointing your browser to the IP address (e.g. http://192.168.1.23/status).

Kaminari uses mDNS. If your operating system supports it, you can also connect to the sensor via http://kaminari.local/status (or whatever mDNS name you have used in your myWiFi.h file).

Endpoints

Kaminari offers a set of endpoints. Some endpoints are read-only. Other endpoints change the state of the detector, and thus require the API key to be passed in via X-API-Key header or api_key URL parameter. For the sake of simplicity, all requests are GET requests, even those that change the state of the detector.

/status

Returns the current status of the detector as JSON structure. This is an example result:

{
    "lightnings": [
        {
            "age": 34,
            "distance": 12,
            "energy": 38123
        }
    ],
    "distance": null,
    "energy": 0,
    "noiseFloorLevel": 146,
    "disturbersPerMinute": 81,
    "watchdogThreshold": 1,
    "wifiSignalStrength": -55
}

This is the meaning of the individual properties:

/settings

Returns the current settings of the detector as JSON structure, for example:

{
    "tuning": 500135,
    "noiseFloorLevel": 146,
    "outdoorMode": false,
    "watchdogThreshold": 2,
    "minimumNumberOfLightning": 1,
    "spikeRejection": 2,
    "statusLed": true,
    "blueBrightness": 48,
    "disturberBrightness": 100
}

/update

This endpoint permits to change the settings. Settings to be changed are passed as URL parameter:

The changes are permanently stored and will still be effective after Kaminari had been powered off and on.

Other settings are managed by Kaminari and cannot be changed externally.

The API key is required for this call.

/calibrate

This endpoint forces a new calibration of the internal oscillators. The calibration takes approximately 5 seconds. The calibrated antenna tuning is returned. It should be around 500 kHz.

The API key is required for this call.

/clear

This endpoint clears the list of detected lightnings, the age of the last detected disturber, and the counter of disturbers per minute.

The API key is required for this call.

/reset

This endpoint resets the detector chip. May be useful if the detector cracks up or behaves strangely. This call also includes a calibration and resetting the statistics.

The API key is required for this call.

Status LED

An optional RGBW LED is showing the current status of the device:

MQTT events

If MQTT support is enabled, Kaminari will publish a message on every detected lightning event. The payload is a JSON structure:

{
    "energy": 0,
    "distance": null,
    "tuning": 500135,
    "noiseFloorLevel": 146,
    "disturbersPerMinute": 2,
    "watchdogThreshold": 1,
    "wifiSignalStrength": -55
}

This is the meaning of the individual properties:

Data Recording

You can frequently poll the /status endpoint for lightnings and other sensor values. This can be done either manually or automated.

Geordi is a tool that frequently polls the status and stores the samples in a Postgresql database. It supports Kaminari directly. Grafana can be used for visualising the results.

FAQ

Contribute

License

Kaminari is open source software. The source code is distributed under the terms of GNU General Public License (GPLv3+).