My Arduino based weather station (with weeWX driver)...

958 views
Skip to first unread message

Alec Bennett

unread,
Apr 4, 2017, 8:10:20 PM4/4/17
to weewx-user
I need to install wind gauges at different locations but don't want to spend $450+ each for more Davis Vantage Pro2's. Fortunately I found this method to connect the Davis anemometer directly to an Arduino:


Works great! With a bit of modification. That means $130 for a pro quality internet connected wind gauge! The Davis wind gauge was $114 new off eBay, shipped, from the seller sarafankit2009. Can definitely recommend. The auction description was "Davis Instruments 6410 Davis Anemometer For Vantage Pro Pro2 6152 New". That plus $10 for the Arduino clone and $8 for the CHIP, which is similar to a Pi.

I adapted the Arduino code for easy reading from weeWX and made a weeWX driver, posted here along with the Arduino code:


It's currently a bit light on documentation but I plan to build that out. 

The Arduino weather station is currently uploading through weeWX to a test location:


Every time the wind direction indicator turns green it means there was another update. It's using the RealTimeGauge extension.

Some questions and issues:

- the driver currently gets the wind speed about every 17 seconds even though the Arduino is reporting it much more often that that. When using a Vantage I get the wind about every 2 seconds. Any thoughts on how to make the updates more frequent?

- I named the driver "aws", as in "Arduino Weather Station". I'm a bit worried that might get confusing and hard to search for because of Amazon Web Services. Agreed? Idea for other name?

- where to place the driver file? Currently in /home/weewx/bin/weewx/drivers/aws.py.

- should I make any changes to how it's packaged? Would this be something useful for the main fork of weewx?

And FYI I adapted the weeWX driver from the MWS driver mentioned in this thread and posted on github here.   



mwall

unread,
Apr 4, 2017, 8:48:32 PM4/4/17
to weewx-user
On Tuesday, April 4, 2017 at 8:10:20 PM UTC-4, Alec Bennett wrote:
I adapted the Arduino code for easy reading from weeWX and made a weeWX driver, posted here along with the Arduino code:


very nicely done!

 
Some questions and issues:

- the driver currently gets the wind speed about every 17 seconds even though the Arduino is reporting it much more often that that. When using a Vantage I get the wind about every 2 seconds. Any thoughts on how to make the updates more frequent?

make genLoopPacket return every time data is emitted from the arduino.

instead of polling the hardware, open the serial port once in the driver __init__.  then do a non-blocking read instead (a read with timeout) instead of read-then-close.

 
- I named the driver "aws", as in "Arduino Weather Station". I'm a bit worried that might get confusing and hard to search for because of Amazon Web Services. Agreed? Idea for other name?

i usually prefix any exension with 'weewx-' for packaging.  for example, the 'aws' driver would be in a package called 'weewx-aws-x.y.z.tgz' that expands to a directory weewx-aws, that contains the actual driver weewx-aws/bin/user/aws.py

but weewx does not care - you can call it whatever you want.

 
- where to place the driver file? Currently in /home/weewx/bin/weewx/drivers/aws.py.

you should put it in user/aws.py

if you install in weewx/drivers/aws.py then it will be removed when you upgrade weewx.  things in the user directory do not get moved/touched during an upgrade.

 
- should I make any changes to how it's packaged? Would this be something useful for the main fork of weewx?

if you package it using the instructions in the weewx customization guide:

http://weewx.com/docs/customizing.htm#How_to_package_an_extension

then it will be a bit easier for people to install/update. the wee_extension utility will be able to install it, and wee_config will recognize it when someone tries to (re)configure their installation.  see the other drivers on the weewx wiki for examples, such as weewx-twi or weewx-sdr or weewx-wh23xx:

https://github.com/weewx/weewx/wiki

and please add your driver to the weewx wiki!

m

Alec Bennett

unread,
Apr 4, 2017, 10:05:17 PM4/4/17
to weewx...@googlegroups.com
you should put it in user/aws.py
 
When I put it in /home/weewx/bin/user/aws.py, engine.py can't find it:

Traceback (most recent call last):
  File "/home/weewx/bin/weewxd", line 64, in <module>
    weewx.engine.main(options, args)
  File "/home/weewx/bin/weewx/engine.py", line 916, in main
    engine = engine_class(config_dict)
  File "/home/weewx/bin/weewx/engine.py", line 72, in __init__
    self.setupStation(config_dict)
  File "/home/weewx/bin/weewx/engine.py", line 96, in setupStation
    __import__(driver)
ImportError: No module named aws

Do I have to do something other than simply place aws.py in that directory?





--
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/R7j98YGv1ME/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alec Bennett

