Enviro+ screen - turning it off

Hello and good afternoon!

I have a humble question about the Enviro+ HAT that I recently bought. I’ve followed the excellent tutorial here

https://learn.pimoroni.com/tutorial/sandyj/enviro-plus-and-luftdaten-air-quality-station

But my question is: is there anyway to turn off the LCD screen on the Enviro+ please?

I run my PiZero-Enviro+ setup indoors and in my bedroom (as I want to monitor the air quality and particulate matter in the area where I sleep). However the LCD screen on the Enviro+ puts emits a lot of light and this makes it difficult to keep the room dark.

If you could provide the commands (Python or Bash) that would turn off the screen permanently (or until reversed as desired) that would be a great help! I’m happy at the Command Line for controlling the unit.

Thank you kindly

BCM 12 is used for the backlight for the screen. I would think you could turn it off via that pin. You just have to figure out if you need to pull it low or high.

Is there no Python/Bash command to do that please?

I do believe it is this screen.

Which uses this python library

If you look through the examples you may be able to make up some code to turn it all black. Puling the backlight pin high or low should only take a couple of lines of python code. I’ll post something latter on when I get a chance, I’m just about to go out the door for an appointment.
I don’t own an Enviro, but I do have one of those screens on the way. When it arrives, and I get a chance to play with it I’ll see if I can figure something out.

Have a look see here.
https://www.raspberrypi.org/documentation/configuration/config-txt/gpio.md
One of these two should turn it off on boot up. Not sure if the Enviro software will overide it though.
gpio=12=op,dh
gpio=12=op,dl

Another possible way to do it.
http://wiringpi.com/the-gpio-utility/
From command line it would “I think” be something like this.
gpio -g mode 12 out
gpio -g write 12 1
or
gpio -g write 12 0

If you wanted to get really fancy you could code it so its off in a dark room, and on if the lights are on. Using values from the light sensor.

if you are using the enviroplus-python library from Pimoroni’s github page you can just do

 disp.set_backlight(0)

After doing something like this to initialise it :-)

# Create LCD instance
disp = ST7735.ST7735(
  port=0,
  cs=1,
  dc=9,
  backlight=12,
  spi_speed_hz=10000000
)

# Initialize display
disp.begin()
1 Like

Ah thanks a lot sharpred, much appreciated for your help!

Yes, I inserted the line

disp.set_backlight(0)

just after the Initialize Display line in the luftdaten.py script. Whilst I’m running it the display is now off… and I can sleep in the dark again :-))))))

Anyway thanks a lot.

1 Like

Yes thank you @sharpred. Clip and pasted it to a text file for future use. I just got my 0.96 SPI LCD yesterday. I have it plugged into my Mini Breakout garden. That’s about as far as I got though. Going to play around with it today sometime.

1 Like