Go Down

Topic: Industrial Light Tower w/ wifi and sound effects (Read 183 times) previous topic - next topic

cwhummel

Aug 06, 2015, 12:24 am Last Edit: Aug 06, 2015, 12:27 am by cwhummel
I've been building a control system for an Industrial Light Tower for a friend. In the beginning all she wanted was a simple dial to control the lights, but she didn't realize who she was talking to. I totally Tim Taylor'd it.

So, to start with, I had to figure out how this light tower operated. Once I finally found the data sheet for it, found that it works on 24vDC (or AC as well, supposedly), I found the lights themselves to be completely modular and could be taken off and placed in any given order without any rewiring. The tower has 9 wires, 2 for Vin, 5 for the lights, and 2 for the light mode (constant of flashing). Just connect a light wire with a mode wire, connect power, and you're good to go.

I started with my Uno, but downsized to a 3.3v Pro Mini to match the rest of the components. For control of the lights, I found the best method was to use optocouplers. Cheap, ease to use, no clicky relay noise. The next question was how to control it. I was originally told to just add a dial or something, but come on, thats no fun. Wifi is where it's at.

Enter the ESP8266. I made a simple web server with serial output to the arduino, giving the user On/Off buttons for each light, as well as a few "programs" such as random, chase, and Knight Rider back and forth light bar. This was ok at first, until I found a few problemss.

A: iOS devices didn't like the ESP web page.
B: Constant lockup/ memory dump/ whatever issues
C: The SSID and password had to be put into the code, so the unit could never be taken anywhere to be shown off.
D: Memory sucks balls on the NodeMCU. My tiny little program barely fit in the LUA environment.

So, after scouring the web, I found this gem. I already knew about the Arduino port for the ESP8266, just hadn't really needed it yet. Not only does the Arduino IDE give you the full 512K, but this program gave me everything I wanted. A GUI to log into any Wifi as needed. And a much better looking web page, which coincidently also now works with iOS. And it's rock solid, handling multiple users if needed.

Now for the fun part. I've always pranked my friend in the past, mostly with stuff like putting musical greeting card things in her keyboards, making her mouse vibrate, etc...

So after an exhaustive search on the what would serve my needs the best/easiest, I settled on the Adafruit Mini FX Sound Board along with a mono amp. I put a counter on the number of incoming serial messages (how many times the light tower is changed from the ESP web page), made a random number trigger with pinout to the sound board, and went ahead and threw on a bunch of annoying sounds. Here are a few examples:

Cartman : Respect my authoritah!
WHO LET THE DOGS OUT!
Rick Roll
Sports Center intro noise
Office Space : What would you say, ya do here?
Lego Movie: Everything is awesome

and, here is a video of the whole thing working.
http://www.youtube.com/watch?v=vUq0ye0VS94

I will post code and schematic (or fritzing pic) later.
"Beer is proof that god loves us and wants us happy" - a popular misquote of Benjamin Franklin, but true nonetheless.

cwhummel

#1
Aug 06, 2015, 10:48 pm Last Edit: Aug 06, 2015, 11:04 pm by cwhummel
Some photos of the Light Tower and my horrible mess a circuit board.
"Beer is proof that god loves us and wants us happy" - a popular misquote of Benjamin Franklin, but true nonetheless.

Pauly


cwhummel

thanks. Been a lot of fun a a good learning experience. building the base is next.
"Beer is proof that god loves us and wants us happy" - a popular misquote of Benjamin Franklin, but true nonetheless.

cwhummel

Here is the code. The posted code is the web page on the ESP8266, the attached file is the code for the arduino pro mini.

Code: [Select]
#ifndef PAGE_EXAMPLE_H
#define PAGE_EXAMPLE_H

