Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no Temperature value #4

Open
ghost opened this issue May 8, 2016 · 12 comments
Open

no Temperature value #4

ghost opened this issue May 8, 2016 · 12 comments

Comments

@ghost
Copy link

ghost commented May 8, 2016

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

@lagunacomputer
Copy link

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

@DanTheMan827
Copy link
Owner

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/*

@lagunacomputer
Copy link

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

@DanTheMan827
Copy link
Owner

DanTheMan827 commented Sep 18, 2016

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...)

@lagunacomputer
Copy link

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

#include <SPI.h>
#include <Ethernet.h>

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;

#include <OneWire.h>
#include <DallasTemperature.h>

/-----( Declare Constants )-----/
#define ONE_WIRE_BUS 2 /-(Connect to Pin 2 )-/

/-----( 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");

    }
  }
}

}
}

@lagunacomputer
Copy link

ah "if you only have a DS18B20 just set humidity = false", duh, thanks again

@lagunacomputer
Copy link

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

@Pistooli
Copy link

Pistooli commented Dec 28, 2016

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!

homebridge - ds18b20 sensor connected to pi

@toshibochan
Copy link

@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

@toshibochan
Copy link

how this homebridge know what pin I'm using for DS18B20?

@lagunacomputer
Copy link

@toshibochan
Copy link

@lagunacomputer thanks! i will buy the sensor and give a try!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants