View Full Version : pH & Temp Logging on PC

11/20/2007, 07:11 PM
What is cheapest way to log pH and Temp in an ODBC database on a PC?

Anyone using X10? (0-100% dimming = Temp or pH ranges) ?

11/21/2007, 10:31 AM
IMHO, Dallas 1-wire devices (http://www.maxim-ic.com/products/1-wire/) would the the cheapest and easiest. Sounds like you have a PC already and your favorite database.

First, you'd need a USB 1-wire adapter (http://www.hobby-boards.com/catalog/product_info.php?cPath=23&products_id=1503).

A 1-wire temp sensor (http://www.hobby-boards.com/catalog/product_info.php?cPath=26&products_id=93) encased in something waterproof, like epoxy. Sensors are cheap, so add as many as you want. I even have sensors in my MH ballasts, in case they overheat.

You would of course need a pH probe. A pH transmitter would be needed to read the probe and convert it to a voltage that can be read by a 1-wire A/D converter (http://www.hobby-boards.com/catalog/product_info.php?cPath=26&products_id=99). The pH transmitter would need to output a 4-20ma loop. Google will yield lots of information on 4-20ma loops. It's a standard for industrial controls. You can find pH transmitters on eBay pretty cheap. I got one for $25. Even brand new one can be had for around $80.

Some CAT-5 cable can be used to connect the sensors to the USB adapter.

You will then need to choose which 1-wire API (http://www.maxim-ic.com/products/ibutton/software/resources.cfm) to use to get the data. If you are just reading the sensors, then the java API and some batch files would work. You can use a java program if you want to get slick. The pH would need a bit more calculation. A point-slope formula would need to be used to derive the pH, based on the voltage of the probe on a pH 7 and voltage at pH 10 calibration fluid, and of course the current voltage.

There may be cheaper ways, but they would probably take much longer to do.

As far as X10, I have it but would never use it for my reef. I don't think it's reliable enough, but some people do swear by it.

11/22/2007, 01:58 PM
- Does anyone have wiring diagrams to show how to construct everything?

- How do you connect the temp and (pH->A/D Converter) to RJ-45?

- How far can you run the RJ-45 (signal loss)?

- Do I need a seperate USB 1-wire adapter for each sensor (ph & Temp)?

- Does anyone have a program already that runs on Windows and logs data into a SQL Server (ODBC) database?

I am pretty handy with soldering, data networking, and general automation, but my programming skills are a bit lacking these days. Any help would be GREATLY appreciated.

11/22/2007, 03:16 PM
HobbyBoards has a good How To (http://www.hobby-boards.com/catalog/howto_contents.php?osCsid=b63d998374684aff00e915c51fb3962e) section on their site. It should answer all your questions on topology and connections and such.

The 1-wire Java API (http://www.maxim-ic.com/products/ibutton/software/1wire/1wire_api.cfm) provides lots of samples. I'm sure the other other APIs has samples too. The other option is to use the OWFS (http://owfs.sourceforge.net/), which will let you access the data as if it was text files in the file system. It only runs on Linux however. Getting the data into a database would depend on the database. I'm not a SQL expert, but I suspect most would allow adding rows from a command line. You should be able to modify the samples to output the data into a format that can be imported into the database. I've never tried it this way myself, as I do everything within Java and use JDBC to access the database.

I would offer up my code, but what I have is a bit complicated right now and not quite ready for public consumption.

There are a lot of ways to do this in software. Research the options and pick the path of least resistance for you. All will require some programming, whether it's Java, .NET, C, batch files, or shell scripts. Sounds like a good opportunity to brush up on those programming skills :)

11/24/2007, 07:49 AM

I have been reading your posts on the Linksys Router Hack forum and have a question about the Hobby Board HVAC Monitor modification to read the 0-5VDC input from a pH Probe. Did Hobby Board make the necessary changes to the board's sensitivity or did you have to do something after you got the board?

I am planning on ordering:
1- Temperature Kit (Hobby Board: TS-R1-K)
1- Power Injector Kit (Hobby Board: PI1-R1-K)
1- HVAC Monitor (Hobby Board: HVAC2-R1-A)
1- 1-Wire USB Adapter (Hobby Board: DS9490R-A)
1- pH Probe (Ebay ??)

I am going to build the Temperature Kit with the temp sensor on a long lead and coated in epoxy so I can put it into the aquarium.

11/24/2007, 09:21 AM
HobbyBoards did make the change for me. All they did was remove the resistors and bridge the gaps with a piece of wire. The board won't read the pH probe directly. You will need a pH transmitter with 4-20 ma output. This will convert the high impedance signal from the pH probe into a voltage range that can be read by a A/D converter like the DS2450. The DS2450 will read the 4-20ma loop voltage. I found this (http://www.processautomationcontrol.com/download/4-20mA-Current-Loop-Primer.pdf) with a quick Google search on 4-20ma loop circuit. The trick is to use the right size resistor in the loop based on the voltage supplied to the circuit that will yield a voltage between 0 and 2.5 for the DS2450 to read. The DS2450 can read 0 - 5 volts, but at a much less resolution. The swing of the pH transmitter (at least my cheap one) is less than 2.5 volts, so it's better to use the higher resolution mode. The pH transmitter I got included a span adjustment, so I didn't have to mess with the different resistors to adjust the range to be within 0-2.5 volts. Also, the DS2450 has 4 channels, so you can have multiple pH/ORP probes. I got my pH probe from one of the online reef stores. I think it's a Neptune probe. You'll also need the pH7 and pH10 calibration fluids.

Here is the slope formula I used to get the pH, based on the voltages at ph7 and ph10.

slope = (ph10 - ph7) / 3
pH = 7 + ((voltage - ph7) / slope)

I just found a pH/ORP transmitter on ebay for $45.50 (I'm adding a ORP probe to my system). Unlike the first one I got, this one has an LCD screen.

11/24/2007, 09:28 AM
You don't need to buy the Temperature Kit. Just get the sensor and solder it to the end of a CAT5 cable. Get a few, they are cheap.

11/26/2007, 08:34 PM
What is a good epoxy to use to encase the temp sensor?

11/27/2007, 05:26 PM
I used a 2 part epoxy from Home Depot, the kind in the double syringe. After I soldered the sensor to the cable and used small heat shrink tubes to seal and insulate them. Then I sealed the gap between the leads with silicone. Then I slid a heat shrink tube over the cable and just barely over the bottom of the sensor. For a mold, I drilled a hole between 2 pieces of 2x4. Then I made a big mistake and just filled the hole with the 2 part and shoved the sensor on in, so the epoxy covers the sensor and some of the cable. Had a heck of a time separating the 2x4s though. Eventually I did and scraped the wood off the hardened epoxy:rolleyes: Next time I'll use some kind of release agent, or spend some more time removing the stuck on wood. I did this almost 2 years ago. It's still in my tank.

12/01/2007, 11:46 AM
WOW that was easy. I wired up an 18S20 Temp sensor to some CAT6 and the USB Adapter. I am running Wserver that I got from http://www.henriksens.net/1-wire. Very Very easy.

Now I just need to get the ph transmitter/controller and wire up the A-D converter and 1-wire interface.

12/01/2007, 05:35 PM
Cool! Glad you got it working.

I find the Java based OneWireViewer (http://www.maxim-ic.com/products/ibutton/software/1wire/OneWireViewer.cfm) a very good way to test the network of devices. It can display almost all the properties of the devices and it's easy to use. No need for a web server. Until I add the routines to the controller, I use the viewer to read the voltages of the pH7 and pH10 calibration points, then I save them as constants to the database.

01/10/2008, 09:30 PM
when doing this can you use any router or hub if I have an extra laying around.... Or is there something special about the one they offer that I would need to get that?

If you do this correctly couldnt you intern write a software program and use this as a tank monitor instead of buying a 400 dollar tank controller?

01/11/2008, 05:12 AM
<a href=showthread.php?s=&postid=11572034#post11572034 target=_blank>Originally posted</a> by gguertin
when doing this can you use any router or hub if I have an extra laying around.... Or is there something special about the one they offer that I would need to get that?/QUOTE]

You can't use an Ethernet hub for the 1-wire network. Very different protocols. For just a few 1-wire devices, a hub isn't really necessary.

[QUOTE]If you do this correctly couldnt you intern write a software program and use this as a tank monitor instead of buying a 400 dollar tank controller?

Yes, one could, and many have. For monitoring, there is no risk really. If you want it to control various functions, then you have to be much more careful in how you design it. Lots can go wrong if you aren't careful.

01/11/2008, 07:39 AM
can you explain some of these risks or point me to a thread that has done this?

I am torn on buying one or making one... If one can be made affordably since I have a few computers lying around doing nothing that would be nice.. if it ends up the same it wouldnt be worth it..

01/11/2008, 05:19 PM
I don't have any of the threads bookmarked. A Google (http://www.google.com/search?aq=-1&oq=&complete=1&hl=en&q=diy+controller+site%3Awww.reefcentral.com&btnG=Search) search should net some results to start with.

Like I said, monitoring is no risk at all. When you start controlling things like heaters and sump top-off is where the risk comes in. You have to decide how much risk you can live with. PCs are less reliable than something like a PLC. There is a lot more going on within the PC OS and hardware. Sure, a PC can run for months without a crash or reboot, especially if it's not doing anything. What happens if the OS crashes while the heater is on, or the sump is being topped off? Or the controller process itself dies? The more you control, the more things can go wrong. Basically it's all about risk management.
You can alleviate some risk by having fail safes outside the controller, like a heater set to 2 degrees higher than your set point plugged into the controller and a second heater not controlled by the controller set a couple degrees lower than your set point. A high level float switch could shut off your auto top-off in case the controller doesn't shut it down. Lights aren't so much of a big deal if they are left on or off for a day or so, but if you are on vacation for a week or so it could be. If the controller does die, how would you know?

Whatever you do, you'd have to think about failures and what effect they would have. Even if you don't have a controller and add water to the sump manually, one failure could be one's memory.

Building a controller is more of a hobby project than a way to save a few bucks. Of course in the end you'd have a controller that does exactly what you want, assuming it works the way you intended.