TM1638 display work with delay

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
mishu_g
Posts: 1
Joined: Wed Mar 17, 2021 2:31 pm

TM1638 display work with delay

Post by mishu_g » Wed Mar 17, 2021 2:40 pm

Hello everybody
I'm new on this forum.
I tried to display the temperature in the DS18X20 sensor on the TM1638 display.
The display is very slow, each digit is active for about 2 s.
I use library from https://github.com/mcauser/micropython-tm1638
Code:

Code: Select all

import machine, onewire, ds18x20, time
import tm1638
from machine import Pin
ds_pin = machine.Pin(16)
tm = tm1638.TM1638(stb=Pin(2), clk=Pin(3), dio=Pin(6))
ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))
roms = ds_sensor.scan()
print('Found a ds18x20 device:',roms)
while True:
  ds_sensor.convert_temp()
  time.sleep_ms(750)
  for rom in roms:
    print(ds_sensor.read_temp(rom))
    t=str(ds_sensor.read_temp(rom))
    tm.show(t)
  #time.sleep(2)
Note: In Thonny shell refresh time for temperature is ok

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: TM1638 display work with delay

Post by pythoncoder » Fri Mar 19, 2021 9:17 am

I think you need to convert the temperature to a number and use tm.number() rather than tm.show(). I would start by outputting temperatures at the REPL using print(), then outputting to the display with tm.number().
Peter Hinch
Index to my micropython libraries.

Post Reply