System Is Down Detector

by jckelley in Circuits > Microcontrollers

4311 Views, 52 Favorites, 0 Comments

System Is Down Detector

cover_image.jpg

If you work in a company that has a website, you know how important it is that the website always be up and running. That's why you constantly see "99.99999% reliability!" all over the fancy server hosting sites. A website can't make money if the system is down, so knowing when that happens and reacting quickly is super important. In this Instructable, we will use the LinkIT ONE board to make an alert system that will play a loud alert siren and send us a text message. This way no matter where we are, we can respond as fast as possible!

Supplies

WP_20151027_006.jpg

Since we're harnessing a lot of the built-in power of the LinkIT ONE, we don't need that many external supplies here. You can focus your gathering energy on a quality speaker to play our alarm through!

  • LinkIT ONE
  • Speaker (headphones for testing is cool)
  • SIM Card (Pre-paid for deployment, borrow a friend's for testing)
  • An Alarm MP3 File
  • A Website to check on!

Configure Your LinkIt ONE Board

WP_20151019_012.jpg

We'll need to modify some of the switches on the LinkIt One board in order to make it work. Along with the image attached, make sure that you have done the following

1. Set the MS -- UART switch to UART (You'll switch it to MS in a later step temporarily, but not for deployment)

2. Set the USB -- BAT switch to USB

3. Set the SPI -- SD switch to SPI

Connect Your GSM and WiFi Antenna

WP_20151027_004.jpg

Now, you'll need to make sure and connect both your WiFi and GSM antenna's to your LinkIT ONE board. Both of these Antenna's should have come with your LinkIT ONE kit. Attaching them is pretty self-explainatory: Connect the WiFi Antenna do the socket labeled 'WiFi' and your GSM Antenna (Which allows you to send text messages) to the socket labeled 'GSM'

Insert Your Sim Card

WP_20151019_011.jpg

I know that most people probably don't have a pre-paid SIM card laying around. If you are just prototyping and want to see a proof of concept, feel free to remove it from your current cell phone (or one of your friends) just to try it out. If you get serious and want to make this a full-time gig, you will have to pony up for a pre-paid SIM.

Inserting the SIM card is a fairly straight forward process. Flip over your LinkIt One and look at the smaller big metal piece. You can see in the figure where I inserted my SIM card if you are confused.

After you have inserted the SIM card, be sure to attach your GSM antenna that came with your LinkIt One kit. This will allow you to get a cell signal.

Download Your Alert Sound

WP_20151025_007.jpg

You could opt for a rather basic siren alarm, such as this or that. But I chose for something a little more fun :)

Once you've found your sound, download it. If you found it as a youtube link, go ahead and use a youtube downloader website in order to convert it to an mp3 file. Store in a place you'll remember because we'll be moving it over to the LinkIT ONE very shortly.

Install Music on Device

WP_20151025_010.jpg

Now, you'll want to install your scary voice file on your device. Because we are using the SPI/SD slot for SPI purposes (Sending a text message) we are not able to use the SD to store our mp3 file. Instead we will have to store it in flash memory.

Drag and Drop Music into the LinkIt One Flash Storage

Turn your LinkIt One device into 'MS' mode (Mass Storage) and your computer will recognize it just like a usb stick. From here, you can easily drag and drop mp3 files over. The problem is that your limited by the 10mb on the LinkIt One, this means only a handful of songs (if they are short!).

Once you're done, turn your device back to UART mode in order to deploy code to the device!

The Code I - WiFi and Checking If the System Is Down

If you look over this WiFi client code, you'll see basic code that goes and checks if a we can get data from a website or not. In the case provided, we've used "www.google.com".

If we can't receive data from that website (AKA, the System is Down) then we write to the serial monitor.

The Code II - Alerting Once the System Goes Down

Next, we will implement some logic to send out an SMS text alert. This will allow us to be notified if the system is done no matter where we are (well, provided that you are within distance of a cell tower and have your cell phone!). This code uses the LGSM library. If the code looks confusing to you, I suggest you check out online resources.

After that, we want play our alert audio file. That way if we're in the room by not by our phone we get an immediate alert. For that, we will use LAudio library to play the file, and the LSD library to ready from flash storage.

Also, be sure to do the following before actually deploying your code:

  • Change the Wifi Parameters (SSID and Password)
  • Change the Audio file name to whatever you named your file
  • Change the number to text within the Soundthealarm function to make sure it texts you!
  • Change the url to whatever 'System' or website you would like to check if you can get data from or not.

Then deploy away!

Going Forward

WP_20151027_005.jpg

Now you have a nifty device that will alert you both audibly and visually anytime your favorite website (or workplace website) has gone south. You can modify this even more with a bit of tinkering on both ends. You could make it to a get request to make sure that you are getting certain data back (Correct data) from a server. It could help out with testing environments and much more!