LCD Sensor Print

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

LCD Sensor Print

Post by sprinkfitter » Mon May 11, 2020 6:32 pm

I am trying to print a sensor reading to a LCD. No errors but the screen is black. LCD will print text ok and screen is working :?: :?:

Code: Select all

from ili934xnew import ILI9341, color565
from machine import Pin, SPI
import tt24
from time import sleep
import dht

sensor = dht.DHT11(Pin(5))

while True:
    sleep(2)
    sensor.measure()
    temp = sensor.temperature()
    hum = sensor.humidity()
    temp_f = round((temp * 9/5) + 32.0, 1)
    #print('Temperature: %3.1f C' %temp)
    #print('Temperature: %3.1f F' %temp_f)
    #print('Humidity: %3.1f %%' %hum)
    
    
      #print('Failed to read sensor.')

spi = SPI(2, baudrate=20000000, miso=Pin(19),mosi=Pin(23), sck=Pin(18))
display = ILI9341(spi, cs=Pin(2), dc=Pin(27), rst=Pin(33), w=320, h=240, r=1)


display.erase() 
display.set_font(tt24)
display.set_pos(0,0)  #11 lines down with tt24
display.print(str(temp_f))
display.set_pos(0,20) #23 lines accross with letters
display.print(str(hum))

Post Reply