User avatar
hamashi2
Posts: 6
Joined: Mon Jul 01, 2013 10:10 am

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Jul 09, 2013 7:43 am

I don't really mind the looks of the string, I just want to snip the outtemperature, humidity, raintick, windspeed, winddir, uv and solarrad, and I'm currently really out of my natural habitat with all this python stuff.
torkelmj wrote:As a string ... it doesn't look pretty.

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Jul 09, 2013 7:56 am

It's all described here:
http://www.davisnet.com/support/weather ... s_v261.pdf

Section X - data formats (pg. 21-) refers.

gregario
Posts: 2
Joined: Tue Oct 08, 2013 6:37 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Oct 08, 2013 6:51 pm

Hi All,

thanks so much for the information, its been very beneficial. I've gotten a bit stuck (I'm a python beginner!)
I'm putting together the code to print out the davis weather station data and store it in a .txt file.

So far I've gotten this far:

Code: Select all

 
import serial, string, time, struct
# Serial port settings
WXPORT = '/dev/ttyAMA0'
WXBAUDRATE = 19200
WXBYTESIZE = serial.EIGHTBITS
WXPARITY = serial.PARITY_NONE
WXSTOPBITS = serial.STOPBITS_ONE
WXXONOFF = False
WXTIMEOUT = 3
WXDELAY = 0.2  # WX station communication delay

wx = serial.Serial(WXPORT, WXBAUDRATE, WXBYTESIZE, WXPARITY, WXSTOPBITS, WXTIMEOUT, WXXONOFF)
time.sleep(WXDELAY)

def wxWrite(s, termChar='\n'):
    """write s to wx, terminate string with termChar, then DELAY execution"""
    """NOTE: requires global wx to already be open"""
    if(wx != None):
        s = s + termChar
        wx.write(s)
        if(s == 'VER\n'):
            time.sleep(WXDELAY * 3) # VER seems to need more time?
        else:
            time.sleep(WXDELAY)

i = wx.inWaiting() # number of chars waiting in the RX buffer
s = wx.read(i) # read i chars from RX buffer
print (i)

# assuming s holds entire LOOP packet
barometer_INHG = round(struct.unpack_from('H', s, 5)[0] / 1000.0, 2)
So the problem I'm having is the the RX buffer is empty (by printing i and also the struct.unpack throws an error as there is not 2 bytes), I've tried the LOOP command but am not getting a response. Any suggestions for me? (as you can tell I don't really know what I'm doing!)

The end goal for me would be the very basic current weather data, comma delimited, with a return char at the end so that I can store and manipulate the variables locally in python!

Any help would be greatly appreciated!

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Oct 08, 2013 7:02 pm

Are you a victim of the Davis firmware v. 3.xx problem?

http://meteo.annoyingdesigns.com/DavisSPI.pdf

gregario
Posts: 2
Joined: Tue Oct 08, 2013 6:37 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Mon Oct 21, 2013 11:54 am

I'm pretty sure I do have V3 of the equipment, I also did get a davis datalogger though, will I have authentication issues with this?

Does the V3 have different commands I have to run to get this working, I'm talking over ttyUSB0 on a raspberry pi and I can't seem to get anything to respond into the rxbuffer!

What I would like to do is send a loop command out and receive back the current info, parse that into a set of variables I can then save into a database/csv file... Any help would be greatly appreciated!!!

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Mon Jan 06, 2014 11:37 am

gregario wrote:I'm pretty sure I do have V3 of the equipment, I also did get a davis datalogger though, will I have authentication issues with this?

Does the V3 have different commands I have to run to get this working, I'm talking over ttyUSB0 on a raspberry pi and I can't seem to get anything to respond into the rxbuffer!

What I would like to do is send a loop command out and receive back the current info, parse that into a set of variables I can then save into a database/csv file... Any help would be greatly appreciated!!!
Did you "wake up" the console per Davis instructions?
http://www.davisnet.com/support/weather ... s_v261.pdf

Shouldn't be much of a problem to achieve this.

oretnom
Posts: 5
Joined: Tue Jan 21, 2014 4:56 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Jan 21, 2014 5:00 pm

Hello. Thank you verry much for this guide, it's been really helpful :)
I'm trying to do something similar with a BeagleBone Black. I've been reading the Davis documentation about the serial communication with the console, and there is something i can't really understand about the LOOP package. I mean, when I send, for example, LOOP 2, what is the difference between the 2 packages I receive? I haven't seen any explaination about this. Thanks in advance.

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Tue Jan 21, 2014 9:25 pm

oretnom wrote:I've been reading the Davis documentation about the serial communication with the console, and there is something i can't really understand about the LOOP package. I mean, when I send, for example, LOOP 2, what is the difference between the 2 packages I receive? I haven't seen any explaination about this. Thanks in advance.
IS there a difference? The data may be the same (or very identical).

Pg. 12 of http://www.davisnet.com/support/weather ... s_v261.pdf refers.

