Announcement

Collapse
No announcement yet.

Light Sensor Bobcat

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Light Sensor Bobcat

    I finally feel comfortable with my Light Sensor Bobcat.

    When I first installed the device, I was never sure it would respond properly to varying light conditions outside. Now I use the Light Sensor as the primary means to control the Dusk and Dawn lighting in my home.

    To setup my light levels, I have my Ocelot send the light level to a variable, which I have named "Ocelot Light Level". I use a level of about 220 to set the Dusk or evening mode, and roughly 190 for the Dusk mode. You may find that different values are appropriate for your system.

    To combat lightning (lightning storms are common in spring) and other odd disturbances, I created another Device named "Ocelot Averaged LightLevel". An event is set to trigger a script every time the light value changes.

    The script does a simple calculation to generate an averaged (weighted) level into a virtual device named "Ocelot Averaged LightLevel". To do this I use a very simple formula. The following example is not the actual code but represents the way I accomplish the averaging.

    <pre class="ip-ubbcode-code-pre">
    Dim AveragedLevel, NewLevel ' holds calculations
    AveragedLevel = hs.DeviceValueByName "Ocelot Averaged LightLevel"
    NewLevel = hs.DeviceValueByName "Ocelot Light Level"
    AveragedLevel = cint((AveragedLevel*.95) + (NewLevel*.05))
    hs.SetDeviceValueByName "Ocelot Averaged LightLevel", AveragedLevel
    </pre>

    Another Event is set to trigger whenever the device "Ocelot Averaged LightLevel" value changes. When the vaule is less than the Dusk value or greater than the Dawn value I trigger the appropriate Dusk/Dawn scripts.

    The formula I am using is an averaging technique that essentially nets the same thing as averaging the last 20 reads. I take 95% of the AveragedLevel and add 5% of the NewLevel. If the NewLevel is the same as the AveragedLevel, the new AveragedLevel stays the same. But if the NewLevel drops by 10, it means that the averaged level will only decrease by .5 (10 *.05 = .5) or
    (190 * 0.95) + (180 * 0.05). This is the same as having 19 readings of 190 and one reading of 180. The value of this technique is that you don't need to store the last 19 readings. You only keep the result. This is especially great when priming an average, or when you start up. You do need to do some range checking and value checking. This can be done whenever you initiate HomeSeer. Simply cause the first data point to be forced into the Averaged LightLevel device, and everything should work quite nicely.

    regards,

    I don't throw out "flyers" or data that changes more than some percent of the average, but this would be quite easy to implement. This is one way to do it:

    <pre class="ip-ubbcode-code-pre">
    Dim AveragedLevel, NewLevel ' holds calculations
    AveragedLevel = hs.DeviceValueByName "Ocelot Averaged LightLevel"
    NewLevel = hs.DeviceValueByName "Ocelot Light Level"
    ' reject flyers because they changed more than 15%
    if (AveragedLevel / NewLevel) &lt; .85 then exit sub
    ' otherwise continue
    AveragedLevel = cint((AveragedLevel*.95) + (NewLevel*.05))
    hs.SetDeviceValueByName "Ocelot Averaged LightLevel", AveragedLevel
    </pre>

    This trick works great and you don't need to check for which value is greater than the next because as it gets darker, the change will be slower. But you need to be careful about the getting brighter side of things, because if it brightens quickly, like after a storm, you need to be sure the value changes keep up or else you get behind and you will loose the ability to update the average. Thus, you need to keep the flyer's percent large enough. Also, since the Light Sensor does read continuously, you will be getting smaller increments of change than you would with lightning.

    Personally, I have not included the "reject flyers capability" in my script for the moment, although I may in the future.

    GenevaDude

    [This message was edited by GenevaDude on Fri, 04 April 2003 at 03:21 PM.]

    #2
    Why do you need to calculate average light level over a period of time to use a light sensor to control dusk / dawn lighting?

    Comment


      #3
      DC

      In one word - lightning!

      I had an interesting situation where we had some lightning a few weeks ago and my Home Automation computer had lots of "fun" trying to turn the lights on and off in response to the changes in light level.

      The first time lightning "struck" it was funny. After the second, third, and so on it was no longer a positive WAF

      regards,

      GenevaDude

      Comment


        #4
        If the light sensor is set to go "ON" at a certain level and "OFF" at a certain level you could have an event with a condition like "IF LIGHT SENSOR HAS BEEN ON FOR AT LEAST 1 MINUTE" or "IF LIGHT SENSOR HAS BEEN OFF FOR AT LEAST 1 MINUTE". That would factor out lightning.

        But if you are using the light sensor as an analog input device, I guess that wouldn't work since there is no event condition like "IF LIGHT SENSOR HAS BEEN GREATER THAN x for 1 MINUTE". (Actually, I thought there was when I first asked the question.)

        Comment


          #5
          Just wondering how you have the lightbob mounted. Is it in some kind of a weatherproof incloser?

          Thanks

          Comment


            #6
            sonypoolplr,

            I have an interesting solution that was driven by stuff I had on hand.

            A few years ago I bought the Sears shop-vac and then added the clear plastic pipes they sell both in kits and individually. The goal was to connect my table saw, radial, router and some other tools to a centralized vaccuum. It didn't work out because the shop-vac is not strong enough and the pipes are not large enough in diameter. I have since purchased a Jet Vaccuum and switched to a larger piping system.

            So when I decided to mount my Ocelot Bobkats outside I thought that the clear pipes would work. I cut a section about 18 inches long and put an elbow on each end. The assembly is mounted outside the computer room window using the plastic clamps that come with the pipe kits. They are also available as a seperate item.

            Next, I simply put my 3 sensors inside the assembly. They are not fixed into position, and I can easily pull them out if necessary. I have a temperature, humidity and light Bobkat in the housing. Because the assembly is clear, it receives good lighting. Since it is on the North side of the house, it seems to be concistent in useage, plus, the temperature sensor is not influenced by sunlight and solar radiation. Same for the humidity sensor. And the open ends allow for reasonable air flow as well. Temperatures track quite well with the DuPage Airport, which is just three or four miles away.

            Certainly, there is a more elegant way to do what I have done, but it serves the purpose and is not especially visible from the yard.

            regards,

            GenevaDude

            Comment


              #7
              DC,

              You are correct. And there is usually more than one solution to a problem.

              I chose this method because I want to be able to adjust the threshold levels. The Ocelot light sensor can be used as a digital device or as an analog device. Getting a logic level from Ocelot is not desireable because you need to calibrate the values and that is difficult to do. You would need to stop HomeSeer (because there is no way to simply disengage the serial port) and fire up CMAX. So, taking the analog reading is preferable and significantly easier to maintain. I can tune things at will. In fact, I derived my values by watching the light level in the family room. When I felt it was getting "dark enough" I ran upstairs (not actually) and observed the value of the sensor. This became my Dusk value. Same thing for the Dawn value. Since then I have tweaked them a few notches, but they are close to my original picks.

              Again, there are lots of ways to go about it. Dusk and Dawn levels can be determined by the geographical location and time method or you might desire to use an indoor sensor. But I believe the best measurement is made outdoors. The light level is direct and not influenced by internal lighting or any other situations. It measures what you want, the outdoor light level. Be it cloudy or be it bright, this is a reliable and true source that enters your home through the windows. It is better to control your lighting needs based on this rather than by a geographical location.

              regards,

              GenevaDude

              Comment

              Working...
              X