//
//   The EXAMPLE PAGE
//
const char PAGE_example[] PROGMEM = R"=====(
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <h1>Pat's Super Awesome Light Tower</h1>     
  <body>
  <p> <form name="input" method="get">Blue <input type="submit" name="on1" value="On">&nbsp&nbsp<input type="submit" name="off1" value="Off"></form></p>
  <p> <form name="input" method="get">Green <input type="submit" name="on2" value="On">&nbsp&nbsp<input type="submit" name="off2" value="Off"></form></p>
  <p> <form name="input" method="get">Red <input type="submit" name="on3" value="On">&nbsp&nbsp<input type="submit" name="off3" value="Off"></form></p>
  <p> <form name="input" method="get">Yellow <input type="submit" name="on4" value="On">&nbsp&nbsp<input type="submit" name="off4" value="Off"></form></p>
  <p> <form name="input" method="get">White <input type="submit" name="on5" value="On">&nbsp&nbsp<input type="submit" name="off5" value="Off"></form></p>
  <hr>
  <p> <form name="input" method="get">Random <input type="submit" name="RA1" value="On">&nbsp&nbsp<input type="submit" name="off6" value="Off"></form></p>
  <p> <form name="input" method="get">Chase <input type="submit" name="CH2" value="On">&nbsp&nbsp<input type="submit" name="off6" value="Off"></form></p>
  <p> <form name="input" method="get">Knight Kit <input type="submit" name="KK3" value="On">&nbsp&nbsp<input type="submit" name="off6" value="Off"></form></p>
  <hr>
  <p> <form name="input" method="get">WTF! <input type="submit" name="WTF" value="On">&nbsp&nbsp<input type="submit" name="off6" value="Off"></form></p>
  <hr>
  <p> Built By <b>The Chad</b></>

   
   <div id="mydynamicdata"> Powered by Gluten Free Panda Poop.  </div>   <!-- added a DIV, where the dynamic data goes to -->
   <script>               


window.onload = function ()
{
load("style.css","css", function()
{
load("microajax.js","js", function()
{
setValues("/admin/filldynamicdata");  //-- this function calls the function on the ESP     
});
});
}
function load(e,t,n){if("js"==t){var a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}else if("css"==t){var a=document.createElement("link");a.href=e,a.rel="stylesheet",a.type="text/css",a.async=!1,a.onload=function(){n()},document.getElementsByTagName("head")[0].appendChild(a)}}



   </script>

)=====";
#endif


void filldynamicdata()
{       
    String values ="";
//    values += "mydynamicdata|" + (String) + "This is filled by AJAX. Millis since start: " + (String) millis() + "|div\n";   // Build a string, like this:  ID|VALUE|TYPE
    server.send ( 200, "text/plain", values);   
}

void processExample()
{       
    if (server.args() > 0 )  // Are there any POST/GET Fields ?
    {
     
       for ( uint8_t i = 0; i < server.args(); i++ ) {  // Iterate through the fields
       // Serial.println(server.argName(i));
            if (server.argName(i) == "on1")
            {
                 // Your processing for the transmitted form-variable
                 String fName = server.arg(i);
                 Serial.println('1');
            }
            else if (server.argName(i) == "off1")
            {
              Serial.println('2');
            }
            else if (server.argName(i) == "on2")
            {
              Serial.println('3');
            }
            else if (server.argName(i) == "off2")
            {
              Serial.println('4');
            }
            else if (server.argName(i) == "on3")
            {
              Serial.println('5');
            }
            else if (server.argName(i) == "off3")
            {
              Serial.println('6');
            }
            else if (server.argName(i) == "on4")
            {
              Serial.println('7');
            }
            else if (server.argName(i) == "off4")
            {
              Serial.println('8');
            }
            else if (server.argName(i) == "on5")
            {
              Serial.println('9');
            }
            else if (server.argName(i) == "off5")
            {
              Serial.println('a');
            }
            else if (server.argName(i) == "RA1")
            {
              Serial.println('b');
            }
            else if (server.argName(i) == "CH2")
            {
              Serial.println('c');
            }
            else if (server.argName(i) == "KK3")
            {
              Serial.println('d');
            }
            else if (server.argName(i) == "off6")
            {
              Serial.println('e');
            }
            else if (server.argName(i) == "WTF")
            {
              Serial.println('f');
            }
        }
    }
    server.send ( 200, "text/html", PAGE_example  );
}
"Beer is proof that god loves us and wants us happy" - a popular misquote of Benjamin Franklin, but true nonetheless.

Go Up