prodata
Posts: 160
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 01, 2014 3:22 pm

torkelmj wrote:IS there a difference? The data may be the same (or very identical).
Although there is some overlap between LOOP and LOOP2, there are also major differences. Compare the tables in Section X for the details, but basically LOOP will give data for all sensors that can be attached to a VP2 station (ie including all the supplementary stations), whereas LOOP2 provides more detailed data (eg wind speeds to 1dp, 2min and 10min means, wind direction in degrees etc) for the basic 8 outside weather parameters available from the primary ISS (ie including solar and UV sensors, if fitted).

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 01, 2014 3:51 pm

...then you assume that the OP intended to write "LPS 2" in his original post. He specifically asked for "LOOP 2" which may very well return two identical data packets.

prodata
Posts: 160
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 01, 2014 4:11 pm

torkelmj wrote:...then you assume that the OP intended to write "LPS 2" in his original post. He specifically asked for "LOOP 2" which may very well return two identical data packets.
Indeed - I should be more careful about looking for space characters! So the answer should be: Sometimes two consecutive LOOP packets (ie as requested by LOOP 2) will be identical, but typically they will vary in the wind speed parameter (and possibly wind direction, but less likely given that there are only 16 bins, plus calm).

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 01, 2014 5:35 pm

Sorry if my reply was perceived as a rather rude one. The curse and blessing of mobile devices: too easy to write (too) short posts from an on-screen keyboard.

prodata
Posts: 160
Joined: Tue Jan 24, 2012 5:53 pm
Contact: Website

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 01, 2014 8:50 pm

No problem at all - almost amusing the difference a single space character can make (even in plain text, ie not code) :)

But having introduced the point, I think that if I was writing software for a standard non-supplemented VP2 ISS (and using console firmware v1.90 or later) then I might be tempted to use the LOOP2 (no space) packet rather than plain LOOP, just for the extra detail in the standard weather parameters it can provide.

oretnom
Posts: 5
Joined: Tue Jan 21, 2014 4:56 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Wed Feb 05, 2014 10:28 pm

torkelmj wrote:
oretnom wrote:I've been reading the Davis documentation about the serial communication with the console, and there is something i can't really understand about the LOOP package. I mean, when I send, for example, LOOP 2, what is the difference between the 2 packages I receive? I haven't seen any explaination about this. Thanks in advance.
IS there a difference? The data may be the same (or very identical).

Pg. 12 of http://www.davisnet.com/support/weather ... s_v261.pdf refers.
Thanks. I have another question, if you don't mind. The document specifies that the size of the LOOP package is 99 bytes, but I have noticed that sometimes I get 90 or 110 bytes. This really confuses me, I suppose this is because of data getting lost during communication. Do you think I should ignore this packages and stick only to the "properly sized" ones?

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Wed Feb 05, 2014 10:44 pm

Most bulletproof approach: use CRC-verified data only. :)

oretnom
Posts: 5
Joined: Tue Jan 21, 2014 4:56 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Thu Feb 06, 2014 4:22 pm

torkelmj wrote:Most bulletproof approach: use CRC-verified data only. :)
Right, I'll get to it, thanks!

oretnom
Posts: 5
Joined: Tue Jan 21, 2014 4:56 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Fri Feb 07, 2014 5:40 pm

Hey, me again :?
I have some more questions:

First, I'm looking at page 33 of your document, section Python Example Code. I've read on how to use the struct.unpack_from function on several sites. I'll use your example:

Code: Select all

struct.unpack_from('B',s,1)[0]
In this case, B is the data type and length you wan to extract, right? That would be a 1 byte integer; s is a container for the received data, for example, from LOOP 1; and 1 is the offset, the position of the desired data. What I don't know, and have not seen anywhere, is what [0] is for.