unread,
Apr 5, 2017, 4:02:08 AM4/5/17
to weewx...@googlegroups.com
make genLoopPacket return every time data is emitted from the arduino.
instead of polling the hardware, open the serial port once in the driver __init__.  then do a non-blocking read instead (a read with timeout) instead of read-then-close.

Thanks hugely for this tip. The driver code I was starting with had clearly been repurposed a few times and was a bit of a mess. Once I took your advice and restructured it everything started working perfectly.









mwall

unread,
Apr 5, 2017, 7:53:08 AM4/5/17
to weewx-user
On Tuesday, April 4, 2017 at 10:05:17 PM UTC-4, Alec Bennett wrote:
you should put it in user/aws.py
 
When I put it in /home/weewx/bin/user/aws.py, engine.py can't find it:

the 'driver' parameter tells weewx where to find the driver.  your weewx config should have this:

[AWS]
    driver = user.aws

m

Devonian

unread,
Apr 5, 2017, 8:35:10 AM4/5/17
to weewx-user


- I named the driver "aws", as in "Arduino Weather Station". I'm a bit worried that might get confusing and hard to search for because of Amazon Web Services. Agreed? Idea for other name?


Winduino ? 

vince

unread,
Apr 5, 2017, 10:50:40 AM4/5/17
to weewx-user


On Wednesday, April 5, 2017 at 5:35:10 AM UTC-7, Devonian wrote:


- I named the driver "aws", as in "Arduino Weather Station". I'm a bit worried that might get confusing and hard to search for because of Amazon Web Services. Agreed? Idea for other name?


Winduino ?

Ardweeno
 

Alec Bennett

unread,
Apr 5, 2017, 11:36:50 PM4/5/17
to weewx...@googlegroups.com
 driver = user.aws

Thanks, fixed.

Another question: there's some code at the bottom of the driver that (I think) lets it run independently of weewx for testing. In my case it starts with:


if __name__ == '__main__':
    import optparse
    usage = """%prog [options] [--help]"""
    syslog.openlog('aws', syslog.LOG_PID | syslog.LOG_CONS)
    syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))

When I try to run aws.py directly though I get import errors. I'm not sure if I should worry about it, since for example simulator.py gets an import error too (in that case its "No module named weedb"). Is it worth looking into? Note that I made a separate script (arduino_test.py) for testing the connection to the Arduino. 


And last question I hope (ha who am I kidding): the Arduino is simply reporting wind speed as calculated over the number of rotations that the cups on the anemometer make over the last 2.5 seconds. It doesn't try to determine wind speed and gusts separately. I see from the charts that weeWX is calculating gusts:

Inline image 1

But when I upload to Weather Underground there's no gusts:


I don't imagine there's an easy fix for that?

Ardweeno

Winduino

Ha! Love it!




gjr80

unread,
Apr 6, 2017, 12:20:08 AM4/6/17
to weewx-user
On Thursday, 6 April 2017 13:36:50 UTC+10, Alec Bennett wrote:

Another question: there's some code at the bottom of the driver that (I think) lets it run independently of weewx for testing. In my case it starts with:


if __name__ == '__main__':
    import optparse
    usage = """%prog [options] [--help]"""
    syslog.openlog('aws', syslog.LOG_PID | syslog.LOG_CONS)
    syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_DEBUG))

When I try to run aws.py directly though I get import errors. I'm not sure if I should worry about it, since for example simulator.py gets an import error too (in that case its "No module named weedb"). Is it worth looking into? Note that I made a separate script (arduino_test.py) for testing the connection to the Arduino.

 Hi,

What command are you using to run aws.py directly? If you are having import errors it is probably a PYTHONPATH issue, something like this should work (for a setup.py install):

$ PYTHONPATH=/home/weewx/bin python /home/weewx/bin/user/aws.py

Obviously the paths will need to be changed for a deb or rpm install.

You will find this sort of arrangement (with perhaps more detailed instructions) used in a number of the the drivers in bin/weewx/drivers.

Gary

Alec Bennett

unread,
Apr 6, 2017, 12:41:58 AM4/6/17
to weewx...@googlegroups.com
$ PYTHONPATH=/home/weewx/bin python /home/weewx/bin/user/aws.py

Thanks, working now.




Alec Bennett

unread,
Apr 6, 2017, 1:03:05 AM4/6/17
to weewx...@googlegroups.com
https://github.com/weewx/weewx/wiki
and please add your driver to the weewx wiki!

Done.



On Tue, Apr 4, 2017 at 4:48 PM, mwall <mw...@users.sourceforge.net> wrote:

--

Thomas Keffer

unread,
Apr 6, 2017, 8:45:42 AM4/6/17
to weewx-user
If you set debug=2, weewx will log the actual URLs sent to the Weather Underground. To help you identify them, log entries will start with

restx: Ambient: url:

Take a look at them and make sure that the parameter 'windgustmph' is being set.

I'd go with "ISSduino"

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages