Follow Me Icons

 

Follow @KendrickColeman on TwitterConnect on LinkedInWatch My Videos on YouTubeFollow me on FacebookCheck Out My Projects on GitHubStay Up To Date with RSS

Search

BSA 728x90 Center Banner

Introducing the MonsterRemote for the MonsterShield

I'm pretty excited to release this and make one long blog post out of it. This is not my usual blog posting topic, but this is a good place to keep it so I can maintain it. I'm a pretty big halloween nut, like really big. check out some pictures from 2012 Halloween.

 

Last year, I caught wind of the MonsterShield prop controller. For about $200, you can have a prop controller that can control 16 relays, have 15 different animations, with MP3 cd quality audio, that also has an API. I was completely sold. Over some talk with Jason (the creator of the MonsterShield), I wanted to build something that I could use to trigger the animations that I want. I run a yard haunt, and with over 10,000+ people that come around to see the Halloween decorations on the street, I can't use traditional triggers. Motion detectors means they would be going off constantly. And having it timed means I won't have the correct animations set off for specific parts of the yard depending upon where people are standing. I could use multiple prop controllers, but I like centralization. With 16 relays, I can control everything in my yard from a single spot, so I had to figure out the best possible way to trigger the animations I want to see. This way my wife and I can sit on the porch, drink a beer, and set off the electric chair when people aren't ready for it.

 

I started learning Ruby on Rails earlier this year but didn't have a project, so this became my first go at Ruby on Rails. And thanks to Steven Bryen for lending his ruby expertise from time to time. The great thing about RoR is that you can easily build responsive websites that can be viewed on mobile phones, tablets, as well as desktops. So there is my goal. Using a Raspberry Pi as the Ruby on Rails server, it will send commands to the Arduino to trigger anything I want.

 

Without further ado, I am pleased to introduce the MonsterRemote. The MonsterRemote is aimed at being a remote control for the MonsterShield prop controller that you can use from any mobile device. Utilizing a smartphone with web browsing capabilities, you can trigger any configured animation on the MonsterShield prop controller. This is a free and open source project with no liability or support.

 

Features:

  • Dynamic Home Screen that will only display the animations/slots that have been enabled on the MonsterShield
  • Change the generic names ("0. Scene 00") to any name of your choosing like "0. Ambient Mix" or "0. Scary Jumping Flying Thing"
  • Enable/Disable Animations in the settings page that will Enable/Disable the slot on the MonsterShield and reflect a new or deleted button on the home screen
  • Interrupt and stop a triggered animation after selecting yes on a dialogue box
  • Remotely Shutdown your Raspberry Pi to preserve file integrity of the linux system files
  • Toggle Ambient settings to be On or Off
  • Toggle the Animation mode to be Sequential (0,1,2,3..), Random (5,A,9,1..), or Single after selecting your animation(1,1,1,1..)
  • It's FREE!!

 

Browse the code over at GitHub - monster_remote.

 

An intro video (bad quality on the Flip) and some screenshots:

 

Version 1.5.2 Changes

 

Older Version Images

 

A quick look at the 2013 light show using the MonsterShield and MonsterRemote (watch it in >=720p)

 

Version Changelog:

  • Version 1.0:
    • 1.0, waiting to fix bugs
  • Version 1.5
    • changed serial port communication to open on rails start. previously, communication was opened and closed on every command causing the arduino to reset
    • added "Refresh Scenes" button instead of refreshing scenes on the MonsterShield Settings page. Whenever the monstershield is in ambient mode, reading a result from the MonsterShield is impossible
    • removed MonsterShield version number because if the MonsterShield is in ambient mode, it's impossible to read.
    • Fixed "Stop Ambient" loop function
    • made all buttons larger for easier mobile use
    • changed the ambient stop and start to more colored buttons
  • Version 1.5.1:
    • Fixed bugs of not having the correct communication port on rails start.
    • Added a "Connect MonsterShield" button on the Raspberry Pi settings page
    • Added labels to detect if the MonsterShield has been successfully connected. Located on Home and Raspberry Pi settings pages.
    • Added more communication ports
  • Version 1.5.2:
    • New twitter bootstrap look and feel.
      • New colors
      • New modal pop-up after scene has been selected
      • Alerts and Notifications are shown on the screen and disappear after 2 seconds
      • Tables and forms have been updated to have a bootstrap native look

 

to grab the latest version, go to the directory where the monster remote git was cloned (ie. /var/www/monsterpi) and type git pull https://github.com/kacole2/monster_remote.git master

 

What you need:

  1. A MonsterShield + Arduino. You can add the expander board if you want. Order everything you need from hauntsoft.com. Jason rocks!
  2. A Raspberry Pi. The raspberry pi will host your rails applications
  3. Wireless dongle for the Raspberry Pi. The Raspberry Pi will need to connect to your home wi-fi network.
  4. USB cable. The USB cable (often referred to as a USB printer cable) will have the square side to connect to the Arduino, and the rectangle side connects to your Raspberry Pi or Powered USB Hub.
  5. Powered USB Hub for the Arduino is suggested for ample power draw.
  6. You need to have some technical capability and not be scared. This won't be a cake walk. Hopefully my guide will show you how it's done.

 

Configure your MonsterShield

Setup your MonsterShield with your MonsterShield editor program or the using the keybang board. Once the MonsterShield is setup as a normal prop controller, you can move on.

 

Setup your Raspberry Pi:

  1. Install Raspbian on your Pi. You will probably want a class10 SD card so everything compiles and runs faster
  2. During setup, configure an easy to remember hostname. Such as monsterremote or monsterpi, or monster. if you have a DNS server at home, make sure to include your FQDN. I called mine monsterpi, and will be using that in all the configurations going forward. so if you want to make it easy, name it monsterpi.
  3. Setup your wireless dongle to connect to your home network. plenty of blog posts are out there to show you how to set this up depending on the type of dongle you bought.
  4. Configure a static IP address on your raspberry pi's wireless connection. VERY IMPORTANT
  5. Remember the username and password you use for connecting to your Pi. by default, the username is Pi. I suggest changing the password to something you can remember.
  6. Test connecting to your Pi via SSH from another computer.
  7. Follow these instructions on installing Ruby on Rails. RPi Ruby on Rails. or follow my list for step by steps. this can all be done via SSH and we no longer need monitor support.
    1. to follow these directions properly, verify you are in the /home/ director for the pi user
    2. Install some packages. 
      sudo apt-get install -y git curl zlib1g-dev subversion
      sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev 
      sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3 
      sudo apt-get install -y libxml2-dev libxslt-dev 
      sudo apt-get install -y autoconf automake libtool bison
    3. not entirely sure if it's needed, but it doesn't hurt.
      sudo apt-get install libv8-dev 
    4. not entirely sure if it's needed, but it doesn't hurt.
      sudo apt-get install libcurl4-openssl-dev
    5. Install RVM and the latest ruby version. It will take a few hours for this to compile on your Pi.
      curl -L get.rvm.io | bash -s stable --ruby
    6. run this command so ruby is working in your console.
      source ~/.rvm/scripts/rvm
    7. run this command so no documentation is installed with the gems.
      echo "gem: --no-ri --no-rdoc" > ~/.gemrc

 

Cool. Now your Pi is setup and ready for the application. adapting this part from a nice tutorial over at Ubuntu Hardy - Nginx, Rails, and Thin.

Install MonsterRemote on the Pi

  1. Clone the git repository containing the application.
    1. Change the current directory
      cd /var
    2. Create a directory called www
      sudo mkdir www 
    3. Go to to the new www directory
      cd www 
    4. Create a directory called monsterpi. you can name it anything you want. this will be a directory you will access. you may want to call it monsterremote or monster. i just called it monsterpi to keep it consistent with the name of the pi itself.
      sudo mkdir monsterpi
    5. Clone the application to the monsterpi directory. In a few seconds you will see all the data for the application transfer
      sudo git clone https://github.com/kacole2/monster_remote.git /var/www/monsterpi
    6. Change to your new directory
      cd /var/www/monsterpi 
    7. Install all the necessary gems. this will take a while, probably a few hours to install rails and such.
      bundle install
    8. Change ownership of files to the pi user
      sudo chown pi:pi /var/www/monsterpi 
  2. Create and seed the database. don't start this until you are done with step 2.
    1. While still in the /var/www/monsterpi directory type
      rvmsudo rake db:setup RAILS_ENV=production
    2. Pre-compile some assets
      rvmsudo rake assets:precompile RAILS_ENV=production
  3. Install the Thin rails server. bootup adapted from stackoverflow
    1. Thin gem should already be installed, but for good measure...
      gem install thin
    2. Install the thin server
      rvmsudo thin install
    3. Update the service to automatically start at login. but for some reason it doesn't like to start automatically on the pi.
      sudo /usr/sbin/update-rc.d -f thin defaults
    4. Create a thin configuration
      rvmsudo thin config -C /etc/thin/monsterpi -c /var/www/monsterpi --servers 1 -e production 
    5. Run rvm list
      rvm list
      1. you will see a list of ruby versions installed. If you're following this guide, then you will only see one version listed, and our original installation loaded the latest version of ruby. remember your current rvm version for the next step. At the current time of this writing, mine is ruby-2.0.0-p247
      2. if you know your way around ruby, and you have multiple gemsets installed then you need to perform a rvm gemset list to get your working list, otherwise, if you are following this tutorial, then we are just using the default global gemset
    6. Create a wrapper to boot Thin based on your currently installed ruby version. 
      rvm wrapper ruby-2.0.0-p247 bootup thin
    7. Lets edit the Thin bootup application
      sudo nano /etc/init.d/thin
    8. change the original loader
      1. original looks like this DAEMON=/home/pi/.rvm/gems/ruby-2.0.0-p247/bin/thin
      2. change the line to look like
        DAEMON=/home/pi/.rvm/bin/bootup_thin
        1. ctrl+x, and then Y, to exit and save
    9. Lets start the thin webserver
      sudo service thin start
  4. Install and configure Nginx web server
    1. Install Nginx from repository
      sudo apt-get install nginx
    2. Edit the application server configuration files by opening it up for editing
      sudo nano /etc/nginx/sites-available/monsterpi
    3. copy and paste this text file (or copy below) into the new file #make any necessary changes for hostnames and sites.ctrl+x, and then Y, to exit and save
      upstream monsterpi {
      server 127.0.0.1:3000;
      }
      
      server {
      listen   80;
      server_name  monsterpi;
      rewrite ^/(.*) http://monsterpi.kendrickcoleman.c0m permanent;
      }
      
      
      server {
      listen   80;
      server_name monterpi;
      
      access_log /var/log/thin_access.log;
      error_log /var/log/thin_error.log;
      
      root   /var/www/monsterpi/public;
      index  home.html;
      
      location / {
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      
      if (-f $request_filename/home.html) {
      rewrite (.*) $1/home.html break;
      }
      
      if (-f $request_filename.html) {
      rewrite (.*) $1.html break;}
      
      if (!-f $request_filename) {
      proxy_pass http://monsterpi;
      break;
      }
      }
      }
    4. remove the existing nginx.conf
      sudo rm /etc/nginx/nginx.conf
    5. Create a new nginx.conf and open it up for editing
      sudo nano /etc/nginx/nginx.conf 
    6. copy and paste this text file (or the code below) into the newly created file #make any necessary changes for your system. ctrl+x, and then Y, to exit and save
      user pi;
      worker_processes 5;
      
      error_log /var/log/nginx.error.log;
      pid /var/run/nginx.pid;
      
      events {
      worker_connections 1024;
      }
      
      http {
      include mime.types;
      default_type application/octet-stream;
      
      log_format main '$remote_addr - $remote_user [$time_local] $request '
      '"$status" $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for"';
      
      access_log /var/log/nginx.access.log main;
      
      sendfile on;
      
      keepalive_timeout 65;
      
      upstream monsterpi {
      server 127.0.0.1:3000;
      }
      
      server {
      listen 80;
      server_name monsterpi;
      
      root /var/www/monsterpi/public;
      location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      
      if (-f $request_filename/home.html) {
      rewrite (.*) $1/home.html break;
      }
      if (-f $request_filename.html) {
      rewrite (.*) $1.html break;
      }
      if (!-f $request_filename) {
      proxy_pass http://monsterpi;
      break;
      }}
      
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
      root html;
      }
      }
      }
    7. Create a link to finish the configuration
      sudo ln -nfs /etc/nginx/sites-available/monsterpi /etc/nginx/sites-enabled/monsterpi
  5. Turn on the app and lets check it out 
    rvmsudo /etc/init.d/thin restart
    rvmsudo /etc/init.d/nginx reload
    rvmsudo /etc/init.d/nginx restart

