There is some wild weather approaching! We need a way to give ourselves an early warning when a disaster strikes!

Transcript

Hi Steven, here from Core Electronics, in this tutorial I'm going to show you how to make a natural disaster sensor project, using the Adafruit Circuit Playground Express and we're going to program it using MakeCode.

We're going to utilize four different sensors on the board to detect four different natural disasters.

First one is going to be high heat or extreme heat or fire, using the thermometer. When the temperature gets above 40 degrees it's going to activate a sound and a red-light animation.

The next disaster we're going to detect is storms and, in this case, thunder is what we're going to detect using the microphone, so when w it would detect it especially loud noise, again it plays a short animation of lights and a little bit of sound.

The third item that we're going to detect is a flood and for this we're going to use the capacitive touch sensors on the board and capacitive touch is sensitive, to touching a person or touching water as well so if we put the end of our alligator clip down where water might accumulate, when water pools in the up enough to touch it, it'll play a water rising animation and a little bit of sound that we made ourselves in the program.

Our last sensor is an earthquake sensor we're going to use the accelerometer on the board to detect any motion in the X and Y plane while the board is lying flat on the table so if we have an earthquake, any shake of the board is shown on the ring of lights and that's also going to be transmitted to the computer where you can graph it or store it if you want.

So this is a really popular stem project right now it's great for students because it allows them to create some real-world problem solving and learn how to program a little bit with microcontrollers and since we're using the Circuit Playground Express and MakeCode, these are really the ideal combination of microcontroller and in programming language for this sort of project because there are no external parts required on the Circuit Playground Express, you don't need to have a bunch of loose LEDs and resistors to make this project work and MakeCode is really accessible for the beginner programmer so you don't get tied up with maybe a curly bracket being missing that ruins your code and keeps the whole thing from working you can just drag in your code blocks and everything really comes together a lot nicer.

So, let's take a look at the code another reason that MakeCode, is a really good option to use for this sort of project is you have the virtual Circuit Playground Express in the top corner of the screen, so that lets see you try out your code in real time before needing to load it onto the board so you could see everything is working the way it's supposed to and again it takes another opportunity for people to get hung up out of the picture. So, if your program is working on the virtual board you'll know that when you put it on your physical board it should behave just the same and if it's not working for some reason when you go to put it on your physical board then it must be a problem with your connection just makes things easier to troubleshoot.

So, let's break down what we've done for this our first section is, our high heat detection so we have a long if and else if statement here that breaks it into the different parts. The first part is temperature, so the temperatures over 40 degrees then it plays a siren sound and a red-light animation.

The next part is if the sound levels over 200 the sound level returns a value between 0 and 255, so 200 is pretty darn loud and like you'd have to trigger that with a clap right above the board or something so if you hear especially high sound above 200 then it plays a tune and plays an animation as well, so that would be simulating detecting a thunderstorm and in the tutorial I have a more advanced example of this block of code where the Circuit Playground would look for a flash of light like lightening count the number of seconds until it hears a loud sound and then use that data to return how many kilometres a wave lightning from where you are. So, there's a lot of there's a lot of room to expand with these sorts of projects as well.

The next part is our capacitive touch water rising so if pin A2 is pressed, then we have this custom made tone which you use by selecting music blocks and then you can pick the actual note that you want to put in on that block to play and then I've used the light wheel and put them between rests for the notes to create this water rising animation and a good thing about the graph command is if you go into show console device and this is something that's available on the Windows app version of MakeCode, then you can view the real-time data of whatever is in that graph command and it graphs it out here for you so I'm shaking the board now and that you can see it returned on this graph in real time and one of the cool things about this from an educator perspective, is that you can then download all this collected data and it'll export it straight into a spreadsheet that you can then use however you'd like.

So that wraps up my tutorial on how to make a natural disaster sensor, using the Adafruit Circuit Playground Express and programming it with MakeCode. If you want to learn more about how to use the Adafruit Circuit Playground Express or how to program things in MakeCode or Circuit Python, check out our tutorials sections.

I'll see you there.

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.