HowTo: pxlBlck – Automatic adjustment of the display brightness via LDR

If you want to use your pxlBlck not only to stay informed about events, but also to display the current time, you may have noticed that a fixed display brightness is not always suitable.

Especially if you have your pxlBlck near a window, you have to set the display brightness relatively high during the day to be able to read the time reasonably. Unfortunately, the same brightness setting is again too bright for twilight or night.

But this problem can be easily solved. Everything you need is described in this article.

Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support in being able to offer other useful projects in the future. 🙂 


For the assembly you have to master soldering tasks. The following articles contain tips on this.

You should also have already built and programmed your pxlBlck. You can find more information about this in the following articles.

Required tool:

Required material:

In the following list you will find all the parts you need for the assembly.

Connect an LDR to the ESP8266

So that the ESP8266 in your pxlBlck can read the ambient brightness, you must first connect an LDR. This is a light dependent resistor, whose resistance depends on the ambient brightness of the LDR.

If the brightness changes, the resistance of the LDR also changes. If the LDR is connected to the ESP8266 via a voltage divider, this resistance and thus the brightness can be measured indirectly using the ADC.

In the following articles on the various pxlBlck platforms the connection of the LDR is described in detail.

But you can also see the basic schematic for connecting an LDR to an ESP8266 on the following schematic.

Basically, an LDR is connected to an ESP8266 according to the following circuit diagram.

Configure the ADC of the ESP8266

To be able to read the brightness values of the connected LDR you have to configure the analog digital converter of the ESP8266 first. Thanks to ESPEasy this is done quickly.

To do this, go to the web interface of your ESPEasy device. To do this, enter the IP address of the device in the address line of your browser.

How to find out the IP address of devices in your network is also described in the article Display/find out the IP address of the devices in the network described.

Then switch to the "Devices" area.

All configured devices are now listed in the table shown.

Now click on the "Edit" button in the first empty line.

You will be redirected to a page where you can configure a device.

To configure the Analog to Digital Converter you have to add the entry

Analog input – external


Now you should configure the "Analog input - external" device as shown in the picture on the left.

You must then confirm the settings by clicking on "Submit".

Enable and configure rules

After configuring the analog digital converter, all you have to do is configure the correct “rules” so that changes in the ambient brightness also lead to changes in the set display brightness.

To do this, click on the button (marked in red) to the “Tools” tab.

Now you have to switch to the “Advanced” page. To do this, click on the button marked red.

Activate the ability to configure rules by activating the checkbox in the “Rules” section.

Then confirm these settings by clicking on “Submit”

After you have pressed the button, you may have to reload the page again, so that...

...the button for the “Rules” becomes visible.

Now click on it to open the “Rules” tab.

Now enter the following rule into the (red marked) Rules text field.

On ADC#A analog do
pbbr,0,[ADC#A analog],1,1,15,

This rule causes the current display brightness to be adjusted to the ambient brightness every second.

You can also find more info about this command in the article pxlBlck - Commands for configuring the pxlBlck

You can also see whether the automatic brightness setting is working correctly in the Device tab.

There (in the red marked area) the currently read in brightness of the LDR and the resulting display brightness is shown and updated.

Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at       


  1. Hello Fabian,

    could you please explain the values from the Two Point Calibration to me.
    I would like the LEDs to be 1 - 2 levels brighter than with the current setting.


    1. Hey Anke,
      the two-point calibration is actually a scaling. (I think the name is a bit unfortunate.) This scales the value range of the ADC to a new value. In the case of the ESP, the ADC can take values between 0 and 1023. Since the LDR is connected via a voltage divider, this range (depending on brightness) is between 0 and 400. Of course, this varies somewhat depending on the installation location. If you want to “calibrate” it exactly, you could uncheck “Calibration enabled” and then write down the values of the ADC in darkness and maximum lighting (e.g. during the day or room lights on). You then enter the values under Point 1 (value at darkness) and Point 2 (value at maximum brightness).
      Now for the actual scaling:
      Since the pxlBlck plugin sets the brightness with a value range of 1-15, the value range of the ADC must now be scaled to the value range of the pxlBlck plugin. In the example shown in the entry, the value range 0-400 is scaled to the value range 0-10. That means the ADC value 0 is scaled to a 0, the ADC value 200 is scaled to a 5 and the ADC value 400 is scaled to a 10. Values above or below 400 or 0 are also scaled in this way. For example, an ADC of 600 gives a scaled value of 15. 🙂
      I hope I explained it clearly. Otherwise please let me know. 🙂
      Best regards

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.