Presence sensing was always a key feature for this project, with the goal to have the screen turn on when someone approaches, and then automatically turn off when not in use.
Thankfully the presence sensing is really easy to achieve using an LD2410C-P sensor. As far as I understand it, this awesome sensor uses radar to essentially measure the amount water it can see, meaning that it's not affected by motion, sunlight, etc, and only triggers when a big sack of water is standing in front of it - ie a human being. The best part is that it outputs a simple low/high IO signal based on presence being detected. So far, the sensor has worked fantastically and flawlessly.
The sensor is mounted behind the faceplate which doesn't seem to change the way it performs at all. The datasheet has more information about radomes, but 0.4mm of PLA seems to work fine.
The biggest challenge was getting the screen to turn off and on. I'll blame a lot of this on the change from X to Wayland in RPi OS, but I've found that almost any internet article or forum post before 2023 no longer applies (and yes, I understand the security reason for the change). I think this is just something that will just improve over time.
Anyway, after a lot of trying and failing with Xrandr, WL-randr and DDCUtil, I found the correct version of Waveshare's RPi-USB-Brightness library. Unfortunately it seems to be completely closed source, but from what I understand it controls the backlight by serial communication over the USB port, and so far it works adequately. The alternative is to solder a wire to the screen's backlight PWM port, and then send a PWM signal from the RPi.
So, to bring it all together, I created a Python script to read the GPIO pin, and turn the screen off and on as necessary with a nice fade-in effect. You can view and download this script from the Github repo here: https://github.com/tsnoad/rpi_wall_case/blob/main/kiosk.py. This script will also be used to read input from the touch-sensitive buttons, but this isn't implemented yet, partially because I don't know if the buttons will actually be useful.
At present the script has to be run manually after startup (so does the browser that points to Homeassistant). At some point I will set this up as a daemon, but at the moment I just have it set up as a RPi OS menu item so that a keyboard is not needed.
That's all for now, but still on the to-do list are:
- Project log about getting Power over Ethernet working
- Project log about painting, sanding and finishing the case
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.