Turn on/off ST7735 connected to WeMos D1 R2

Hi
I have a ST7735 connected to a WeMos D1 R2. I retrieve sensor data created on a BME680 ( connected to a NodeMCU in a different location ) via HomeAssistant. This part works fine.

Is there a way to turn off the screen during the night or when I’m away during the day? I do have the code to display content only at predefined times, what I’m looking for is a function for the display to actually turn it off.

I did see Ssd1306 Screen ON/OFF time based - #3 by arfrater , but it is a different type of display and it is unclear to me where it has the id’s defined for “turn_display_on” and “turn_display_off”
And I did see Turn off OLED display after boot / restart , but obviously the display for platform ST7735 does not have turn_on(), turn_off() methods.

Here is my yaml, I shortened it a bit and removed the parts related to the sensors and the lambda to print the actual values and graph
Note: if you copy the code for other purpose, the device crashes 100% with a stack trace if you connect a browser to port 80, this type of display seems to run out of memory.


esphome:
  name: screen
  platform: ESP8266
  board: d1_mini
  on_boot:
    priority: -10
    # ...
    then:
      - switch.turn_off: builtin
      
# Enable logging
logger:
  level: INFO
# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret api_password
  
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: !secret ah_domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "screen Fallback Hotspot"
    password: !secret ap_password
  manual_ip:
    static_ip: 192.168.0.50
    gateway: 192.168.0.1
    subnet: 255.255.255.0
    
mdns:
  disabled: true
  
web_server:
  port: 80
  
captive_portal:

font:
  - file: "DejaVuSans.ttf"
    id: my_font
    size: 10

switch:
  - platform: gpio
    pin: D4
    name: "Wemos LED"
    inverted: true
    id: builtin

time:
  - platform: homeassistant
    id: ha_time

# removed sensors

spi:
  clk_pin: D5
  mosi_pin: GPIO5 

display:
  - platform: st7735
    id: display1
    cs_pin: D8
    dc_pin: D7
    reset_pin: D6
    model: INITR_BLACKTAB
    rotation: 90
    device_width: 128
    device_height: 160
    col_start: 0
    row_start: 0
    eight_bit_color: true
    update_interval: 30s
    lambda: |-
      it.printf(10,10,id(my_font),blue,"Blue");
      it.printf(10,25,id(my_font),green,"Green");
      it.printf(10,40,id(my_font),red,"Red");
      it.printf(10,55,id(my_font),yellow,"Yellow");
      it.printf(10,70,id(my_font),white,"White");

regards
Armin

The answer is actually in the thread you posted.

As per adafruit your display pulls ~50ma at full backlight. I doubt you’ll get that out of a pin, you’ll have to check to see if your chip can supply that much. You will likely need a switching transistor.

Hi
thanks, I hope to find some time during the weekend to try that.

Armin

I tried it but when the pin high is 3.3 V and not 5 V that I’m using to power the Display.
There should be a way to power it with 3.3 V but not clear how to do it

Untitled

GP NPN BJT = general purpose NPN bipolar junction transistor.

e.g. BC546, 2N2222, etc…

Clear!
you suggest to use the GPIO to control the GND and not the 5V.
Great idea

Can draw empty screen depending on datime, f.e. !?!?!

I’ve just started experimenting with an ST7735. My unit has a pin marked BL - presumably for backlight.

I have the BL pin connected to a gpio ‘switch’

switch:
  - platform: gpio
    pin: 21
    id: disp_backlight
    internal: true

Turning on the ‘switch’ turns on the backlight, turning off the switch turns off the backlight and the display goes dark.

Not quite what you asked but maybe it will do…

Seems to be a different model , no pin for BL here
have VCC GND SCL SDA RS/DC RES CS

And for the SD-Card MSO, SCLK, MOS and CS

But the display is still working after 2 years, only that I moved it from the WeMos D1 to a ESP32

Armin

ST7735 seems to cover a lot of variations. Mine doesn’t have SD card

Bought here: https://www.amazon.co.uk/dp/B07FKX67WN/ref=pe_27063361_485629781_TE_item

Cheers