Here is the Node Red setup for a Selfie Station where a button is pushed, a LED light ring turns on, a photo is taken, which is then emailed to a dedicated email. Its very similar to this project that was done by teams of students at UH Hilo.
Step 1. Set up the light ring so that it turns on and off after a message is sent:
In this case – we wanted the light ring to turn on with the color red, and then turn to a different color white and then turn off. To achieve this we used a trigger node. The first one was set to 8 seconds.
The second trigger node was almost identical, except that the “send” command was white, and the “then send” command was black.
Step 2. Connect the camera node with a delay: In this case we chose 9 seconds because it was in the middle of the time when the light ring is white. When the signal is sent – the light rings should go off and then the camera light should come on.
You will want double click on the camera node and change the file mode from generate to buffermode. You can also change the properties of the photo here.
Step 3. Check that you ended up getting your photo by looking in the pictures photo on your pi. Grab the send email node from the sidebar.
Move the email node after the photo node.
You will want to have a special gmail that you have set up to receive emails from node red. We set up one that was named especially for the project. Once you are logged in to the account you will need to follow the link for getting emails from “less secure sources.” The screen you will get to after being logged into the gmail account looks like this: You will want to toggle the button to allow less secure apps.
Open the properties tab for the email node – enter the new email you just created and made less secure into the who “To” field. Enter the email that you want the data to be sent from into the “Userid” field. This does not need to be a “less secure” email. It could even be an email with the specific name of the pi where it will be placed.
Test it out and check your email to see that it worked.
Step 4: Switch the input to a button (or any other trigger device). We used a button and connected one side to 5v power, and the other side to GPIO12. Set the resistor to “pulldown” and check the box for read initial state of pin on deploy.
When its working a push of the button should change the “0” to a “1” right below the pin node. When the button is released it should change back. Connect up the nodes and push a button to take a photo and send it!
The button can be swapped out for a different type of sensor such as the PIR or sonic motion sensor, just be careful that the sensitivity isn’t set too high, or else you could find yourself with a lot of emails!
If you actually want to set this pi up somewhere (like we did in this project) you will want to configure it to auto start Node Red when the pi is powered on. As long as the pi is in an environment where it has permission to log into the wifi, it should work.