Natural Disaster Sensor Project with Circuit Playground Express

Updated 06 June 2018

There is some wild weather approaching! We need a way to give ourselves an early warning when a disaster strikes! In this project, we will use the Adafruit Circuit Playground Express to make an all in one Disaster Detection Station that will detect earthquakes, storms, fires/extreme heat, and floods. This popular classroom programming challenge is perfect for the Adafruit Circuit Playground Express because all the sensors that you need are made right into the board! We can also program with MakeCode, a block-based programmer that makes it possible to program with no prior programming experience.

We will first show the code in its fully assembled form, then break it down into each part. We will use the onboard thermometer, accelerometer, microphone, and capacitive touch sensitive pin. We recommend having at least one alligator clip to use as a wire detector.

If you are an educator interested in creating a Disaster Detection Station in your classroom, NSW uses this project as a STEM Stage 3 example. Check out the Unit Overview STEM Stage 3: Disaster Detection, and Sample unit STEM Stage 3: Disaster Detection. The Circuit Playground Express is the perfect board for use in the classroom with no loose part, no soldering, and no complex software required.


Housing the Project

A fun way to expand on this project in the classroom is by challenging students to create weatherproof housing for their natural disaster detection stations. You can 3d print a housing, have students build something out of cardboard, or house them in plastic tubs. The design is up to you!


The Code

We will create our program in MakeCode if you want to learn more about using MakeCode check out our Getting Started with MakeCode Tutorial. The code we have created has four parts. We will first show the entire code, and then break down and explain each part. We are detecting heat (fire), loud sounds (thunder), touch (water level), and motion (earthquakes).

MakeCode Screenshot for Adafruit Circuit Playground Express Disaster Sensor Sketch

The first disaster we will detect is extreme heat. We could also say this is a fire detector. We have chosen to set the trigger temperature to 40 degrees Celsius. You can set this temperature to anything you like, but keep in mind that anything above 50 degrees is likely to damage the board. It is also more fun if you can duplicate the conditions to activate the warning. You could (carefully) heat the board to 40-50 degrees with a hairdryer. For the heat sensor, we have a comparator, that takes the live input temperature from the thermometer and checks to see if its greater-than or equal to 40. If the temperature is greater than 40 then a siren sound is played, and a rotating red light animation is played on the lights.

MakeCode Adafruit Circuit Playground Express Heat Detection

The second disaster we are detecting is thunder. We have set the speaker to listen for sound amplitude over 200. The sound of thunder will likely exceed this limit and the circuit playground will emit a sound and play a sparkle animation when it does. We have included a more complex version with lightning and thunder detection at the end of this tutorial.

MakeCode Adafruit Circuit Playground Express Flood Detection

The third disaster we are going to detect is a flood. Using the capacitive touch sensitive pins on the Circuit Playground Express, we can use an alligator clip and wire as our water sensor. We’ve chosen pin A2, when the end of the wire attached to pin A2 touches water, a tone and a water rising animation will be played. In this example, we made the tones and animation ourselves.

Note: It is safe to put the end of a wire connected to the capacitive touchpad into water, but do not put any other part of the board into water. Also, be careful not to connect the 3.3v or Vout pins. These are powered pins should never be put in water. The capacitive touch pins are A1, A2, A3, A4, A5, A6 and A7.

MakeCode Adafruit Circuit Playground Express Motion Detection and Graph

The final disaster is an earthquake. The Circuit Playground Express comes with an accelerometer, so we can measure any movement that the board experiences. If the Circuit Playground is resting flat on a surface, then any side to side movement can be read from the x and y-axis of the accelerometer. We have added both together and graphed them to the light ring, so any motion is displayed on the ring of lights in real time. It is also graphed and logged within the MakeCode app in the Console! You can export all this collected data to an Excel spreadsheet.


Going Deeper

If you want to take it a step further, there are lots of other ways to utilize the sensors on the Circuit Playground Express. There are seven capacitive touch sensitive pins on the Circuit Playground, each one could be used to detect different levels of water. Here is an example of how to possibly measure the distance lightning is away from your detector. It uses some advanced blocks so I didn’t include it in the main code. It takes an ambient light reading every minute, if brighter than ambient light is detected it resets the timer. When a loud noise is detected the time that passed between the flash and the thunder is divided by 3 and printed in the Console. This is the number of kilometres away that the lightning was. The distance is then represented on the board by lighting up one LED per kilometre. 

MakeCode Adafruit Circuit Playground Express Lightning Detection

Take these ideas and get programming! You don’t need a Circuit Playground Express to start trying these programs yourself, MakeCode is free and available on your web browser. A virtual Circuit Playground Express is to the side of your code and is interactive. This allows you to create your code and see it working in the virtual environment before it reaches your hardware. There are lots of great possibilities for this project, we have lots of great Circuit Playground Express Tutorials to help give you ideas, and a Circuit Playground Express Workshop that goes through everything you could need to start programming with absolutely no prior experience.

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.