DIY lightning recorder

Author: Alex wulff (due to glitches of the habra editor, it did not work out as a translation)

To the start of the course C ++ development we have translated an article about a personal lightning recorder – a small device that reports lightning strikes in the vicinity. It even tells you at what distance the lightning struck; at the same time, according to the author, it will be cheaper to assemble it yourself than to buy it in a store. Another obvious plus is that you can hone your skills in circuitry.

The device is based on the AS3935 lightning detector with an RF channel manufactured by DFRobot. The detector detects electromagnetic radiation from lightning and, using a special algorithm, converts this information into information about the distance before the strike.


The sensor can detect lightning strikes up to 40 km (25 miles) and determine the distance to the location of the lightning strike with an accuracy of 4 km (2.5 miles). The sensor itself is quite reliable, but it may not work correctly if the device is in the open air. A homemade device may not work as reliably as a commercial lightning recorder.

Materials (edit)
Instruments
  • computer with free Arduino IDE software.

  • soldering iron and solder;

  • hot glue gun;

  • a machine for stripping the ends of the wire from insulation;

  • 3D printer (optional)

1. Development of the connection diagram

The device diagram is simple. Information from the lightning sensor is transmitted via SCL and SDA lines, plus one connection is provided for an audio signal. The device is powered by a lithium-ion polymer (LiPo) battery, so I decided to integrate a charger for such a battery into the circuit.

Figure A
Figure A

The schematic of the device is shown in Figure A. Note that the LiPo battery is connected to the charger via JST female connectors and does not require soldering.

2. Assembling the circuit

The best way to assemble the device is to use the so-called free assembly technique. The parts are not attached to the substrate (for example, to a perforated board), but simply connected with wires (Fig. B). This way the device is assembled much faster and is smaller in size. True, the aesthetics suffers … But no one will see the dubious aesthetics if the assembly is closed with a 3D printed case. The video above shows how I assembled the circuit using the free assembly method.

Connect the bug to the charger

Unsolder the green terminals from the LiPo charger. They are useless, but they take up space. Connect the positive (+) and negative (-) terminals of the LiPo battery charger to the positive (+) and negative (-) terminals on the face of the bug. These wires will supply the primary voltage of the LiPo battery directly to the microcontroller. The bug technically requires 5V, but it will still work with a 4V LiPo battery.

Lightning sensor connection

Cut the supplied 4-pin cable so that about 5 cm is left of the wire. Strip the ends and connect the cable to the lightning sensor by making the following connections:

  • connect the positive (+) terminal on the lightning sensor to the positive (+) terminal on the bug;

  • connect the negative (-) terminal on the lightning sensor to the negative (-) terminal on the bug;

  • connect the synchronization contact (C) on the lightning sensor to the SCL connector on the bug;

  • connect the data contact (D) on the lightning sensor to the SDA connector on the bug.

The IRQ pin on the lightning sensor should also be connected to the RX connector on the bug. The connection must match the hardware breaker on the bug; the RX header (pin 0) is the only remaining interrupt-capable pin.

Buzzer connection

Connect the short wire from the buzzer to the negative (-) terminal on the bug (ground) and the long wire to pin 11. The signal pin of the buzzer should be connected to the PWM pin (for maximum flexibility), pin 11 is ideal.

Switch connection

Connect the switch to the battery. It will turn the device on and off. First, solder the two wires to the adjacent switch terminals. Since the switch connections are quite fragile, I also hot glue them after soldering.

Figure B
Figure B

Cut the red wire on the battery about halfway and solder the wires from the switch to each end. These connections are shown on the right-hand side in Figure B. Be sure to cover open sections of the wire with heat shrink tubing or hot glue as they may touch one of the ground wires and cause a short circuit. After connecting the switch to the charger, you can connect the battery.

Final layout

Figure B
Figure B

The last step is to get rid of the messy accumulation of wires and components and bring the device into a more presentable form (Fig. B). This must be done carefully so as not to break the wires. Hot glue the LiPo charger to the top of the LiPo battery, then glue the bug on top. And the last step: glue the lightning sensor to the very top. I brought the buzzer to the side, as shown in Figure B. As a result, I got several boards connected to each other with wires sticking out of them. I also left the pins of the switch free for later insertion into the 3D printed case.

3. Programming the microcontroller

Launch the Arduino IDE on your computer and make sure Leonardo is selected from the Tools → Board menu. Download and install library for the lightning sensor. Then download project code and upload it to the bug. The program is extremely simple and very customizable.

Upon detecting lightning, the device will first beep several times to warn of a nearby lightning strike, and then beep a certain number of beeps corresponding to the distance to the lightning in kilometers. If the lightning is less than 10 km (6.2 miles) away, the detector will beep once. If the distance is more than 10 km (6.2 miles), the distance will be divided by 10, rounded off, and the unit will beep according to the number received. For example, if lightning strikes at a distance of 26 km (16 miles), there will be three signals.

The software is started by interrupts from the lightning sensor. When it detects electromagnetic radiation from an impact, a high voltage is applied to the IRQ pin, it causes an interrupt in the microcontroller. The sensor can also send traps for non-lightning events, such as when an interference / noise threshold is exceeded.

In this case, move away from electronic devices with the detector. The radiation emanating from such devices can “block” the relatively weak radiation of a distant lightning strike.

4. Printout of the case on a 3D printer (optional)

Figure D
Figure D
Figure D
Figure D
Figure E
Figure E

I designed the case for the device myself. Files for 3D printing can be downloaded here… (fig. D, E). The upper part of the case snaps to the lower one, no special equipment is required. The case is spacious enough to accommodate your device if you assemble it differently (Figure E). In any case, nothing prevents you from designing a similar body yourself:

  • determine the dimensions of the device;

  • design the device in CAD (I love Fusion 360 – students can get it for free);

  • create an enclosure by dragging a profile from the device model. A 2mm tolerance is sufficient.

Lightning strike detection

Congratulations, you now have a working lightning recorder! How to check if the device is working? The answer is obvious – wait for a thunderstorm. I don’t know how reliable the sensor is, but mine worked the first time.

Charging the device is very simple – just connect the microUSB cable to the LiPo charger and wait for the charging indicator to turn green. During charging, the device must be turned on, otherwise energy will not flow into the battery!

Alteration

The lightning recorder can be made more useful and convenient to use by making certain changes to the software:

  • other sound signals: to make the device sound more pleasant, use the Tone.h sound library;

  • sleep mode: The ATmega32u4 microcontroller (the chip that powers the bug) supports hardware interrupts in sleep mode. The device can be put into sleep mode, and any event received from the lightning sensor will cause the sensor to react. Sleep mode can significantly extend battery life.

This material shows that the ability to develop programs in C ++, work with electronics, gives ample opportunities and can be useful in a variety of areas: imagine, for example, that you are often in nature – then it is better to know about a thunderstorm in advance and even kilometers away but you don’t need expensive equipment. If you like to feel how you control the iron, the current passing through the microcircuits, then you can take a closer look at our course on C ++ developmentwhere students prepare to begin their career as a software developer in this complex and powerful language.

find outhow to level up in other specialties or master them from scratch:

Other professions and courses

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *