Page 1 of 1

TM1638 display work with delay

Posted: Wed Mar 17, 2021 2:40 pm
by mishu_g
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

Re: TM1638 display work with delay

Posted: Fri Mar 19, 2021 9:17 am
by pythoncoder
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().