Author |
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: January 28 2007 at 13:32 | IP Logged
|
|
|
Hello. I was just looking at a 5+ year old Radioshack weather station that I have lying around, and I realized that it has a serial port output. That indicates to me that it could potentially be connected to the computer and used to pass data to Powerhome. Googling it, I found this page on people the program with it: http://wx200.planetfall.com/
I don't really know how to do that kind of programming--based on the stuff they've got on that page, can anyone give me some tips as to how to write a program that will take data from the station and pass it to global variables in PH?
Thanks
Tom
|
Back to Top |
|
|
onhiatus Senior Member
Joined: May 12 2004 Location: United States
Online Status: Offline Posts: 279
|
Posted: January 29 2007 at 15:30 | IP Logged
|
|
|
It seems like the author of that web page had a partially complete vb app. If you could get the source code it's pretty easy to have a vb app send a windows message to power home.
I use a vbapp to read temperatures from arround my house and transfer them to powerhome this way.
It is also should not be that difficult to write a ph macro that reads directly from the serial port - do a search on "caller id" on this board and you should find some examples.
Good luck, be brave...
Tony
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: January 29 2007 at 20:36 | IP Logged
|
|
|
Ok, so I took a look at the caller id script, and I'm trying to get data from the weather station using something similar.
What I have is a macro called GET which does:
Formula | Post | ph_comopen( 4, 1, 9600, "N", 8, 1, 1, 0, 0, 1, 0, 1, 1, "?", "WEATHER" )
Then there is a macro WEATHER that does:
Set System | [LOCAL 1] | ph_comrecvchar( 4 )
Set Global | DATA | string("[LOCAL1]")
When I run GET, I want it to get whatever it can from the weather station (on COM 1), and stick it into DATA so that I know what I'm working with. However, when I run the script, DATA just gets set to 0.
Is there something wrong with the way I have this set up? Do I have to make changes to the stuff in the parenthesis for phcomopen?
Thanks
Tom
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: January 29 2007 at 21:27 | IP Logged
|
|
|
Ok, revision. I realized that I forgot the
Formula | Post | ph_comsendstring( 4, "at#cid=1\013" )
in the GET macro.
When I add that in and run the macro, DATA becomes 207. I'm assuming that I need to send something else in order to get the correct response, but I don't know enough about serial ports to know how to do that.
Here's a link to the protocal for the station: http://wx200.planetfall.com/wx200.txt
Suppose I wanted to get the inside temperature--would I have to put something else inside consendstring? If so, any idea what? Or is this an entirely different issue?
Thanks
Tom
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 30 2007 at 00:29 | IP Logged
|
|
|
You don't want the "at" stuff, that's for a modem.
Remember that ph_comrecvchar gets just one character, or byte, at a time, so you'll need to set up a loop to grab them, add them to a variable, then get ready to get some more.
This kinda gets complicated...
It looks like you'll be getting blocks of bytes every 5 and 10 seconds. Inside Temp would be in the second block, 9F, which is 34 bytes long. From that block, you'll only need the first two bytes.
9F. 1 DD all Temp Indoor: 'bc' of 0<ab.c<50 degrees C @ 0.1
9F. 2 Dx all Temp Indoor Hi: 'c' of <ab.c> C
9F. 2 xB 0-2 Temp Indoor: 'a' of <ab.c> C
9F. 2 xB 3 Temp Indoor: Sign 0=+, 1=-
So, if the internal temp was 69.0°F (20.5°C), that portion would look like, "9F 05 x2".
I'm getting too tired to think clearly. Will continue later!
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: January 30 2007 at 18:38 | IP Logged
|
|
|
Thanks for taking a look at that--it sounds like there will be a lot of steps involved in getting meaningful information with the direct serial connection route.
Luckily, I think there's an easier way. I was surfing around and I found a program called SB Weather that reads data from the wx200 and exports it as a comma seperated text file. I'm sure there's some easy way to grab that data using strings and whatnot and display it in PH.
However, here's the thing. SB Weather worked great on my normal computer, but when I tried to connect it to the dedicated HA computer, it would show an error whenever I ran PH. I think the problem is that I use a Firecracker cm17a, which connects to the serial port. The Firecracker is on COM1, and the WX200 is on COM2, a usb to serial adapter. Whenever I launch both programs at once, one or the other shows a COM error.
Even though the devices are on different ports, is there some way that they could conflict? If so, is there a fix (switching to a different serial controller or something)? Or do I finally have to cough up the money for a USB x10 controller?
Any help appreciated
Thanks
Tom
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: January 30 2007 at 22:29 | IP Logged
|
|
|
There should only be a conflict if they are set to the same port.
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: February 01 2007 at 16:17 | IP Logged
|
|
|
Alright, it's working! I ended up changing the port for the Firecracker and then changing it back, and for some reason that did the trick. I've got it set to import data from the station into a global variable every time I run a macro.
One little thing...how do I set it to trigger the macro every 5 minutes? I want it to perform actions if the temperature reaches a certain level, but I'm not sure how to get it to check with the station more than once per hour.
Thanks
Tom
|
Back to Top |
|
|
Viper Groupie
Joined: January 14 2007 Location: United States
Online Status: Offline Posts: 88
|
Posted: February 01 2007 at 17:20 | IP Logged
|
|
|
Several possibilities. Create a one time event for 5 minutes in the future to call the macro from within the macro. Or put a loop in the macro with a Wait for 300 seconds.
Edited by Viper - February 01 2007 at 17:21
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 01 2007 at 18:54 | IP Logged
|
|
|
If you put 5 as the frequency of a Timed Event, it means 5 minutes.
|
Back to Top |
|
|
Tomcat7194 Newbie
Joined: November 05 2006
Online Status: Offline Posts: 24
|
Posted: February 04 2007 at 15:37 | IP Logged
|
|
|
That works, it's updating reliably. Thanks for your help guys! :)
Tom
|
Back to Top |
|
|