Jeenode+DS18B20+Homeseer

All about Arduino, Jeenode and other Clones (hardware & Software)

Moderator: Mdamen

lulu2607
Starting Member
Starting Member
Posts: 4
Joined: Fri Aug 06, 2010 6:50 pm

Jeenode+DS18B20+Homeseer

Post by lulu2607 »

Hi,
As this is my first post I want to begin by saying "Hello" and a big "THANK YOU" to the entire community!

Just ordered my Jeenode+Jeelink and intend to use them mostly for reading temperature and control 1-2 relays.
For the temperature reading I want to use DS18B20 .
I've read about different sketches (4 digital inputs, 1 input+1output) used to integrate the Jeenodes with homeseer but could not find any references about using 1 wire temp sensors with Jeenode+Homeseer.
I've read that the maximum number of devices/jeenode in homeseer is 8, not a deal breaker as I can use 2 relays and 6 temp sensors, the problem is naming/creating this devices as all examples using arduiono+1-wire will auto detect the 1-wire devices. There is a work-around to individually name the DS18B20 in jeenode/homeseer? Can someone please help me with an example?
Unfortunately i kinda have a "gift" for making things more complicated that actually are, so hope that my "project description" will make sense to anyone willing to advice/help me.
Thank you!
Iulian
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Jeenode+DS18B20+Homeseer

Post by Digit »

Hi,

You're right, no examples here with the combination of 1-Wire+JeeNode+HomeSeer.
I'll see if I can find some later this evening.
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Jeenode+DS18B20+Homeseer

Post by Digit »

Hi,

Here some pointers to get you going. A while ago I modified a small sketch for reading DS18x20 sensors that I found on the Arduino Playground:

Code: Select all

#include <OneWire.h>

/* DS18S20 Temperature chip i/o */

OneWire  ds(10);  // on pin 10

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
  char buf[20];

  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  if ( !ds.search(addr)) {
    //Serial.print("Read again.\n");
    Serial.println("");
    ds.reset_search();
    delay(1000);
    return;
  }
  
  Serial.print("Addr:");
  for( i = 0; i < 8; i++) {
    Serial.print(addr[i], HEX);
    Serial.print(" ");
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.print("CRC is not valid!\n");
      return;
  }
  
  if ( addr[0] != 0x10) {
      Serial.print("Device is not a DS18S20 family device.\n");
      return;
  }

  // The DallasTemperature library can do all this work for you!

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
  
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

//  Serial.print("SP=");
//  Serial.print(present,HEX);
//  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
//    Serial.print(data[i], HEX);
//    Serial.print(" ");
  }
//  Serial.print(" CRC=");
//  Serial.println( OneWire::crc8( data, 8), HEX);
  
  // erin
  
  LowByte = data[0];
  HighByte = data[1];
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  // ds18B20
  //Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
  
  //ds1820
  Tc_100 = (TReading*100/2); 

  Whole = Tc_100 / 100;  // separate off the whole and fractional portions
  Fract = Tc_100 % 100;


  //sprintf(buf, "%c%d.%d\337C     ",SignBit ? '-' : '+', Whole, Fract < 10 ? 0 : Fract);

  Serial.print(" Temp=");

  if (SignBit) // If its negative
  {
     Serial.print("-");
  }
  Serial.print(Whole);
  Serial.print(".");
  if (Fract < 10)
  {
     Serial.print("0");
  }
  Serial.print(Fract);

  Serial.println(" grC");

  
  //Serial.println();
}
This sketch belongs to this post: http://blog.hekkers.net/2010/08/07/addi ... mperature/
As you can see on the picture, I'm using a single 1-Wire bus to read the temperature of 3 sensors. More can be added though on that single bus!
That's what 1-Wire is about; you could also define multiple 1-Wire buses all with just a single sensor on it. Maybe that's easier to do. Also mind the difference of temperature calculation with DS18S20 and DS18B20!

If I were you I would start with trying out this code and rewriting it, cause what you'll probably need to do is map an id to a specific sensor with a specific 8-byte (64-bit) address. How? There are too many solutions (even without creating multiple 1-Wire buses as mentioned above); find the one that fits you best :)

