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. Hardware
  3. LM393 as Light Level Sensor

LM393 as Light Level Sensor

Scheduled Pinned Locked Moved Hardware
5 Posts 3 Posters 3.1k Views 1 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.
  • clippermiamiC Offline
    clippermiamiC Offline
    clippermiami
    Hero Member
    wrote on last edited by clippermiami
    #1

    I've been playing with the LM393 analog output as a light level sensor using the sensor code from the MySensor site. Usin ghe divisor values in the sketch

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

    it appears to have a very very narrow range from full dark to full brightness. Using it indoors in a dark room i've seen a reading of about 35+/- and in a fully lit room a reading of 60+/-. Is this normal for this sensor or is mine just not up to par?

    I've ordered some of the BH1750 sensors for "production" use so i'm hoping they will be better.

    Thanks
    John

    1 Reply Last reply
    0
    • ferpandoF Offline
      ferpandoF Offline
      ferpando
      Hero Member
      wrote on last edited by ferpando
      #2

      I have the same problem.
      Too narrow range.
      Another problem I have is the readings spike all over the place.
      With the same light, it fluctuates a few decimals up and down.
      I ended up adding some code to reduce the spikes and have a more linear curve.

      Here's what I did with the condition in the loop function:

       if (lightLevel != lastLightLevel) {
           if(lightLevel > lastLightLevel + 0.3 || lightLevel < lastLightLevel - 0.3){
                gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lightLevel);
                lastLightLevel = lightLevel;
           }
       }
      
      clippermiamiC 1 Reply Last reply
      0
      • ferpandoF ferpando

        I have the same problem.
        Too narrow range.
        Another problem I have is the readings spike all over the place.
        With the same light, it fluctuates a few decimals up and down.
        I ended up adding some code to reduce the spikes and have a more linear curve.

        Here's what I did with the condition in the loop function:

         if (lightLevel != lastLightLevel) {
             if(lightLevel > lastLightLevel + 0.3 || lightLevel < lastLightLevel - 0.3){
                  gw.sendVariable(CHILD_ID_LIGHT, V_LIGHT_LEVEL, lightLevel);
                  lastLightLevel = lightLevel;
             }
         }
        
        clippermiamiC Offline
        clippermiamiC Offline
        clippermiami
        Hero Member
        wrote on last edited by
        #3

        @ferpando I haven't seen that level or rate of change myself, but a little hysteresis rarely hurts :)

        1 Reply Last reply
        0
        • ferpandoF Offline
          ferpandoF Offline
          ferpando
          Hero Member
          wrote on last edited by
          #4

          I ordered one of the other light sensor type to test the differences.

          1 Reply Last reply
          0
          • axillentA Offline
            axillentA Offline
            axillent
            Mod
            wrote on last edited by axillent
            #5

            Do not mix digital and analogue outputs of the light sensor
            Lm393 is used to switch from low to high above the light threshold. Etc. it provides digital (binary) output. If you connect it to arduino analogue ping you mostly will read binary data with some noise.
            Analogue output of this sensor is bypassing lm393 and provides you a range of analogue levels depending on the light level

            For me a cheap 5mm round photoresistor is very sufficient as a light sensor. Just create a divider with photoresistor on bottom and fixed resistor on top. Fixed resistor should be with resistance much lower than dark resistance of the photoresistor, so you will read 1023 in a dark room

            sense and drive

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


            30

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 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