Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Light sensor calculation

Light sensor calculation

Scheduled Pinned Locked Moved Development
7 Posts 5 Posters 3.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jocke4uJ Offline
    jocke4uJ Offline
    jocke4u
    wrote on last edited by
    #1

    Hi,

    I am looking at light sensor LM393 and wonder about the logic.

    int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
    

    First part ((1023-analogRead(LIGHT_SENSOR_ANALOG_PIN)) I understand the thinking to.... little light = low value and it's logical but for the division by 10.23 I cannot understand the reason.
    Can anyone enlighten me? ;)

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      The division is there to get a percentage value between 0-100.

      1 Reply Last reply
      0
      • jocke4uJ Offline
        jocke4uJ Offline
        jocke4u
        wrote on last edited by
        #3

        Ha :) stupid me ...of course....thanks
        I however feel it get "0" (no light at all) with still some light and will remove that division to have a bit more "sensitivity".

        Would also be nice to have some comments in the source about these calculations to make it easier to understand the thought behind ;)

        Dan S.D 1 Reply Last reply
        0
        • jocke4uJ jocke4u

          Ha :) stupid me ...of course....thanks
          I however feel it get "0" (no light at all) with still some light and will remove that division to have a bit more "sensitivity".

          Would also be nice to have some comments in the source about these calculations to make it easier to understand the thought behind ;)

          Dan S.D Offline
          Dan S.D Offline
          Dan S.
          Hero Member
          wrote on last edited by
          #4

          @jocke4u The biggest number that can fit in the register that holds the light sensor value is integer 1023 (based on the register size). Given the range of 0-1023, the formula will return a value of 1 to 100. For my light sensor I changed it to a direct read with no modification, because I like you was more interested in accuracy for lower light level values. Maybe in direct sunlight you would get 1023, but indoors my max is about 500.

          1 Reply Last reply
          0
          • korttomaK Offline
            korttomaK Offline
            korttoma
            Hero Member
            wrote on last edited by
            #5

            Have you guys had luck with the sensitivity on these? I also removed the division but I'm still not satisfied with the sensitivity.
            Would it make a difference if I connect the "light sensor" to 3.3V insted of 5v? I'm using it with a Pro Mini 3.3 that I also feed with 5v on the raw pin.

            • Tomas
            Dan S.D 1 Reply Last reply
            0
            • korttomaK korttoma

              Have you guys had luck with the sensitivity on these? I also removed the division but I'm still not satisfied with the sensitivity.
              Would it make a difference if I connect the "light sensor" to 3.3V insted of 5v? I'm using it with a Pro Mini 3.3 that I also feed with 5v on the raw pin.

              Dan S.D Offline
              Dan S.D Offline
              Dan S.
              Hero Member
              wrote on last edited by
              #6

              @korttoma I think I am using a different light sensor then you (AmbiLight Sensor). For my sensor it was recommended to hook a 100k resistor in series with the output to improve low end sensitivity. You may want to try that on your light sensor. Seemed to work for me. They also said if you want to improve the top end (readings max out) use a resistor in parallel with the output.

              1 Reply Last reply
              0
              • jeylitesJ Offline
                jeylitesJ Offline
                jeylites
                wrote on last edited by jeylites
                #7

                I'm just curious. What is the benefits and difference between a Lux and Photosensitive sensor?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                20

                Online

                11.7k

                Users

                11.2k

                Topics

                113.0k

                Posts


                Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • MySensors
                • OpenHardware.io
                • Categories
                • Recent
                • Tags
                • Popular