Author Topic: Lacrosse TX60 temperatute and humidity capture  (Read 1459 times)

0 Members and 1 Guest are viewing this topic.

Offline Flying_Carlos

  • Member
  • *
  • Posts: 8
Lacrosse TX60 temperatute and humidity capture
« on: February 18, 2016, 10:44:41 PM »
I started with this project a long time ago (http://www.wxforum.net/index.php?topic=24882.msg244178#msg244178) but I dropped out and now I think I finished it.

Part of this information I took from the excellent work of SkyDvrz and others at http://www.wxforum.net/index.php?topic=14299.0
My idea was to reproduce in part the work of those guys but using the TX60U thermometer/hygrometer instead of WPS.

First, I registered the Gateway and the TX60U in weahterdirect.com and then I started the analysis of the traffic using the following :
1)Advanced Gateway Setup program (AGSP) , download from http://www.weatherdirect.com/downloads/GatewayAdminInstall.exe
The following  article (http://www.weatherdirect.com/pdfs/help/weatherDirectRegistration.pdf), in the page 20 & 21 explain how to use the AGSP, also in SkyDvrz software there is a detailed explanation of how to setup the proxy.
I redirected the Gateway  to my PC IP using port 9000
2)Start a proxy in my pc (I used CCproxy) listening at port 9000
3)Fire Wireshark and use the following filter
http && (ip.src == xxx.xxx.xxx.xxx || ip.src ==yyy.yyy.yyy.yyy) && ( ip.dst == xxx.xxx.xxx.xxx || ip.dst ==yyy.yyy.yyy.yyy)
xxx.xxx.xxx.xxx= MyPCIP
yyy.yyy.yyy.yyy =weatherdirect.com IP (52.4.247.10)
You’re going to see the request coming from xxx.xxx.xxx.xxx and answered by yyy.yyy.yyy.yyy

I was playing around with the capture of TX-60 and it looks that temp & HR% are similar to the weather station.
This is the request the TX60 send to the server
HTTP_IDENTIFY: ZZZZZZZZ:AA:YYYYYYYYYYYYYYYY:BB
According to mike@mycal.net
ZZZZZZZZ  =is 0x80 + MAC address less vendor id.
YYYYYYYYYYYYYYYY = Registration code or device Serial Number or other Identifier.
AA = Packet Code 1 
BB = Packet Code 2
AA:BB is the command sent by TX60 and the Gateway
I saw  two different commands in the header: 01:01 , 01:00,  the first one send also 23 byte with the sensor info. The server answered with the following headers HTTP_FLAGS: 00:00 and HTTP_FLAGS: 01:00. You can also see a 00:70 command, that is sent by the Gateway and answered with HTTP_FLAGS: 70:00 .
If you have more than one TX60 , the second thermometer would send a 02:01 and 02:00 commands instead of 01:01 and 01:00. So the first part in the command is the sensor ID
When the command is ID:01 TX60 also send 23bytes with the following structure:
XXXXXXXXXXXXXX3576082626262626262626262626605A
The structure of the packet is:
7 byte of something like the registration( is always the same in each request)
3 byte of sensor 1 info
13 bytes of  "26" + sensor 2 info ??? (I couldn't check because I don't have the probe)

