0

I am working with a DHT 11 and LCD. When executing the code, the temperature prints one time on the pc and freezes. It does not print on the LCD though neither. Can I have someone assist me with this problem, please?

enter image description here

5
  • 1
    Not a Pi, but a Python problem... Pls post the code as text, but first make sure you initialise the LCD just once. You're doing that every time you try to write new values and that will not work.. – Dirk May 8 at 18:46
  • import os from time import sleep import RPLCD import CharLCD import RPi.GPIO as GPIOimport gpiozero GPIO.setwarnings(False) humidity, temperatureC = Adafruit_DHT.read_retry(11, 4) termperature = temperatureC * (9/5) + 32; def configure_lcd(): lcd = CharLCD(numbering_mode = GPIO.BCM, cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[33, 31, 29, 23])) lcd.write_string('Temp = {0:4.1}F'.format(termperature)) lcd.cursor_pos = (0, 0) lcd.cursor_pos = (0, 1) lcd.write_string('Hum = {0:4.1f} ^'.format(humidity)) – Miguel Wimbish May 8 at 22:05
  • while temperature if humidity and temperature is not None: print('Temp = {0:4.2} Farenhet Humidty = {0:4.2f}%'.format(temperature, humidity)) configure_lcd() sleep(2) – Miguel Wimbish May 8 at 22:05
  • IDK why it came out that way. I could post it all at once. you're only give a certain amount of character – Miguel Wimbish May 8 at 22:06
  • You have to add any updates to the question itself, not the comments. – Dirk May 9 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.