Showing posts with label 1wire. Show all posts
Showing posts with label 1wire. Show all posts

Saturday, July 19, 2008

1Wire Serial Adapter Hates EdgePort

Since I've had the 1Wire network running, I've encountered a few fatal system errors that caused an immediate reboot of my HA server. Digging in the Event Viewer, I found messages like this:

Error code 00000044, parameter1 89422548, parameter2 00000d63, parameter3 00000000, parameter4 00000000.

I Googled a bit and found that error code corresponds to a memory problem or a driver issue. I stumbled upon a thread that told about how to read minidump files created by crashes. The dump file pointed to the EdgePort and the most likely culprit was a Java application. That points to the 1Wire stuff since its OWAPI is based on Java and the DS9097U adapter is plugged into the EdgePort.

Rather than take the easy way and move the 1Wire to the motherboard's built in serial port, I decided to write a VB.net app to talk to 1Wire adapter using the TMEX API. This way, I could avoid using all of the convoluted Java/J# crap. The problem with this path is there wasn't a VB example to get the temps, but there was a Delphi example. Ugh. Finally, I managed to cobble the Delphi and VB sample code into one VB.net program to connect to the 1Wire network and read the temperatures. About 7 hours after deploying that, I got another fatal pointing to the EdgePort. Guess it's not the Java part of the 1Wire after all.

So I connected the DS9097U to the onboard serial port and moved the TC+ to the EdgePort. It's been 12 hours without a fatal reboot. Hopefully, this solves the problem.

Update: It's been over 3 days since I moved the DS9097U and there have been no crashes since. Yay!

Thursday, July 17, 2008

Noisy 1Wire Readings

Of the 8 sensors I installed, the last one on the chain fluctuates a little between readings. It's not bad, just not as accurate as the other 7 sensors. What's different about this one?

It's at the end of the 1Wire line - could there be signal issues? I originally wanted to create my 1Wire network in a star pattern as that would be the easiest to wire from the patch panel, but the 1Wire docs advised against it. So I ran the network as 1 giant wire with each sensor as a stub. I actually used 4 wires to run them (voltage and ground since I decided against powering them parasitically and a wire for network in and network out). I chose this method to control the length of the stubs - otherwise the stub length would be the wire distance from the patch panel to wherever the sensor is located, which would vary for each location as each Cat-5 run is some different, unknown length. This, of course, increases the network length, but should be well within the 700 meter limit.

The sensor is also the only one outside. It's installed sticking out of the wall of our enclosed porch. It was exposed, but after seeing the fluctuations, I covered it up with electrical tape. It still fluctuates. I tucked it behind the porch speaker. It still fluctuates. I'm not sure what else to try at this point. Maybe that's the way it is outside?



Here's an RRD graph of the master bedroom temperature vs. the outside temperature. Starting Wednesday evening, after I got all the graphing and data gathering correctly set up, you can see the very smooth curve for the master bedroom sensor. The outdoor sensor, however, has fluctuations, on the order of a degree or more at times. The readings are accurate - they just don't make for a pretty picture.

Wednesday, July 16, 2008

1Wire Installation Completed

I put in the final four sensors Monday night and started trying to integrate things into the system. I decided to have the temps dumped into mySQL and all other applications can get the temps for there. For now, I've modified the GetTemps.js jscript sample from the 1Wire SDK to poll the sensors, update their values in mySQL and then sleep for 5 minutes.

My next step is getting the temps into the TimeCommander+ since it controls HVAC. The TC+ previously relied on the LM34 sensors connected directly to its analog inputs, so it directly knew the temperatures around the house. With 1Wire, I had to create variables in the TC+ for the temperatures it needs and have starCOMUltra periodically update them.

Finally, I had to update my RRD scripts for graphing temps. Since the 1Wire temps are digital values, there's no need to do any smoothing or error checking that I occasionally had to do with the analog LM34s. Once I had the RRD scripts up and running, I was able to see how nice 0.1 degree accuracy looks. I happened to have 2 DS18B20s, while the others were different flavors of DS18S20s. The rooms with the more accurate DS18B20s had much smoother curves compared to the DS18S20s with their 0.5 degree accuracy. I discovered, though, that you can calculate more accurate values using extra data bits stored in the device. I just added that code to my script and set it off running.

Monday, July 14, 2008

1Wire Deployment

The last few days, I started deploying 1Wire temperature sensors around the house. I've had the serial port interface and a bunch of DS18S20 sensors lying around for a while but I never got around to installing them. Our current system uses LM34 sensors hooked to the analog inputs of the JDS TimeCommander+, but they only have 2 degree accuracy and I've lived with that for 10+ years. Since I've been on my automation surge of late, I figured it was time to install the 1Wire stuff.

I tried putting the serial interface on an EdgePort at the end of the extended USB run in the garage, but for whatever reasons, the PC was unable to communicate consistently with it. It ended up back in the office, near the HA server. I decided I was going to gradually phase them in, which meant leaving the LM34s wired and running, while I tested out 1Wire. This made me clear out more wires in the wiring closet, at least temporarily, until I can shut down the LM34s. While I was cleaning that up, I decided to map out every wire in each of the 15 Cat-5 cables connected to the patch panel. (When we bought the house in 1999, 15 runs of Cat-5 seemed plenty. Now, I know better... *sigh*). I was able to free up some extra wires everywhere I needed them.

After the cleaning and mapping was done, I had time to solder and wire up 4 sensors - the living room, the master bedroom, the office and our daughter's room. There's still our son's room, the family room, the garage and outside left to do. If there's extra sensors, and I'm feeling adventurous drilling holes and running wire, I may try putting one in the attic.

Installing the 1Wire software wasn't as easy as the wiring. The 1Wire API, OWAPI, is some Java stuff and it relied on the Microsoft JVM, which they are no longer allowed to distribute. Anyway, after digging around the 'Net and iterating on the install process, I was able to get OWAPI operational. I had planned to integrate this all into starCOMUltra, but there's so much lag polling the sensors, I'm probably going to write a separate app to poll the sensors. I'm leaning toward making it directly interface it to sCU instead of using xPL as an intermediate step.