Skip to content

jeancarl/tjbot-photo-booth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TJBot Photo Booth

This project provides the Node-RED and Cloud Function code to build a TJBot Booth.

There are two components to the photo booth: a Node-RED flow running on the Raspberry Pi that controls the TJBot. When the TJBot receives a takephoto command, it captures and uploads the photo, and publishes camerastatus and phototaken events to the Watson IoT Platform. A Node-RED application running in IBM Cloud subscribes to these events, maintains a gallery of photos, and sends MMS messages via Twilio. The photos are stored in an Object Storage service.

Object Storage

Photos are stored in an IBM Cloud Object Storage service. This section describes how to create an Object Storage service and create a container.

  1. Create an Object Storage service in IBM Cloud

  2. Create a container named photobooth

  3. Copy the service credentials for use later on in the object storage nodes in Node-RED running on both the TJBot and in IBM Cloud.

Cloud Functions

This project uses two Cloud Functions to:

  1. watermark the image by overlaying a graphic over the selected photo
  2. send an image as an MMS with the Twilio API

This section describes how to create the two Cloud Functions, via the IBM Cloud console and from the command line.

Cloud Function to Watermark Image

The file watermark.js contains the Cloud Function that overlays one image on top of another. This Cloud Function can be created in the IBM Cloud console.

  1. Create a new action. Make sure to check the box labeled Enable as Web Action.

  2. Copy and paste the Node.js code from watermark.js into the Code textbox.

Cloud Function to Send Twilio MMS

The directory code/twilio-send-photo includes the Cloud Function that sends an image as an MMS message with the Twilio API. Because the action requires the twilio npm package, a zip file containing all the necessary parts (code and node modules) is built and uploaded via a shell script.

  1. Install the Cloud Function CLI by following these instructions.

  2. Edit the file local.env. Put the Twilio Account SSID and Auth Token in this file.

  3. To install the required npm modules and zip up the action, run the shell script

    ./deploy.sh --build
    
  4. To deploy the Cloud Function, run the shell script

    ./deploy.sh --install
    
  5. To update the Cloud Function, run the shell script (you may need to --build first)

    ./deploy.sh --update
    
  6. Copy the Cloud Function Web Action URL from the IBM Cloud dashboard into the configuration node in the Node-RED application in the next section.

Node-RED Image Gallery Application in IBM Cloud

The Node-RED application in IBM Cloud provides controls to take a photo, displays the gallery of photos taken, and a phone number input to capture the destination an MMS should be sent.

This section describes how to create the Node-RED boilerplate application and configure the application.

Node-RED dashboard to command TJBot to take a photo, display a gallery, and input to send a MMS message

Node-RED flow to run the Gallery application

  1. Create an IoT Starter boilerplate application in IBM Cloud. This will create a Node-RED application with a Watson IoT Platform service.

  2. Import the JSON from the file named bluemixflow.json

  3. Register a device type of tjbot and a device with id photobooth. Update the IoT nodes with the device credentials.

  4. Set the configuration node with the Cloud Function endpoints, the Twilio phone number, watermark image and text message.

Deploy the application and confirm the Node-RED dashboard renders.

Node-RED TJBot Setup

The TJBot subscribes to a takephoto command via the Watson IoT Platform. When this command is received, the flow will:

  1. light the LED the color red to signal it is about to take a photo
  2. publish a camerastatus event with status of taking
  3. take a photo
  4. turn off the LED
  5. publish an camerastatus event with status of uploading
  6. upload the image to Object Storage
  7. publish an camerastatus event with status of ready
  8. publish an phototaken event with the image URL

This section describes how to setup the TJBot with the Node-RED flow and necessary credentials.

  1. Install the TJBot Node-RED nodes onto the Raspberry Pi. Refer to this Medium post for more information.

  2. Import the JSON from the file named raspberrypiflow.json into Node-RED running on the Raspberry Pi.

  3. Add the IBM Cloud Object Storage service credentials into the object storage node.

  4. Add the device credentials from the Watson IoT Platform.

Twitter

This section describes how to configure the photo booth to tweet photos in addition to send a text message. The additional flows can be imported using the JSON in the code/twitter.json file.

The first modification is to add the text input element into the Node-RED dashboard interface.

The second modification is to add the functionality to send a tweet if a Twitter handle is provided.

  1. Import the JSON from the file named twitter.json

  2. Double click on the Twitter node and authenticate with a Twitter account.

  3. Configure the tweet content in the Set Configuration node.

  4. Deploy the changes and access the Node-RED dashboard interface.

Here's an example of what the tweet looks like in the Twitter timeline.

License

This code is licensed under Apache 2.0. Full license text is available in LICENSE.

About

TJBot Photo Booth projects files to create a TJBot Node-RED powered photo booth

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published