Open ghost opened 8 years ago
How does this work? I have the plugin installed on my Homebridge pi server, and I can get the Accessory to show up in Home/HomeKit on my iphone, but there is no temp reading. Am I missing some arduino code or pi code? where do I hook the sensor to? what is the other half of this piece? Also, how do I format the device ID address? ie "device": "28-0000063f4ead" does not equal " 0x28, 0x4D, 0xAA, 0xCB, 0x04, 0x00, 0x00, 0x9C" thanks
In regards to usage
You need to find the sensor ID, you can run the following command after loading the kernel modules
ls /sys/bus/w1/devices/
If you don't have the modules loaded you'll have to run this before running this plugin
sudo modprobe w1-gpio
sudo modprobe w1-therm
As far as the plugin reporting 0 degress... what does it say if you try to run cat on the file w1_slave located in /sys/bus/w1/devices/*
duh, obviously i need to connect the sensor directly to my pi/homebridge server. I guess i was thinking it would magically report from my arduino running homebridge-http plugin. I will work on that and get back to you, thanks
If you want something for handling remote temperature sensors you can use https://github.com/lucacri/homebridge-http-temperature-humidity
That works very nicely... if you only have a DS18B20 just set humidity = false in the homebridge config
If you want something super cheap for scattering temperature sensors around the house I would give the NodeMCU a try... it's a cheap Wi-Fi board that can be programmed with the Arduino IDE
And another positive about that board is that there are internal pull-up resistors so you don't even need them for the DS18B20 sensor (well, I've tried it with a single one-wire device connected... more may not work...)
wow, thanks man, I am now getting temp in F using a ds18b20 on an arduino, and it shows up in Home/Homekit over my homebridge pi server. I just cant get the Temp value to show correct, but i faked the Hudity value of the plugin and its working correctly under the other accessory, so I know it can work
Thanks for your direction man
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 201 }; // ip in lan byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(80); //server port
String readString;
/-----( Declare Constants )-----/
/-----( Declare objects )-----/ /* Set up a oneWire instance to communicate with any OneWire device*/ OneWire ourWire(ONE_WIRE_BUS);
/* Tell Dallas Temperature Library to use oneWire Library */ DallasTemperature sensors(&ourWire);
/-----( Declare Variables )-----/
//////////////////////
void setup(){
pinMode(5, OUTPUT); //pin selected to control //start Ethernet Ethernet.begin(mac, ip, gateway, gateway, subnet); server.begin(); //enable serial data print Serial.begin(9600);
sensors.begin();
}
void loop(){
float temperatureIndoor; float temperatureOutdoor; delay(10); // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
/* Serial.println(readString); //print to serial monitor for debuging
client.println("HTTP/1.1 200 OK"); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>Simple Arduino button</H1>");
client.println("<a href=\"/?on\">ON</a>");
client.println("<a href=\"/?off\">OFF</a>");
client.println("<a href=\"/?temp\">temp</a>");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
*/
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: application/json;charset=utf-8");
client.println("Server: Arduino");
client.println("Connnection: close");
client.println();
sensors.requestTemperatures(); // Send the command to get temperatures
temperatureIndoor = (sensors.getTempFByIndex(0));
temperatureOutdoor = (sensors.getTempFByIndex(0));
client.print("{\"temperature\":");
client.print(temperatureIndoor);
client.print(",");
client.print("\"humidity\":");
client.print(temperatureOutdoor);
client.print("}");
client.println();
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf("?on") >0)//checks for on
{
Serial.println(readString.indexOf("on"));
digitalWrite(5, HIGH); // set pin 5 high
Serial.println("Led On");
}
if(readString.indexOf("?off") >0)//checks for off
{
Serial.println(readString.indexOf("off"));
digitalWrite(5, LOW); // set pin 5 low
Serial.println("Led Off");
}
if(readString.indexOf("?temp") >0)//checks for off
{
Serial.println(readString.indexOf("temp"));
//digitalWrite(5, LOW); // set pin 5 low
Serial.println("temp sent");
}
//clearing string for next read
readString="";
sensors.requestTemperatures(); // Send the command to get temperatures Serial.print("Device 1 (index 0) = "); Serial.print(sensors.getTempFByIndex(0)); Serial.println(" Degrees F");
}
}
}
} }
ah "if you only have a DS18B20 just set humidity = false", duh, thanks again
thanks man, got the HomeKit Accessory Room Temp thing value to work correctly by changing the value to get celcius instead: temperatureIndoor = (sensors.getTempCByIndex(0)); using https://github.com/lucacri/homebridge-http-temperature-humidity and your suggestions
Also just wanted to confirm, that your plugin works nicely on my setup. Just connected simply the DS18B20+ sensor to my Pi (which is the Homebridge) and shows the temperature in HomeKit as it should. Brilliant! Many thanks!
@Pistooli how you setup your DS18B20 on your PI? and how config? i want use DS18B20 waterproof sensor in my pool. https://www.amazon.com/dp/B00KLZQ0P8/_encoding=UTF8?coliid=I1I08Y9WAHJ21C&colid=2C3RKYX98VWKZ
how this homebridge know what pin I'm using for DS18B20?
you connect it to a GPIO pin. I believe the homebridge plugin uses I2C and just scans the bus for devices
https://www.modmypi.com/blog/ds18b20-one-wire-digital-temperature-sensor-and-the-raspberry-pi
@lagunacomputer thanks! i will buy the sensor and give a try!!!
Hello, I have already installed the Plugin but i get 0 degrees. When i read manually the values of the Sensor i get 23 degrees. I use already the right Sensor id. Any ideas? I use i2c Bus for the Connection to the Sensor