Introduction: Arduino Lightning Detector W/ Real Time Graphing

Hi! This is my first Instructable, and I would love feedback!

This project started one day when I was bored. I Googled 'Arduino Projects,' and this came up on the Arduino playground.

NOTE: This was not my original idea, I discovered it on the Arduino playground, but here is the original article: http://runtimeprojects.com/2016/02/a-lightning-detector-for-arduino/ . I have made modifications to my project, which I think may make it better.

You need:

  1. x1 Arduino
    (I started on an Uno but ended up using a Micro)
  2. x1 Breadboard
    (You could eventually end up using a Perfboard, I guess)
  3. x4-7 Jumper wires
    (To connect components)
  4. x1 Voltage Divider Circut
    You have two options:
    1. x1 Potentiometer
    2. x3 Resistors
      1. x2 10K Ohm
      2. x1 3.3M Ohm

Step 1: Background Lightning Knowledge

When lightning strikes it releases many kinds of energy. Most people know it releases light & sound, but Lightning also releases radio waves, specifically in the VLF (Very Low Frequency) to the LF (Low Frequency) ranges, or about 3 to 300 KHz. With the Arduino, frequencies of about 7 KHz can be captured, which is well within the limits of frequencies emitted.

With this project, we should be able to pick up lightning within about 12.5 miles (20 kilometers).

Step 2: The Circuit

WARNING: Lightning can induce both positive and negative currents in the wire, so please follow the instructions carefully, being 100% certain that your voltage divider is working to avoid damaging your Arduino.

The circuit is very simple. The most complicated part is called a voltage divider, this is to prevent our Arduino from being damaged by the currents induced in the wire by Lightning.

Picking your poison: Voltage Dividers

There are a few different ways you can implement a voltage divider into your circuit.

Option 1: Resistor

If you are going to use resistors, you will need to attach them like in the 2nd picture.
Option 2: Potentiometer

If you are going to use a potentiometer, then you can attach it as in the circuit diagram, the first picture.

Step 3: The Code

There are two different programs running for normal operation.

Download my code & Circuit diagrams from Github.

  1. Arduino
    The Arduino program is very simple.
    void setup() {
    Serial.begin(115200); //Setup serial communications at 115200 baud.
    pinMode(A4, INPUT); //Define analog pin 4 as an input
    }

    void loop() {
    Serial.println(analogRead(A4)); //Print the value from pin A4 to the serial port
    }
  2. Processing
    The Processing program is a bit more complicated
    import processing.serial.*;
    Serial myPort; // The serial port

    int xPos = 1; // horizontal position of the graph float inByte = 0;

    void setup () {
    // set the window size (Note: can be scaled for your screen):
    size(1000, 750);

    // List all the available serial ports
    // if using Processing 2.1 or later, use Serial.printArray()
    println(Serial.list());

    // Open whatever port is the one you're using.
    //Change the 0 to whatever # in the list you are using (-1)
    myPort = new Serial(this, Serial.list()[0], 115200);

    // don't generate a serialEvent() unless you get a newline character:
    myPort.bufferUntil('\n');

    // set inital background:
    background(0);
    }
    void draw () {
    // draw the line:
    stroke(127, 34, 255);
    line(xPos, height, xPos, height - inByte);

    // at the edge of the screen, go back to the beginning:
    if (xPos >= width) {
    xPos = 0;
    background(0);
    }
    else {
    // increment the horizontal position:
    xPos++;
    }
    }

    void serialEvent (Serial myPort) {
    // get the ASCII string:
    String inString = myPort.readStringUntil('\n');

    if (inString != null) {
    //trim off any whitespace:
    inString = trim(inString);
    // convert to an int and map to the screen height:
    inByte = float(inString);
    println(inByte);
    inByte = map(inByte, 0, 1023, 0, height);
    }
    }