class DS18X20 - ds18x20 series temperature sensor


from ezblock import Pin, DS18X20

pin = Pin("D0")             # create pin object
ds = DS18X20(pin)           # create an DS18X20 object with PWM object               # read temperature in celsius(1)                  # read temperature in Fahrenheit(0)

Raspberry Pi only have one one-wire pin “D7”. While Leaf works with almost every digital pins.


class ezblock.DS18X20(pin) Create an DS18X20 object associated with the given pin object. This allows you to then read temperature from DS18X20.


  • - read temperature with the giving unit. it returns a float if only one ds18x20 is connected to the pin, or it will return a list of all sensor values.
  • DS18X20.scan - Scan the ds18x20(s) connected to the pin, returns a list of roms address

  • DS18X20.read_temp - Read temperature(s) with the givving rom(s)



  • DS18X20.C - Celsius

  • DS18X20.F - Fahrenheit