Closed egraaf closed 9 years ago
This is true! You have a different version of the temperature sensor.
I had the DS18B20
sensor and I did not really care about this SLAVE_PREFIX
.
I guess you have the DS18S20
!
Let us have a look at the kernel module source code of w1*
at: http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/drivers/w1/w1_family.h
You can see on line 32 the sensor you've got and on line 35 the sensor I've got!
I will probably change the name of this module to something like w1sensor and there you can specify the type you have. So then this module can support one of those sensors:
#define W1_THERM_DS18S20 0x10
#define W1_THERM_DS1822 0x22
#define W1_THERM_DS18B20 0x28
Thanks for contributing!
Can you have a look at the new version? And probably give some feedback if it works for you?
I have changed my little Python script to use the new version, and it works for me. I don't know much Python, so this is mostly copy and paste programming ...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import sleep
from w1thermsensor import W1ThermSensor
import paho.mqtt.client as mqtt
def main():
mqttc = mqtt.Client()
mqttc.connect("monitor.egraaf.org")
mqttc.loop_start()
sensor = W1ThermSensor()
while True:
temperature = sensor.get_temperature()
print temperature
mqttc.publish("home/temperature/living", temperature)
sleep(300)
if __name__ == "__main__":
main()
Yes, this works because in the constructor of W1ThermSensor it checks for an available sensor. It does not matter if it is a DS1822, DS18S20 or DS18B20... If you want to intantiate a sensor of a specific type you can define this in the constructor.
I probably have a different version of the DS1820, but it still works with your module once I changed the SLAVE_PREFIX to "10-".
Perhaps you could allow either 28 or 10 as a SLAVE_PREFIX, or mention it in the README.