Once you've managed that, the next step is some smart copy/pasting into the JeeNode for Homeseer sketches you can find over here.

And if you run into trouble, maybe we can help.. :D
lulu2607
Starting Member
Starting Member
Posts: 4
Joined: Fri Aug 06, 2010 6:50 pm

Re: Jeenode+DS18B20+Homeseer

Post by lulu2607 »

Hi,
I want to thank you for help and prompt reply.
Unfortunately, after the joy of receiving my "toys" (Friday), now I'm on hold again as my USB-BUB is unable to upload sketches or power my Jeenode.( http://forum.jeelabs.net/node/88 )

Also Jean helped me to locate the rooms.pde he used with 1wire sensors:
jeelabs.net/projects/jeemon2010/reposit ... /rooms.pde
Hope to start some testing soon (another week of waiting :( ).
lulu2607
Starting Member
Starting Member
Posts: 4
Joined: Fri Aug 06, 2010 6:50 pm

Homeseer Jeenode Thermostat

Post by lulu2607 »

Hi,
Waiting for my 1wire sensors and having my Jeenode up and running started to write a sketch for an independent Jeenode Thermostat with Homeseer integration.
Now, starting is one thing.... getting results..... a different ....
Project requirements:
- 2 thermostat modes: Heat & Cool;
-multiple set points controllable from Homeseer, or at least 2 set points: 17C and 25C (the project is for a greenhouse and this will be the temp. required for night and day);
- a 3C Differential on the thermostat;
- the thermostat should work on Jeenode booting, even if not connected to Homeseer (preferably on heat mode)
I've tried 2 paths:
1. Using condition rules:
-created 4 output devices(day heating, day cooling, night heating, night cooling);
-input devices: Light, Temp, Humidity;
-virtual output device (not mapped to a port on jeenode) - Set Point;
Results:
because condition rules will overwrite each other I've managed only to start the thermostat function, I was unable to find a way to stop the heat/cool when the desired temperature was reached. Maybe something I missing, tried multiple combination, but the last condition will overwrite results for the previous so the heatin/cooling function will stay either ON or OFF depending on the last condition. I even used 4 outputs just to reduce possibilities to overwrite the decisionrules, but no luck.
This is the decisionrules section: The setpoint is decided depending of the light level (day/night)

Code: Select all

/ HEATING: LED1(dev0)&LED3(dev5); COOLING: LED2(dev1)&LED4(dev7)  
// day heating
  rules[0].numConditions = 3;
  rules[0].numTrues = 3;
  rules[0].numFalses = 3;
  rules[0].conditions[0].device = 2; // if is day
  rules[0].conditions[0].sign = LT;
  rules[0].conditions[0].value = 45;
  rules[0].resultsTrue[0].device = 0; // led1 heat 
  rules[0].resultsTrue[0].value = 1; //is on
  rules[0].resultsFalse[0].device = 0; //led1 heat
  rules[0].resultsFalse[0].value = 0; // is off
  rules[0].conditions[1].device = 6; //and tstat on heating
  rules[0].conditions[1].sign = EQ;
  rules[0].conditions[1].value = 0;
  rules[0].resultsTrue[1].device = 0; // led1 heat
  rules[0].resultsTrue[1].value = 1;  //is on
  rules[0].resultsFalse[1].device = 0; //led1 heat
  rules[0].resultsFalse[1].value = 0; // is off
  rules[0].conditions[2].device = 4; // if temperature
  rules[0].conditions[2].sign = LT;
  rules[0].conditions[2].value = 22;
  rules[0].resultsTrue[2].device = 0; // led1 heat 
  rules[0].resultsTrue[2].value = 1; //is on
  rules[0].resultsFalse[2].device = 0; //led1 heat
  rules[0].resultsFalse[2].value = 0; // is off

 //day cooling
  rules[1].numConditions = 3;
  rules[1].numTrues = 3;
  rules[1].numFalses = 3;
  rules[1].conditions[0].device = 2; // if is day
  rules[1].conditions[0].sign = LT;
  rules[1].conditions[0].value = 45;
  rules[1].resultsTrue[0].device = 1; // led2 cool
  rules[1].resultsTrue[0].value = 1; //is on
  rules[1].resultsFalse[0].device = 1; //led2 cool
  rules[1].resultsFalse[0].value = 0; // is off
  rules[1].conditions[1].device = 6; //and tstat on cooling
  rules[1].conditions[1].sign = EQ;
  rules[1].conditions[1].value = 1;
  rules[1].resultsTrue[1].device = 1; // led2 cool
  rules[1].resultsTrue[1].value = 1;  //is on
  rules[1].resultsFalse[1].device = 1; //led2 cool
  rules[1].resultsFalse[1].value = 0; // is off
  rules[1].conditions[2].device = 4; // if temperature
  rules[1].conditions[2].sign = GT;
  rules[1].conditions[2].value = 28;
  rules[1].resultsTrue[2].device = 1; // led2 cool
  rules[1].resultsTrue[2].value = 1; //is on
  rules[1].resultsFalse[2].device = 1; //led2 cool
  rules[1].resultsFalse[2].value = 0; // is off 
  
  //night cooling
  rules[2].numConditions = 3;
  rules[2].numTrues = 3;
  rules[2].numFalses = 3;
  rules[2].conditions[0].device = 2; // if is night
  rules[2].conditions[0].sign = GE;
  rules[2].conditions[0].value = 45;
  rules[2].resultsTrue[0].device = 7; // led4 night cool
  rules[2].resultsTrue[0].value = 1; //is on
  rules[2].resultsFalse[0].device = 7; // led4 night cool
  rules[2].resultsFalse[0].value = 0; // is off
  rules[2].conditions[1].device = 6; //and tstat on cooling
  rules[2].conditions[1].sign = EQ;
  rules[2].conditions[1].value = 1;
  rules[2].resultsTrue[1].device = 7; // led4 night cool
  rules[2].resultsTrue[1].value = 1;  //is on
  rules[2].resultsFalse[1].device = 7; // led4 night cool
  rules[2].resultsFalse[1].value = 0; // is off
  rules[2].conditions[2].device = 4; // if temperature
  rules[2].conditions[2].sign = GT;
  rules[2].conditions[2].value = 19;
  rules[2].resultsTrue[2].device = 7; // led4 night cool
  rules[2].resultsTrue[2].value = 1; //is on
  rules[2].resultsFalse[2].device = 7; //led4 night cool
  rules[2].resultsFalse[2].value = 0; // is off
  
  // night heating
  rules[3].numConditions = 3;
  rules[3].numTrues = 3;
  rules[3].numFalses = 3;
  rules[3].conditions[0].device = 2; // if is night
  rules[3].conditions[0].sign = GE;
  rules[3].conditions[0].value = 45;
  rules[3].resultsTrue[0].device = 5; // led3 night heating 
  rules[3].resultsTrue[0].value = 1; //is on
  rules[3].resultsFalse[0].device = 5; // led3 night heating 
  rules[3].resultsFalse[0].value = 0; // is off
  rules[3].conditions[1].device = 6; //and tstat on heating
  rules[3].conditions[1].sign = EQ;
  rules[3].conditions[1].value = 0;
  rules[3].resultsTrue[1].device = 5; // led3 night heating
  rules[3].resultsTrue[1].value = 1;  //is on
  rules[3].resultsFalse[1].device = 5; // led3 night heating
  rules[3].resultsFalse[1].value = 0; // is off
  rules[3].conditions[2].device = 4; // if temperature
  rules[3].conditions[2].sign = LT;
  rules[3].conditions[2].value = 15;
  rules[3].resultsTrue[2].device = 5; // led3 night heating
  rules[3].resultsTrue[2].value = 1; //is on
  rules[3].resultsFalse[2].device = 5; // led3 night heating
  rules[3].resultsFalse[2].value = 0; // is off
  
  // night heating OFF
  rules[4].numConditions = 3;
  rules[4].numTrues = 3;
  rules[4].numFalses = 3;
  rules[4].conditions[0].device = 2; // if is night
  rules[4].conditions[0].sign = GE;
  rules[4].conditions[0].value = 45;
  rules[4].resultsTrue[0].device = 5; // led3 night heating 
  rules[4].resultsTrue[0].value = 1; //is on
  rules[4].resultsFalse[0].device = 5; // led3 night heating 
  rules[4].resultsFalse[0].value = 0; // is off
  rules[4].conditions[1].device = 6; //and tstat on heating
  rules[4].conditions[1].sign = EQ;
  rules[4].conditions[1].value = 0;
  rules[4].resultsTrue[1].device = 5; // led3 night heating
  rules[4].resultsTrue[1].value = 1;  //is on
  rules[4].resultsFalse[1].device = 5; // led3 night heating
  rules[4].resultsFalse[1].value = 0; // is off
  rules[4].conditions[2].device = 4; // if temperature
  rules[4].conditions[2].sign = LT;
  rules[4].conditions[2].value = 15;
  rules[4].resultsTrue[2].device = 5; // led3 night heating
  rules[4].resultsTrue[2].value = 1; //is on
  rules[4].resultsFalse[2].device = 5; // led3 night heating
  rules[4].resultsFalse[2].value = 0; // is off
Like this I was able to start all heating/cool function but no way to stop it.
Decided to change approach and make only a heating mode thermostat using decisionrules: no luck, did not succeed to turn the thermostat both ON an OFF .


2. Using as example this : http://www.ka1kjz.com/?p=797 , tried to add the thermostat to the homeseer_jeenode sketch in order to run as a loop and Homeseer will control only MODE and ON/OFF functions.
I've defined a DIFFERENTIAL of 3(degrees)
In the loop section added the following:

Code: Select all

if (payload.temp > payload.setpt)              // come on at setpoint
  {
    led.digiWrite(1);                // turn on GREEN (cooling)led
    pir_ldr.digiWrite(0);               // turn on RED(HEATING) led
  }
  if (payload.temp < payload.setpt - DIFFERENTIAL)  // is temp at setpoint - differential?
  {
    pir_ldr.digiWrite(0);              // turn off RED(HEATING) led
    led.digiWrite(0);                // turn off GREEN(COOLING) led
    }
This section is for cooling.
What happens is that Homeseer is giving the following error
Error - Running script, script run or compile error in file: jeeNode.txt13:Type mismatch: 'CInt' in line 239 More info: Type mismatch: 'CInt' .
I consider that second method (loop thermostat) may work, but not sure if calling the right variables, what can I use instead of "payload.temp" and "payload.setpt" as I'm not sure this is the right approach ?
Any suggestions, advices , different approaches will be appreciated.

I hope I've made any sense, had a really long day of trial and loads of errors, so not quite sure that I'm still coherent.
Regards,
lulu2607
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by Digit »

Hi,
I think the easiest/quickest way to get results is to give me the complete sketch, so that I can upload it to one of my JeeNodes and have a look at what's going wrong. If you modified anything in the Homeseer script (jeenode.txt) send me that one too.
You can mail it to jeenode at hekkers dot net, I will have a look and report back what had to be changed to get it working.
lulu2607
Starting Member
Starting Member
Posts: 4
Joined: Fri Aug 06, 2010 6:50 pm

Re: Jeenode+DS18B20+Homeseer

Post by lulu2607 »

Thanks!
Already emailed you the sketches. Let me know if you didn't receive them to try send them from another email account.
Regards,
lulu2607
nawikre
Member
Member
Posts: 192
Joined: Wed Jan 27, 2010 10:53 pm
Location: Eibergen
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by nawikre »

any News about this item?

i am also searching a good solution for my sensors.

i want to add a 1-wire ds18 temp sensor to my jeenode. (actually a arduino pro mini with jeenode sketch)

i was hoping to read more in this topic about it....
greetz,

Iwan
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by Digit »

IIRC, lulu2607 managed to read a DS18B20 sensor and get the result in Homeseer.
After that, I don't know.
But...reading a DS18B20 is not that hard; there are lots of examples that can be easily found!
nawikre
Member
Member
Posts: 192
Joined: Wed Jan 27, 2010 10:53 pm
Location: Eibergen
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by nawikre »

is it possible to just copy past the code into the jeenode sketch to et it to work? I am not a programmer so it is not really my area of expertise.

is it possible to put the sketch (jeenode with ds18) online so i can see how it is done...if i know that, then i know how i can make the sketch working if i have just a ldr of just a pir connected to my arduino pro mini.

thanks alot
greetz,

Iwan
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by Digit »

Copy/Paste? Probably not. A JeeNode sketch will almost always use the RF transceiver to send the sensor values, so you will need to have a RF12 transceiver connected to your Arduino Pro; do you? And if not, what are you going to do with the values once you can read a DS18x20?
Another question is: what are you going to use on the receiving side? This all has a lot of impact on how the sketch will have to look like.
nawikre
Member
Member
Posts: 192
Joined: Wed Jan 27, 2010 10:53 pm
Location: Eibergen
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by nawikre »

sorry, the complete info is this.

i have a jeelink (usb) connected to homeseer (and configured)
The arduino pro mini is on it's way and some rfm12b chips. I have the schematics on how to connect the rf12 to the arduino pro mini. AND i can connect the ds18 or other sensor to the arduino (with help of the jeenode schematic).

So i only need to have/make the sketch to get the ds12 to work. As i know that there are jeenodes that work with a ds18.

hope this makes it a bit more understandable what my situation is...sorry for the confusion.
greetz,

Iwan
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by Digit »

Thanks for the additional info.
One thing left... Do you realize "the" DS18 does not exist? It's either a DS18S20 or DS18B20. The DS1820 has been replaced by the software compatible DS18S20. The DS18B20 has 9-12 bit resolution, DS18S20 has a fixed 9 bit resolution. And both have a different family id (10 vs. 28, all of this IIRC) and need to be handled differently in software (=sketch) to calculate the right temperature.
If all this information is new to you, my advice would be to skip this whole exercise. Buy something Plug&Play or spend time learning the basics. It's either time or money, you know...

BTW, completely OT, but now that my memory starts working again... are you the same person that persuaded me to contact mister Nodo in January 2011 for some sort of cooperation? Of whom I have never heard 1 byte after a brief reply saying "I will contact you for a meeting", resulting in complete silence? But where I did read things like "those Jeenode guys will probably not be willing to share stuff with us" on the Nodo Google groups!?
<censored by global forum admin>
What's the story, what have I missed?
nawikre
Member
Member
Posts: 192
Joined: Wed Jan 27, 2010 10:53 pm
Location: Eibergen
Contact:

Re: Jeenode+DS18B20+Homeseer

Post by nawikre »

thanks for the info n the ds18x20 (family). I have a habbit of shortning names that leads to cunfusion sorry. I am taking time to learn this stuf....

About the nodo question. You are right. that was me. I do not know what happend. I think i just forgot completly (very busy with my own company). About the topic about " those jeenode guys......" i must of missed because i do not know about this topic.
What i do know is that the nodo project has a different perspective and direction. The want to combine a couple of things, but want to stick to basics. I would like to have a homeseer plugin, but that stalled a long while ago, because there are just a few that uses homeseer inside that group.

sorry for that, it was not my intension to forget.
greetz,

Iwan
vanisher

Re: Jeenode+DS18B20+Homeseer

Post by vanisher »

I just managed to create a test setup (the first one ever) with a Jeenode and 3x DS18B20 on one bus.

Code: Select all

ROM = 28 D8 E6 93 3 0 0 B0
  Chip = DS18B20
  Data = 1 17 1 4B 46 7F FF 9 10 8E  CRC=8E
  Temperature = 17.44 Celsius, 63.39 Fahrenheit
ROM = 28 4C BE 93 3 0 0 76
  Chip = DS18B20
  Data = 1 17 1 4B 46 7F FF 9 10 8E  CRC=8E
  Temperature = 17.44 Celsius, 63.39 Fahrenheit
ROM = 28 82 A1 93 3 0 0 E9
  Chip = DS18B20
  Data = 1 19 1 4B 46 7F FF 7 10 EB  CRC=EB
  Temperature = 17.56 Celsius, 63.61 Fahrenheit
No more addresses.
Do you have any influence on the order of the DS18B20's readout? The physical location on the breadboard doesn't change the order of readout.
Post Reply

Return to “Raspberry, Arduino, Cubietruck and other clones Forum”