Tutorial: Building an IOT Lightning Detector with your Raspberry Pi – Part 1
At SwitchDoc Labs we have been building a number of prototype IOT (Internet Of Things) devices for a number of different videos, articles, products and books we have been working on. Our latest Book, “Raspberry Pi IoT Projects: Prototyping Experiments for Makers“, has been selling well on Amazon, published by APress-Springer/Daniel. Our first O’Reilly Publishing tutorial video, “Introduction to the ESP8266 and the IOT” also just came out. Time for a new project, the Raspberry Pi IOT Lightning Detector.
We just have added a new product, the Thunder Board I2C Lightning Detector to our lineup and wanted to build a project using it. We are intending to add drivers for the lightning device to three of our product lines: OurWeather, the SmartPlantPi, the GroveWeatherPi and the WXLink wireless data transmission products. Since we are going to be using the Grove Lightning Detector so extensively, we thought we should build a project.
The ThunderBoard IOT for the Raspberry Pi was thus born. We will be building this project in four postings. FIrst the description of the project (Part 1). Secondly, we get the hardware up and connected (Part 2), then we get the Python software installed, and in Part 4, we will use MQTT to connect to a dashboard, freeboard.io (and pubnub.com). Part 5 shows the Raspberry Pi Thunder Board IOT device and the Arduino Thunder Board IOT device at work!
What is the IOT?
Put simply, the IOT is about connecting Internet Enabled devices the relay information back to us, to cloud based applications and dashboards and to each other. These smart devices can be anything from computers, to thermostats, to refrigerators, mobile phones, cars or even big things like jet engines.
- - Part 1 - The Lightning IOT Project and How Does It Work?
- - Part 2 - Putting Together The Hardware
- - Part 3 - Understanding and Installing The Software
- - Part 4 - Installing the Internet Dashboard
- - Part 5 - Video Demonstration
What is The Thunder Board IOT?
The overall design of the project is simple. We use the Raspberry Pi to read a sensor that measures sunlight and breaks the sunlight down into three components (UV, IR and Visible). We also use an LED to provide visual feedback that a sample is being taken (two blinks) and that the process is still running (one blink).
The general idea of the Thunder Board IOT is to build a software platform to build more complex IOT sensors. In this column and the next, we will be going through a complete, IOT design. As well as providing a test bed for the new Grove Thunder Board Lightning Detector.
The parts list for the Thunder Board IOT for Raspberry Pi project is follows.
|Thunder Board Lightning Detector||0240-THNDRBRD-DBST|
|Grove LCD Display With Backlight||0116-GRVLCDBL-DSBT|
|Additional Grove Cables (2-30cm Cables)||0120-GRV30C-DSBT|
|Raspberry Pi 3 – Many Sources|
|(includes two Grove cables with devices)|
|3D-Print Files (at GitHub)|
If you don’t have a 3D Printer, you can buy the 3D printed case here.
What are Grove Connectors
Grove is a modular, standardized connecter prototyping system. Grove takes a building block approach to assembling electronics. Compared to the jumper or solder based system, it is easier to connect, experiment and build and simplifies the learning system, but not to the point where it becomes dumbed down. Some of the other prototype systems out there takes the level down to building blocks. Good stuff to be learned that way, but the Grove system allows you to build real systems. It requires some learning and expertise to hook things up. Full Grove tutorial here.
The Grove system consists of a base unit and various modules with standardized connectors.
The Base unit allows for easy connection of any input or output from the Grove modules. and every Grove module typically addresses a single function, such as a simple button or a more complex heart rate sensor. Two examples of base units are the Pi2Grover ($20) from SwitchDoc Labs and GrovePi+ ($30) from Dexter Industries. The big difference between these two units, aside from price, is that the Pi2Grover provides a direct connection between the Raspberry Pi and the Grove units (allow normal python drivers to work without modification) while GrovePi+ puts an Arduino between the Grove device and the Raspberry Pi (which requires new drivers to be written for the GrovePi+ board).
You don’t need a Base unit to connect up to Grove modules. You an use a cable (jumper wires to Grove connector) to run from the pins on the Raspberry Pi or Arduino to the Grove connectors.
The Hardware List
The Part Letter in the parenthesis is used to refer to the individual parts in the assembly guide in Part 2.
Raspberry Pi 3 (Part A)
The Raspberry Pi 3 Model B features a quad-core 64-bit ARM Cortex A53 clocked at 1.2 GHz. This puts the Pi 3 roughly 50% faster than the Pi 2. The RAM remains the same – 1GB of SDRAM. The Pi 3 includes on-board 802.11n WiFi and Bluetooth 4.0. WiFi, wireless keyboards, and wireless mice now work out of the box.
Why are we using the Raspberry Pi 3 rather than a less expensive Raspberry Pi Zero? Well, over the last three projects at SwitchDoc Labs, we have found it much easier to develop the software and hardware using a Pi 3 for speed reasons (especially reboot speeds!) and then porting the resulting software and hardware over to a Pi Zero (as we did recently with the GroveWeatherPi Solar powered weather station). The Pi2Grover fits all of the Raspberry Pi boards.
Pi2Grover (Part B)
The Pi2Grover board provides buffered connections and voltage translation between the Raspberry Pi pins and external Grove modules. Pi2Grover provides bi-directional Pi2Grover voltage translation from the Raspberry Pi (3.3V) to 5V. The board is “transparent” to any software, so existing drivers for modules will work with no translation required. Voltage translation for I2C Bus is also supported by the Pi2Grover board.
The Thunder Board Lightning Detector (Part C)
This is the heart of the IOT hardware. This is an I2C device that detects lightning and then reports to the Raspberry Pi via an Interrupt line connected to D16 on the Pi2Grover Card. This board is based on the AS3935 Franklin Lightning Detector and contains an I2C buffer (to isolate the flaky I2C interface on the AS3935) and 10K pull-ups on the I2C bus. It also has an improved antenna design compared to older boards.
The Thunder Board is an Arduino and Raspberry Pi Grove compatible breakout board with a full set of connectors. No external antennas required! It is designed for use in Low Power applications such as battery and Solar Power applications. It can detect lighting up to 40km away.
How the heck do we detect lightning? You would think it would be pretty easy, but it turns out it is not. It’s not just like a giant spark. Well, it is a giant spark, but there are lots of other things that make electrical noise that can be confused for lightning. Your computer (even your Raspberry PI and Arduino!), your car, the motor in your refrigerator, your cell phone, your computer monitor, your AM/FM radio and even your TV. They all make electrical noise that can be confused with Lightning.
The Thunder Board is an I2C device and detects Lightning and provides a distance estimate to the “leading edge” of an incoming storm.
Grove LCD I2C with Back Light (Part D)
The Grove I2C LCD supplies two lines of 16 characters (with user programmable characters!) with a programmable color backlight. It allows you to alert the user by using both text and color what is going on with your unit. You combine this with audio cues from the Grove Buzzer (below) and you have a full local alerting system. Add the Internet Dashboard and you have a complete IOT system.
This LCD is easy to program and can be used in Arduino and Raspberry Pi System. You can get some great effects with the backlight color. When we detect lightning we go red!
Grove Buzzer (Part E)
This is a simple Grove Digital Buzzer. The piezo buzzer can be connected to digital outputs, and will emit a tone when the output is high. Alternatively it can be connected to an analog pulse-width modulation output to generate various tones and effects.
You just connect the Grove cable to the buzzer and to a Grove Digital Output. Set the GPIO output to 1 to turn the buzzer on and to 0 to turn the buzzer off.
30 cm Grove Cables (Part F and G)
We have a whole selection of different lengths and types of Grove cables at SwitchDoc Labs. The 30cm cables are idea for connecting the Grove Thunder Board Lightning Detector to the Raspberry Pi IOT kit. We need to keep the detector away from the Raspberry Pi computer! The Pi makes a lot of electrical noise that can confuse the Lightning Detector.
3D Printed Files
Here are the 3D Printer files for the Raspberry Pi Case for the IOT project.
Coming in Part 2
Part 2 will go through the assembly of the Raspberry Pi Thunder Board IOT device. And then some test results!