1

First time posting. I'm a novice writing a python program. I'd like to to curses to display outputs from sensors connected to a Raspberry PI and created the follow code as a test to understand what way it would need to be coded, however i can't get the CPU temp to be display?

import curses
from curses import wrapper
from gpiozero import CPUTemperature

print("Preparing to initialize screen...")

screen = curses.initscr()

print("Screen initialized.")

first_window = curses.newwin(15, 20, 0, 0)

cpu = CPUTemperature()

print(int(cpu.temperature))

def main(test):

# Update the buffer, adding text at different locations
    first_window.addstr(1, 1, "CPU Temperature")
    first_window.addch(2, 1, int(cpu.temperature))
    first_window.refresh()
    curses.napms(5000)
    
wrapper(main)

curses.endwin()

print("Window ended.")

Thanks for reading, help appreciated

1
  • 1
    You'll have to format the number as a string and pass that (actually an array of bytes) to addstr. Commented Mar 18, 2021 at 11:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.