Discard first DS18B12 measurement on ESP
Looks a bit like it's in fahrenheit, but it is definitely messing up my graphs!
This commit is contained in:
parent
36e033e0f7
commit
34f35cf13a
|
@ -18,11 +18,18 @@ class DS18B20(Sensor):
|
||||||
self.o = onewire.OneWire(machine.Pin(self.pin))
|
self.o = onewire.OneWire(machine.Pin(self.pin))
|
||||||
self.ds = ds18x20.DS18X20(self.o)
|
self.ds = ds18x20.DS18X20(self.o)
|
||||||
self.sID = self.ds.scan()[0]
|
self.sID = self.ds.scan()[0]
|
||||||
|
self._first_measurement = True
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
self.ds.convert_temp()
|
self.ds.convert_temp()
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
return {"temp": self.ds.read_temp(self.sID)}
|
val = self.ds.read_temp(self.sID)
|
||||||
|
if self._first_measurement:
|
||||||
|
if val > 70.0:
|
||||||
|
val = None
|
||||||
|
else:
|
||||||
|
self._first_measurement = False
|
||||||
|
return {"temp": val}
|
||||||
|
|
||||||
|
|
||||||
@sensor
|
@sensor
|
||||||
|
|
Loading…
Reference in New Issue