I compared the recording (every 5') of the alert system with the capture, and based in the finding of the forum , it looks like :
The temperature in the TX60 is sent in Fahrenheit and it use 2 bytes. Relative humidity use only one byte.

So,
Bytes   |Description
08   |Relative humidity
09   |Integer part of temperature
10   | Decimal part of temperature
 (A) Integer part of temp.
 (D) decimal portion of temperature
Temp = (ToInt(A) + D / 10 ) -40

Now what I understood how it works the next step was to get an Http server to simulate the weatherdirect.com.Then with the info captured from the TX60 ,process and  save it in a file or base.
I read that node.js was one of the easiest tools to create servers and fortunately there were a lot of samples in the web . So I decided to give a try and I coded this little script  to do this job and I used sqlite3 to create a base with the captured data and also write the info to a csv file (to later graph the data with excel)

Finally I though the best to way to keep running the server in windows was to put in a service, so I used Nssm (download from https://nssm.cc/download) to start node and the script as a service and voilŕ , I have a base with all temp and HR data every 5 minute from  my TX60. Everything was made for Windows but I think if you work with Linux you can do a similar arrangement. My idea is to install it in a Raspberry PI , but I couldn't find time to try.

Attached are the following files:
 ”TX-60-V2.1.js”
“Install TX60 Service.4.bat”
“StartTX60Server.bat”
“StringExtend.js” (I deserve the hell for this)

Follow these steps to run the node script.
1)First you have to install node.js . You also need to install module “util” and If you want to generate a base with the TX60 data you have to install “sqlite3”. If you don’t, you have to comment the followings lines: 4, 71-73 and 85 in the TX-60-V2.1js
2) Install NSSM
3) Open AGSP ,press the button search(the information of you gateway should appear), check the "Use" checkbox, add your pc IP and use port 9000. Press button “Set” and the “Reboot” after 10 sec. aprox., the Gateway is sending everything to your PC to the port 9000 and from here to weatherdirect.com
3) Copy the following files to your node folder:
Node TX-60-V2.1.js
Install TX60 Service.4.bat
StartTX60Server.bat
StringExtend.js
4)Check the node script is receiving the data: on a node prompt run :
    node TX-60-V2.1.js
You are going to see a log on the screen with the server operation.
5) If everything is OK, stop node and try to install it as a service
6) Modify the file : “Install TX60 Service.4.bat”, adding the all the path needed
7) Run “Install TX60 Service.4.bat”. If is ok you are going to see after the first executed line in the bat :
    Service "TX60Server" installed successfully!
8)Start the service doing in the command prompt:
   sc start tx60server
9) Check the file “TX-60StdOutErr.log” in the node folder, to see the server log. In the files “TX-60.db” and “TX-60.csv”  should be the recorded temp and humidity values.

Sorry for my english.
I hope this infornation could help TX60 owners!! [ You are not allowed to view attachments ]

Offline ozsun

  • Member
  • *
  • Posts: 4
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #1 on: February 28, 2016, 03:34:48 PM »
Firstly ... what a great piece of work!  =D> Very impressive and thanks for the detailed write-up.

Could I ask your for some help?
I got your java scripts running on my R-Pi and changed the proxy settings in AGSP to send the gateway data to node.js on my R-Pi port 9000. Sqlite3 installed, no issues. So far, so good.
However when I run TX-60-V2.1.js, I get this error "Sun Feb 28 2016 20:42:18 GMT+0100 (CET): Command: 001D8C0DD655:undefined Response:". This error repeats 2 minutes, then again 5 minutes later i.e. on the usual 7 minute scan cycle of the sensors. The green LED on the gateway is constant green (no blinking).
A .dump of TX-60.db looks like this

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE TX60(TimeStamp DATETIME,Sensor INTEGER, Temp REAL, HR INTEGER);
COMMIT;

My set up is a bit different to yours - I have 4 TX40s (bought from an EU distributor http://www.mobile-alerts.eu/index.php/en/) the data is sent to www.data199.com. These sensors are temperature only, no humidity.

Any ideas where I need to start with this problem?
What do I need to modify TX-60-V2.1.js for my setup?

Thanks for any advice!

Offline Flying_Carlos

  • Member
  • *
  • Posts: 8
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #2 on: February 28, 2016, 04:34:36 PM »
OzSun, You need to do a capture of your traffic between you Gateway and the web page of that company, to see what your system is sending, this is the only way to understand what is happening and later modify the node script.
In Lacrosse system what I did is the following:

1) install wireshark (or similar) then:

1) Download Gateway Setup program (AGSP) ,  from http://www.weatherdirect.com/downloads/GatewayAdminInstall.exe
The following  article (http://www.weatherdirect.com/pdfs/help/weatherDirectRegistration.pdf), in the page 20 & 21 explain how to use the AGSP, also in SkyDvrz software there is a detailed explanation of how to setup the proxy.
Redirect to your PC IP and Port 9000(for Instance)

2) Start a proxy in your  pc (I used CCproxy) listening at port 9000

3)Fire Wireshark and use the following filter
http && (ip.src == xxx.xxx.xxx.xxx || ip.src ==yyy.yyy.yyy.yyy) && ( ip.dst == xxx.xxx.xxx.xxx || ip.dst ==yyy.yyy.yyy.yyy)
xxx.xxx.xxx.xxx= MyPCIP
yyy.yyy.yyy.yyy =weatherdirect.com IP (52.4.247.10)

Lets assume that your PC iP is : 1912.168.1.100 and the company web page is 111.111.111.111. You are going to see in the traffic
Request from 192.168.1.100 and response from 111.111.111.111. In the TX-60 the request is like this :

PUT http://box.weatherdirect.com/request.breq HTTP/1.1..
Host: box.weatherdirect.com..Connection: close..
HTTP_IDENTIFY: ********:01:****************:01..           (*** : is private data :-()
Content-Type: application/octet-stream..
Content-Length: 23(23 byte with data follow)

As you can saw it the script is processing the Header HTTP_IDENTIFIY, and split it using ":" in 4 separate fields . In this case the 2nd and 4th are 01 and 01. This is what I call the command 01:01.
For your answer it looks that the script is receiving the HTTP_IDENTIFIY but the it looks like there is no 4 field
This is why the answer is 001D8C0DD655:undefined , because the field 4 doesn't exist.
Try to use the wireshark and show me the file with the capture.
Have a luck !!!


Offline ozsun

  • Member
  • *
  • Posts: 4
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #3 on: February 28, 2016, 04:53:00 PM »
Hi Flying_Carlos - Thanks a lot for your fast reply! OK,I'll wireshark tomorrow (it's getting late here) and send you the file.  :-)

Offline ozsun

  • Member
  • *
  • Posts: 4
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #4 on: February 29, 2016, 02:13:04 AM »
There you go ... thanks!

Offline Flying_Carlos

  • Member
  • *
  • Posts: 8
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #5 on: February 29, 2016, 10:38:07 AM »
Ozsum,
Tell me this:
How many TX40 are connected?
What is the temperature measured when you did the capture(aprox.)
Temperature is set in Celsius or Farenheit?
I'm going to see the cap this night.
See you

Offline ozsun

  • Member
  • *
  • Posts: 4
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #6 on: February 29, 2016, 11:38:18 AM »
Hi Flying_Carlos,
There are 4 TX40's connected.
All read in celsius.
3 of them were about 22.5C (inside) and the other was about 3.5C (outside) at the time of capture.
Thanks!

Offline Flying_Carlos

  • Member
  • *
  • Posts: 8
Re: Lacrosse TX60 temperatute and humidity capture
« Reply #7 on: March 01, 2016, 10:21:23 AM »
Ozsum, I think you will need to work hard with this pattern!!.

What I find:
256 bytes are send withd data, it looks too much for a temp sensor!!. But I think they are using the same structure for all products they have.
I see a pattern of 4 group of data (may be one for each sensor), but I couldn't find a temp value using the coding of the  TX60, nor BCD, neither other type of coding that I tried. Each group of data is like this: (this is the first one)

00   00   01   02   03   04   05   06   07   08   09   0A   0B   0C   0D   0E   0F
                                                
10   CE   56   D3   E8   B0   12   02   1B   49   75   50   51   16   A9   00   DC
20   00   DB   1A   00   00   00   00   00   00   00   00   00   00   00   00   00
30   00   00   00   00   00   00   00   00   00   00   00   00   00   00   00   2D

The first 3 byte and the value at 0x22  are the same in each group . At the end of the group (byte at 0x3F) looks like a kind of checksum.
I tried in the rest of values but I didn't have luck .
So , I recommend you that
1) Disconnect all TX40 but one.
2) Watch the capture and look for different HTTP_IDENTIFY:. Should be one from the gateway (like a ping) and 2 from the sensor, one with the data and another like a ping without data.
3) Look the response from the server in each step and save for later.
4) Keep the sensor at the same temp. and take several measurement and compare what it is not changing and what it is.
5) Change the temperature of the sensor and repeat step 2)
6) Copy the data from each case to excel and try to find a pattern that match the temperature.

For 6) look at the TX40 spec and see what is the range of temp. In my case was from -39.99 C to +( don't remember).
so if the value is send as positive should be added with 40, that is the reason that the temp is (Byte1 +Byte2/10 + 40).


I know that is not easy but I think it is the only way to find it.
Have good luck!!, and tell me about your progress.