• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

LDR Readings vary with power consumption

Q&A Forum › Category: ESP32 › LDR Readings vary with power consumption
0 Vote Up Vote Down
Craig Harrington asked 1 week ago

I have a project constructing a tank with tracks and moveable turret firing a red laser. There is target incorporating a LDR fixed to the tank to record laser hits to the tank. Ambient light levels are determined and whenever the light level rises appreciably above the ambient light then a “hit” on the tank is recorded. The problem is that the LDR readings jump by about 20% whenever the tank is moving (i.e the motors are running drawing current).  This increase looks like a laser hit to the tank when it is not.
The Tank is composed of:

  1. 2-18650 3.7v batteries wired in series delivering 7.5v
  2. 2-32GB-520 6-12v motors for tracks.
  3. 2-MG90S servo motors for the turret
  4. L293D 16-pin IC Stepper Motor Driver Controller
  5. LDR Photo Light Sensitive Resistor Photoelectric Photoresistor w/ 10k ohm resistor
  6. L7805CV Voltage Regulator 5V
  7. ESP-32

 
The ESP-32 and the L293D run on 5V from the L7805. The motors operate on the full 7.5v battery pack. The LDR operates from the 3.3v pin on the ESP-32.
The tank draws 165mv when on and not moving. It can draw up to 450-500 mv when moving full speed.  Ambient light levels generate ~1.6v under no motor load but when the motors are running the light level immediately jumps to ~2v.
This effect occurs regardless of adding 50Uf capacitors to the in/out pins of the 5v regulator. I have also tried powering the LDR with a completely separate power source so only the common ground and the LDR signal are involved.
I can provide fritzing if someone has any thoughts that could help.
 
Thanks
SacCha

1 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 week ago

Hi.
The analog reading of the ESP32 is not the most accurate and there are several issues reported if you search on forums.
With that said, it may be necessary to try to use different GPIOs for the LDR to see it it gets better.
 
Another alternative is to use an analog to digital converter to get more accurate analog readings from the LDR. These usually communicate via I2C communication protocol. One example is the ADS1115 module (at the moment, we don’t have a tutorial about it).
 
You can also try to use another method to measure the light, like the BH1750 Ambient Light Sensor: https://randomnerdtutorials.com/esp32-bh1750-ambient-light-sensor/
 
I hope this helps.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Smart Home with Raspberry Pi, ESP32, and ESP8266 V1.6 September 9, 2025
  • [eBook Updated] Learn LVGL: Build GUIs for ESP32 Projects – Version 1.5 July 7, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.