# Weewx data integration - Dev idea

**URL:** https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185
**Category:** Development
**Created:** [January 10, 2020, 11:39pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185 "2020-01-10T23:39:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Lars](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Lars](https://farmos.discourse.group/u/Lars)
#### Post date: [January 10, 2020, 11:39pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/1 "2020-01-10T23:39:39Z")

</div>

Hi @ all,

I just managed to hook into the data sent from my affordable weather station and get the data into weewx. It took me quite some time and I read a lot along the way. I am using a raspberry but most things will be similar on other OS [https://github.com/weewx/weewx/wiki/Raspberry%20Pi](https://github.com/weewx/weewx/wiki/Raspberry%20Pi).

I hope I can provide some knowledge base that might encourage others to get their data away from data hogs like [wunderground.com](http://wunderground.com/) (.csv export option was removed recently). Btw I you want to use a awesome community founded weather app and website use [windy.com](http://windy.com/) !

But back to Weewx. From the Weewx site [http://weewx.com/docs/usersguide.htm#about](http://weewx.com/docs/usersguide.htm#about)  
_WeeWX is software, written in Python, that interacts with a weather station to produce plots, reports, and HTML pages. It can optionally upload the reports to a remote Web server as well as publish to weather services such as WeatherUnderground, CWOP, or [PWSweather.com](http://pwsweather.com/)._  
_Initial development began in the winter of 2008-2009, with the first release in 2009._  
_The source code is hosted on GitHub, while downloads are available at [weewx.com/downloads](http://weewx.com/downloads)._  
_WeeWX is about 13,000 lines of code, plus another 13,000 for the drivers for all the types of supported hardware._

There are many stations that are supported by Weewx drivers while others are not.

If your station is not supported you have several options to get the data.

**Question 1:** can you set a sever IP and Port or is there only 1 fixed server in the station?

- if you can set a different IP and Port you are lucky
- you can install weewx and the interceptor driver [https://github.com/matthewwall/weewx-interceptor](https://github.com/matthewwall/weewx-interceptor) and use the lister mode  
—\> setup  
[Interceptor]  
driver = user.interceptor device\_type = observer port = 8000

**Problem 1: IP** can not be set

- this makes it a bit more difficult but still possible
- you can try to telnet into the wifi or lan connected module
- for example depending on the station [https://obrienlabs.net/redirecting-weather-station-data-from-observerip/](https://obrienlabs.net/redirecting-weather-station-data-from-observerip/)

**Problem 2:** IP can not be set

- option: you can install weewx and the interceptor driver [https://github.com/matthewwall/weewx-interceptor](https://github.com/matthewwall/weewx-interceptor) and use the sniff mode/ package capture
- Example: sniff mode for any WU client

This example assumes two network interfaces on the computer running weewx. 1) Plug the computer into the local network using the first interface (eth0). Plug the device into the second interface (eth1). Bridge the two network interfaces. If you run any web services on the computer, configure them to listen on interface eth0, not eth1. 2) Set parameters in the weewx configuration file. The device has IP address of X.X.X.X [Interceptor] driver = user.interceptor device\_type = wu-client mode = sniff iface = eth1 pcap\_filter = src X.X.X.X and dst port 80

**Problem 3:** it still does not work

- Redirect traffic using a router and iptables
- see how [https://obrienlabs.net/redirecting-weather-station-data-from-observerip/](https://obrienlabs.net/redirecting-weather-station-data-from-observerip/)

**How do you know you are getting data:**

- in the weewx.conf file you set the report to 1 to get a more detailed flow of data [http://www.weewx.com/docs/usersguide.htm#monitoring](http://www.weewx.com/docs/usersguide.htm#monitoring)

- with: tail -f/ var/log/syslog or /var/log/syslog you should see data coming in

- another option is to install Cumulus Real Time [https://github.com/weewx/weewx/wiki/crt](https://github.com/weewx/weewx/wiki/crt)

- [https://cumuluswiki.wxforum.net/a/Realtime.txt](https://cumuluswiki.wxforum.net/a/Realtime.txt)

- this will create a always current .txt

Once everything works fine you might be thinking how great it would be to get the data into farmOS!

**So what could be the options to get data into farmOS?**  
Some ideas not sorted for feasibility:

1. set a cron job to transfer realtime.txt data into farmOS see here [http://landoflinux.com/linux\_raspberry\_pi\_weather\_station.html](http://landoflinux.com/linux_raspberry_pi_weather_station.html)

—\> this might be one option to get the data into farmOS however realtime.txt is updated regularly and all old data is overwritten so if a package is dropped its gone

1. Weewx is hard on SD cards run on PI’s so you can send log files to a remote syslog server

- down this page this option is explained [https://github.com/weewx/weewx/wiki/Minimize-writes-on-SD-cards](https://github.com/weewx/weewx/wiki/Minimize-writes-on-SD-cards)

- this might be a pretty good option to get the data into farmOS however ideally it would also still be stored in the Weewx database for Reports that you can view in a browser or make available on your website

1. there is also an option to the data to a remote sever via FTP but I cant find it at the moment

I hope this helps the community to either run their own weather station with Weewx or start up the integration of Weewx data into farmOS 🙂

Good resources:

> **[weewx/weewx](https://github.com/weewx/weewx/wiki)**
>
> WeeWX code repository. Contribute to weewx/weewx development by creating an account on GitHub.

> **[Installing WeeWX in Raspberry Pi - Domotic Project](https://domoticproject.com/installing-weewx-raspberry-pi/)**
>
> Weewx is a great software for people who have a domestic weather station and are interested in meteorology. In this post will only be exposed the more important points to install and configure Weewx in a Raspberry Pi.

[http://landoflinux.com/linux\_raspberry\_pi\_weather\_station.html](http://landoflinux.com/linux_raspberry_pi_weather_station.html)

> **[matthewwall/weewx-interceptor](https://github.com/matthewwall/weewx-interceptor)**
>
> weewx driver that intercepts web traffic from internet 'bridge' devices such as Acurite Access, ObserverIP, OS LW30x, LaCross GW1000U, FineOffset GW1000 - matthewwall/weewx-interceptor

[https://cumuluswiki.wxforum.net/a/Realtime.txt](https://cumuluswiki.wxforum.net/a/Realtime.txt)

> **[weewx/weewx](https://github.com/weewx/weewx/wiki/Raspberry%20Pi)**
>
> WeeWX code repository. Contribute to weewx/weewx development by creating an account on GitHub.

[https://jackstromberg.com/2018/06/setting-up-weewx-with-a-raspberry-pi/](https://jackstromberg.com/2018/06/setting-up-weewx-with-a-raspberry-pi/)

> **[weewx/weewx](https://github.com/weewx/weewx/wiki/Minimize-writes-on-SD-cards)**
>
> WeeWX code repository. Contribute to weewx/weewx development by creating an account on GitHub.

> **[Extending the life of your Raspberry PI SD Card - Domotic Project](https://domoticproject.com/extending-life-raspberry-pi-sd-card/)**
>
> The SD card is a key part of the Raspberry Pi. As this cards have a limited erase/write cycles, it is very important to choose and use them carefully, in order to expand their life time. In this post we will see some methods to increase the lifespan...

> **[weewx/weewx](https://github.com/weewx/weewx/wiki/observer)**
>
> WeeWX code repository. Contribute to weewx/weewx development by creating an account on GitHub.

> **[Redirecting Weather Station Data from ObserverIP](https://obrienlabs.net/redirecting-weather-station-data-from-observerip/)**
>
> I have an Ambient Weather WS-1200-IP weather station. It’s a great unit and very easy to use and setup! There is an outdoor unit which does temperature, humidity, wind speed, wind direction, rainfall, UV and solar radiation. There’s also an indoor...

[https://community.openhab.org/t/are-you-using-an-outside-weather-station-if-so-which-one/38736/36](https://community.openhab.org/t/are-you-using-an-outside-weather-station-if-so-which-one/38736/36)

> **[weewx/weewx](https://github.com/weewx/weewx/wiki/weathersleuth)**
>
> WeeWX code repository. Contribute to weewx/weewx development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![paul121](https://avatars.discourse-cdn.com/v4/letter/p/54ee81/32.png) [@paul121](https://farmos.discourse.group/u/paul121)
#### Post date: [January 12, 2020, 7:06pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/2 "2020-01-12T19:06:29Z")

</div>

Thanks for compiling all of this info @Lars!! Unfortunately I don’t have a weather station so I can’t test anything regarding “getting the data” but interesting to see how that gets setup.

Re: **So what could be the options to get data into farmOS?**

I just took a look at the WeeWX customization guide. It looks like it might be fairly easy to create a new `service` (an example [here](http://weewx.com/docs/customizing.htm#Adding_a_service)) for farmOS specifically! The integration with wunderground is just a `restful_service` in the weewx `engine`. I’m not entirely sure how all of these services work, but there seems to be some sort of hierarchy defined [here](http://weewx.com/docs/usersguide.htm#%5BEngine%5D). It seems like stages earlier in the pipeline will contain more `raw` and possibly duplicate data. By the time it hits `archive_services`, `resful_services` and `report_services` the data is easier to work with.

In that example the line that sends an email could pretty easily be replaced with a simple

```auto
response = session.post(
        headers=headers,
        url=f"{farmos_server_url}/{sensor_public_key}?private_key={sensor_private_key}",
        json=data
    )

```

Weewx has a really neat way of configuring everything, including services, via `weewx.conf`. The `farmos_server_url`, `sensor_public_key` and `sensor_private_key` could all be defined in a `service` config. Additional properties could limit different units that are posted, time intervals, etc.

I’m also curious if this is something we could build into farmOS.py. Even though posting to sensors doesn’t require _user authentication_ with the farmOS server, the farmOS library could simply provide a wrapper around the `requests.post` I mentioned above (without using farmOS credentials). Because farmOS.py uses the same python `ConfigObj` configuration as weewx, the `config` required for farmOS.py might be able to simply be passed through the `weewx.conf` file. So posting to a sensor would be as easy as `client = farmOS("url", "pub key", "private key")` and `client.sensor.post(data)`

(I’m curious what @mstenta thinks about including such a feature in farmOS.py - with the ability to store configs for sensors in a text file, I think this would be very useful!)

---

<div class="post-metadata">

### Author: ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)
#### Post date: [January 14, 2020, 9:06pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/3 "2020-01-14T21:06:47Z")

</div>

I like the idea of being able to use farmOS.py to post to sensors!

Thanks for all this info @Lars! I will have to give my station another shot and see if I can get weewx to detect it…

---

<div class="post-metadata">

### Author: ![Nod](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/nod/32/524_2.png) [@Nod](https://farmos.discourse.group/u/Nod)
#### Post date: [January 10, 2022, 3:39pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/4 "2022-01-10T15:39:13Z")

</div>

Is there a particular weather station you guys would recommend for this? I live about a mile from my apiary and I am planning on setting up a LoRa network to monitor a weather station at home and at the apiary. Compiling the data for both in one spot would be awesome!

---

<div class="post-metadata">

### Author: ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)
#### Post date: [January 10, 2022, 3:47pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/5 "2022-01-10T15:47:34Z")

</div>

I’m curious too! I got a weather station as a Christmas present a few years back, and tried to get it working with weewx but it wasn’t officially supported, and eventually I gave up. Would love to hear if anyone has had success or can recommend a station for this!

---

<div class="post-metadata">

### Author: ![Lars](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Lars](https://farmos.discourse.group/u/Lars)
#### Post date: [January 10, 2022, 5:51pm UTC](https://farmos.discourse.group/t/weewx-data-integration-dev-idea/185/6 "2022-01-10T17:51:02Z")

</div>

I use the Ambient Weather WS-1401-IP with LAN connection.  
The LAN interface is about 150 yards away from the station (direct line of sight). The WS-1401 is also not supported by weewx but after quite a bit of work I managed to have a raspberry with weewx collect the data from the LAN interface. The raspberry and the weewx data are accessible via LTE router and VPN from my home or phone. There is a option to send data via FTP to another server… but I have never tried it.  
Supported hardware list [weewx: Hardware Guide](https://www.weewx.com/docs/hardware.htm)
