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

If you not only want to stay informed about events with your pxlBlck and also use it to display the current time, then it might be you noticed that a fixed display brightness doesn’t always match to every situation.

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

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


Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/

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 shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂


Requirements

For the construction you have to master soldering tasks. The following articles provide tips on how to do this.

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

Required tools:

Required material:

In the following list you will find all the parts you need to assemble.


Connect an LDR to the ESP8266

So that the ESP8266, which is built into your pxlBlck, can sense the ambient brightness, you must first connect an LDR. This is a light-dependent resistor, the resistance of this kind of resistor 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.

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

You can also see the basic circuit diagram for connecting a LDR to an ESP8266 on the following circuit diagram.

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

Configure the ADC of the ESP8266

So that the brightness values of the connected LDR can be sensed, you must first configure the analog digital converter of the ESP8266. Thanks to ESPEasy, this is done quickly.

To do this, switch 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 the IP address of devices in your network is also described in the article Displaying/Finding out the IP address of the devices in the network.

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 now be redirected to a page where you can configure a device.

In order to configure the analog digital converter you have to choose the entry

Analog input – external

here.

Now you should configure the device “Analog input – external” as indicated in the picture on the left.

You then have to confirm the settings by clicking on “Submit”.


Activate and configure rules

After configuring the analog digital converter, you only have to 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) for the “Tools” tab

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

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

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 in the Rules text field (highlighted in red).

On ADC#Analog do
pbbr,0,[ADC#Analog],1,1,15,
endon

This rule means that the current display brightness is adapted to the ambient brightness every second.

You can find more information about this command in the article pxlBlck – Commands for configuring the pxlBlck

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

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


I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

Fab

P.S. 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 appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at ko-fi.com

Leave a Reply

Your email address will not be published. Required fields are marked *