Say you want to build an app that sends you an email whenever the temperature drops below or exceeds a threshold. Normally, you'd have to go through the process of writing software that can speak to both to your email provider and Bean. If you use Node-RED, you can avoid having to write that software since it understands how to communicate with both your email account and Bean!
In this tutorial, you'll build a Node-RED flow that connects your Bean's temperature sensor to an email account.
- LightBlue Bean
- Windows or OS X computer
Node-RED is a visual programming interface for the Internet of things. If you haven’t used Node-RED with the LightBlue Bean before, you need to set it up before following this tutorial.
This is what this project's Node-RED flow looks like:
Here's a rundown of the nodes in our flow and what each one does.
1 min interval: Triggers the nodes it’s connected to on a set interval. In this example the interval is 60 seconds.
Bean temp: This is a node developed specifically for the LightBlue Bean. It connects to a specified Bean and gets the temperature from it.
Temp threshold: Compares the current temperature to a low and high threshold. If it’s too cold or too hot it sends a string with the temperature to the next node.
Email: Sends the string passed from the previous node to a specified address.Node-RED Sketch
Step 1: Copy file to clipboard
Copy the JSON data below to your clipboard:
ArduinoStep 2: Start Node-RED server
Open your terminal. Navigate to your Node-RED folder and type
http://localhost:1880/ in your browser. Click the menu in the top right corner and choose
import > clipboard
Double click the Bean temp node and click on the pen to edit the Bean settings. Update the name to be the name of your Bean. It is important you write the exact name as it’s the only way for Node-RED to find and connect to the correct Bean.
Double click the email node and fill in the account details for your email.
Click deploy in the top right corner and you’re done!Troubleshooting
Having trouble with this guide? Reach out to BeanTalk to get directed feedback from our developers and community!