Now, regarding to the CRC check. I've been reading about it and found some "incoherences" that just make me think I'm not really understanding. For example, on page 38 of Vantage Serial Protocols Document says this:
When sending a CRC to the console, always send the most significant byte first. This is the opposite of how regular data values are sent where the least significant byte is sent first.
The question is: Why would I want to send a CRC to the console? I had the idea that the console sends the CRC to me when I ask for a LOOP 1 (it's actually on bytes 97 and 98), and then I should proceed to check the CRC with the given function (with the big table). To perform this check, I should pass the LOOP 1 data to that function, right? And this brings me to another question: The document specifies that the CRC bytes must be read (or sent?) MSB first. Does this mean I should perform the check for the first 97 bytes naturally and then swap the bits for the CRC bytes? What I've done so far is pass the data directly to the CRC function, and I've never got zero on the accumulator, so obviously I'm doing it wrong.

As you can see, I'm really struggling with this, but I'm really trying to do everythying I can on my own. I appreciate your help.

torkelmj
Posts: 25
Joined: Wed Dec 26, 2012 11:10 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Fri Feb 07, 2014 11:22 pm

oretnom wrote: I have some more questions:

struct.unpack_from('B',s,1)[0]
In this case, B is the data type and length you wan to extract, right? That would be a 1 byte integer; s is a container for the received data, for example, from LOOP 1; and 1 is the offset, the position of the desired data. What I don't know, and have not seen anywhere, is what [0] is for.
Python is fairly well documented. May I suggest a visit to http://www.python.org/doc/current/library/struct.html --- scroll to struct.unpack_from -- take note of "The result is a tuple even if it contains exactly one item". That's what there is to say about that matter.
The question is: Why would I want to send a CRC to the console? I had the idea that the console sends the CRC to me when I ask for a LOOP 1 (it's actually on bytes 97 and 98), and then I should proceed to check the CRC with the given function (with the big table). To perform this check, I should pass the LOOP 1 data to that function, right? And this brings me to another question: The document specifies that the CRC bytes must be read (or sent?) MSB first. Does this mean I should perform the check for the first 97 bytes naturally and then swap the bits for the CRC bytes? What I've done so far is pass the data directly to the CRC function, and I've never got zero on the accumulator, so obviously I'm doing it wrong.
Again, a little bit of searching would have saved some time.
From http://www.davisnet.com/support/weather ... s_v261.pdf --- search for "CRC" and browse through the matching entries. Sooner or later you'll reach the SETTIME command --- which for obvious reasons requires a CRC checksum to be calculated. There are several other commands, too --- basically, any time you CHANGE data in the console, you'll have to supply a valid CRC. Makes sense, doesn't it --- you don't want the console to accept just about anything you send to it, +/- line noise.

For the second part, remember that the response to the LOOP command starts with an <ACK>. The <ACK> should not be included in the data which you send off to the CRC function. Given than s contains the data received as a response to the LOOP command, you'll want to run the CRC check on the s[1:101] subset. You're not required to toggle the MSB/LSB bit order for this purpose.

Remember, half of the fun with Python is browsing the documentation. The Python community certainly did a great job putting it all together --- it's a great source of information and it's easy and lightweight to browse.

Best of luck!

oretnom
Posts: 5
Joined: Tue Jan 21, 2014 4:56 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Mon Feb 10, 2014 8:12 pm

torkelmj wrote: For the second part, remember that the response to the LOOP command starts with an <ACK>. The <ACK> should not be included in the data which you send off to the CRC function. Given than s contains the data received as a response to the LOOP command, you'll want to run the CRC check on the s[1:101] subset. You're not required to toggle the MSB/LSB bit order for this purpose.

Remember, half of the fun with Python is browsing the documentation. The Python community certainly did a great job putting it all together --- it's a great source of information and it's easy and lightweight to browse.

Best of luck!
Man, you just saved my life, it was the ACK that I was ignoring. I read about it like once but didn't give it importance. Thank you so very much.

retiredtech
Posts: 20
Joined: Thu Apr 04, 2013 11:07 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Thu Jan 19, 2017 10:18 pm

I just received (for free) a Davis weather link plus a USB data logger. I don't intend to use the weatherLink software on a PC but rather attach my Davis vantage vue to a Pi. There are multiple methods described here and in other forums on connecting a Pi to a Davis weather station but before I jump into that is there anyway of using the USB data logger that came with the package or do I just go with the other connections shown in the various posts (IP, serial)?

stevend
Posts: 211
Joined: Fri Oct 11, 2013 12:28 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Thu Jan 19, 2017 11:03 pm

retiredtech wrote:There are multiple methods described here and in other forums on connecting a Pi to a Davis weather station but before I jump into that is there anyway of using the USB data logger that came with the package or do I just go with the other connections shown in the various posts (IP, serial)?
Unless you want to buy (or maybe make) extra hardware, it mostly depends on what your chosen weather software supports.
I use weewx, which says it supports the USB interface of the Davis. (I suspect both USB and network are mostly different ways of accessing the serial interface). Weewx certainly uses the data logger facility if present - if comms fails for a while, weewx will retrieve as much historical data as it can from the Davis. And weewx definitely runs on the Pi (its written in Python)

retiredtech
Posts: 20
Joined: Thu Apr 04, 2013 11:07 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Fri Jan 20, 2017 2:23 am

Thank you for your prompt response. I will go with your advice.

prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Fri Jan 20, 2017 2:39 am

I highly recommend this free software that will run on a raspberry pi. It has been running with my Vantage Pro for a couple of years now without any issues or failure. Now that I think about it, the raspberry has been running this long without needing a reboot.

There is also outstanding user support via the forum.

http://sandaysoft.com/forum/viewtopic.php?t=12860

john84
Posts: 3
Joined: Tue Dec 13, 2016 10:13 am
Contact: Website

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sat Feb 25, 2017 5:22 pm

I want to buy a wireless weather station.
Which one is best?
Any suggestion?
online door parts

prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Raspberry Pi / Davis Vantage Pro2 weather station

Sun Feb 26, 2017 2:27 am

Davis Vantage Pro just like the title of this post.

Return to “Automation, sensing and robotics”