I wanted to show the capabilities of the sensors on the Bean through a cloud-based data store. This allows for demonstrating what the Bean can do as well as getting the software to integrate with it up and running.
1. Install Node-RED on your local machine and create free accounts for the AT&T Developer program and IFTTT (and/or Twilio).
2. In M2X create a device called "Bean".
- Create a device, not a collection.
- Virtual device is fine.
- A public device would mean the data streams are publicly available. You'll likely want to keep it private.
- Take note of the DeviceID and API Key.
- Create 3 data streams: Temperature, X-Axis, Y-Axis.
3. Grab the code from the Github repo.
- The edge flow goes into Node-RED. If you're using the Bean Loader application make sure it's not connected to the Bean while using it with Node-RED. I do like using Bean Loader to make sure the Bean is detectable. Also make sure any other device is not currently paired with the Bean.
- Adjust the interval in the timestamp inject node to your liking. I've set it to as quickly as every second, which Flow and M2X can handle, but it does drain the battery. Setting to 10, 30, or even 60 seconds works great.
- The cloud flow goes into Flow Designer.
4. Set the DeviceID in the Init node of the edge flow. Set the API key in the Bean config node attached to the blue M2X node on the far right.
5. Deploy the flow in Flow Designer in order to start the services and get the URLs for the end points.
6. In the Bean device in M2X create 2 triggers (from the Overview tab when examining the device).
- X-Axis, > 0.91, reset at <= 0.1, callback URL set to the end point for the Tilt Alarm node from Flow Designer. Single frequency.
- X-Axis, < -0.91, reset at >= -0.1, same callback URL and frequency.
7. Either configure the Twilio node in Flow Designer with your Twilio account info and phone number to receive the text or configure an IFTTT recipe. In IFTTT you'll need to add your M2X account while logged into both services. M2X is already an established source for the "this". You can have it listen specifically for the Bean device (by DeviceID) or to all devices in your account. For the "that" select SMS and fill in your phone number.