Using RapidSpike Connect Anything to Check the Moon

When we say you can connect anything to RapidSpike, we really mean anything. Like the Moon.

Scenario

You want to check how far away the Moon is from the Earth. If it gets too close, or too far away, alert people.

Solution

Step 1 – Create an RCA Monitor

RapidSpike Connect Anything (RCA) monitors are available on our free Basic plan, so feel free to get signed up and have a play. Once you have an account, click the ‘Add’ button at the top of the screen, select ‘RapidSpike Connect Anything’ from the list of monitors and follow the instructions.

Step 2 – Write a script

A RCA monitor requires you to send some data to us. So you need to write and host a script. Your script can run on any device and be written in any language. For example a Raspberry Pi running Python, a server running your website or your Internet connected fridge freezer. The example below is a PHP script that runs on a Cron every hour. I don’t think the Moon will move a great distance between checks (or at least I hope it won’t) so I think once an hour is fine. For customers on a Professional plan, we can process data up to every 5 minutes or every 1 minute on Enterprise accounts.

After a quick search I found an API which returns information about the Moon, including the distance I needed. My script calls the API, then sends the data to the RCA monitor. You’ll be give a unique ID after creating the monitor, make sure you use this when sending your data. For more information please see Sending RapidSpike Connect Anything (RCA) Data.

It’s worth checking the response to make sure everything is working okay. Here we can see the data and the key values were received. See Troubleshooting RapidSpike Connect Anything (RCA) for common issues.

{
    "message":"Data received",
    "error_code":null,
    "status":{
        "code":200,
        "message":"OK"
    },
    "data":{
        "keys_received":{
            "DFCOE":373117.52,
            "DFS":149696179.94
        },
        "id":"ex4mp13-ex4mp13-ex4mp13-ex4mp13"
    }
}

Step 3 – Create the alerts

We’re now collecting the data which can be viewed on a pretty graph. Which is nice, but you probably don’t want to be checking it every day to see where the Moon is. So we can create alerts based on the data we receive. So lets create an alert if the Moon is less than a certain distance from Earth.

If the Moon gets within 250,000 KM of the Earth I will receive a Slack message and email. If things get worse and the Moon gets even closer (less than 100,000 KM away) I could also create an alert that sends me an SMS or voice call – just to make sure I don’t miss it.

We hope you have fun creating RCA monitors. Please do share your uses of RCA, we really like to hear about any unusual or interesting projects!

The Moon seems to be moving away from us…