1

Project: I am making a Pi powered photo frame with google photos integration.

Object: I have added a pir sensor for auto screen off when no activity is detected and now i am looking to control backlight brightness with output from the Pi's gpio. My backlight control board uses a 363hz frequency and pwm with 3.5 volts to drive and this is perfect for my needs.

Technical information: The current draw from the signal is 20 microamperes. The duty cycle from the monitors control board goes from about 25% at its lowest and then the square wave goes to "full high" 3.5 volts at full brightness. I have been able to replicate this with the pi with software pwm but it has drop-outs and glitches. When using hardware pwm (pigpio, pin BCM24) the backlight can be adjusted far lower than standard and is steady all the way in increments to 100%. The lux sensor I am using outputs a voltage inversely proportional to light in, with high light values are closer to zero volts and low light values output 5 volts at full darkness.

Question: My question is how can I implement a signal input from the lux sensor to be returned on gpio out with varying PWM output for backlighting control. I am a total novice and am not looking for an answer more than a direction to follow. This is a very interesting project for me and I am enjoying learning, although this is a gift for someone soon, I am having a lot of fun figuring this out. I fear without proper training/ guidance I may not be able to do this. Thank you anyone for any information as I have scoured Google for days and cannot seem to find a way to co-relate input voltage on gpio to output variance in pwm. Maybe I am not using the proper search terms. Here is the very very basic code i am using to successfully control my backlight editing the last number from 150-1000 to change brightness. Thank you again!!

Basic code: sudo pigs pfs 24 1000 prs 24 1000 p 24 1000

  • 2
    I take one look at posts like this and give up - try some paragraphs. – Milliways Apr 16 '18 at 23:49
  • Sorry about the mess, tried to clear it up some. – benjamin Jaquith Apr 17 '18 at 0:07
  • You don't specify explicitly how you wish your backlight to respond to the ambient lighting. Normally, as ambient light reduces so should the display brightness. In order words, in bright sunlight the display should be at its brightest. The opposite has been assumed in Joan's answer – Greenonline Apr 18 '18 at 22:42
  • Exactly. The lux sensors output is inversely proportional to the input of light in a traditional sense. High amboant lighting, low voltage, low ambient light, high voltage. I just have to reverse the phase of the input or output to correct this. I am using an Arduino now to solve this issue and so far it's working perfectly. Thank you for the input 😀 – benjamin Jaquith Apr 19 '18 at 2:19
1

If I understand correctly you want to adjust the backlight according to the inverse of the lux reading. I.e. the darker the environment, the brighter the backlight.

Firstly the Pi has no way of reading a voltage so you need an ADC (Analogue Digital Converter) to convert the varying voltage into a number to be passed to the Pi.

Look for something like the MCP3008 which allows for up to 8 inputs and provides a 10 bit resolution. The received number will be 1023 for 5V (min lux) and 0 for 0V (max lux). As the MCP3008 will need to be powered from 5V its output line (DO) will need a voltage divider attached to drop the voltage to a Pi safe 3V3. A web search will find hundreds of examples for the Pi.

You would then map those readings onto a PWM dutycycle setting. So that min lux becomes max dutycycle, and max lux becomes min dutycycle.

  • Thank you so much for the information Joan! I will look into the hardware necessary to incorporate this feature. I just found out last night that the gpio pins can only read States of on and off and not analog voltages in, let alone 5v, so I would need hardware to do that. The guidance is greatly appreciated. – benjamin Jaquith Apr 17 '18 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.