Open up a web browser to your Pi and you should see the MonsterRemote homescreen. Woohoo!... that took long enough.

 

 

Configure Your MonsterRemote

Now that your application is on the Pi, lets get going! Using your computer or phone, and browse over to your MonsterRemote server. I named my Pi monsterpi.kendrickcoleman.c0m so it has FQDN capabilites, which isn't necessary. I can open it up at monsterpi, or monsterpi.kendrickcoleman.c0m.

 

When you connect to your Pi, you will see the MonsterRemote home screen. This home screen is NOT populated with your MonsterShield data yet. Before we populate the data, we need to make sure we have the correct Communication Port Settings. Go to Settings -> Pi/Server.

 

 

Verify the communication port settings is at ttyACM0, which is default for for Raspberry Pi connections. 115200 is the default baud rate for connecting to the MonsterShield/Arduino. If this isn't your setting, click edit, and change the configuration by pressing edit. If your connection isn't listed, let me know and we can get that fixed. I have not tested it, but it might be possible to use a linux, or windows based laptop to be the rails server as well. I used my mac to build the rails application so I know that will work, but not entirely sure about the shutdown command. Click Save.

 

If you are using a raspberry pi, edit the settings for the webserver. Type in the IP address or hostname of your raspberry pi, username, and password. Set the Ip Address or DNS Name to monsterpi or monster.your-fully-qualfied-domain-name or the static IP address you configured back when setting up your Pi. By default, the username should be pi. Your password is anything that you changed it to, or raspberry is default. If you are running your rails server on a mac or linux machine, these settings may be used to shut it down, but haven't been completely tested.

 

 

If there is ever a problem getting information from the MonsterShield, you will receive a screen like this, where you should go and configure the communication port settings.

 

To populate the data, go to Settings -> MonsterShield. When accessing the MonsterShield settings, we are performing a call to the MonsterShield to get back all the configured animations. If the animation settings don't look correct (all false, or mixed up), refresh the page. There is usually a problem sending a call to the MonsterShield and making it work without timing out. You shouldn't have to refresh this page more than 2 times.

 

Within the settings page, we grabbed all the configurations from the MonsterShield whether they are enabled or disabled and displayed them. You can also change every individual slot. By editing a slot, you can change the scene name to any string of your choosing. This string will be seen on the buttons on the home screen. You can also change whether the scene is enabled or disabled. Enabling or Disabling the setting from this screen will change the configuration of the MonsterShield and enable or disable that specific slot.

 

Clicking back will take us to the MonsterShield Settings page where the application will once again poll the MonsterShield for the current settings and display them on the screen. At this point, you will see your previously manipulated slot changed to enabled or disabled.

 

The MonsterShield Settings page will also allow you to toggle the Ambient settings by sending a STOP or START command to the MonsterShield. We can also change the playback mode by selecting Sequential, Random, or Single modes.

 

Now if we go back to the MonsterRemote home screen, we can see the buttons have all changed. Any slot that has been disabled has been removed from the home screen.

 

 

Well there ya go, enjoy!

 

Contacts Page:

 

Related Items