import machine, onewire, ds18x20, time
import re

def truncate(num,decimal_places):  
    dp = str(decimal_places)
    return re.sub(r'^(\d+\.\d{,'+re.escape(dp)+r'})\d*$',r'\1',str(num))
ds_pin = machine.Pin(22)
 
ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))
 
roms = ds_sensor.scan()
"""
'{:0>9}'.format(3.499) 
y=(3.5)
"""
y=(20.37)
while True:
 
  ds_sensor.convert_temp()
 
  time.sleep_ms(750)
 
  for rom in roms:
 
    
 
    h = (ds_sensor.read_temp(rom))
    x = str(h)
    v = (len(x))
    formatted = f"{h:2.1f}"
    print (formatted)
    if h==0:
          print ("is negative")

    
    j= '{:.1f}'.format(y)
    e= '{:0=4}'.format(y)
    print (e)
    print (j*10)
    print ((j))
    print (v)
    print ((str(h)[0:2]))
  time.sleep(5)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT