# Hackulink Driver
## What is it?
A driver for feeding data from an Acu-Rite Acu-link internet bridge into weewx.
## Um, what’s “weewx”
> weewx is a free, open source, software program, written in Python, which interacts with your weather station to produce graphs, reports, and HTML pages. It can optionally publish to the WeatherUnderground, PWSweather.com, CWOP, WOW, or AWEKAS.
Get it here: http://www.weewx.com
## What else should I know.
- The code could be better, but it seems to work.
- It ignores data from tower sensors.
- I have no idea how it would work with two 5in1 sensors.
- It won’t log any data if the internet connection or AcuLink’s servers are down.
- The inside temperature, which is a byproduct of the pressure calculation, isn’t right, possibly because of heat emitted by operation of the bridge.
- Reported pressure isn’t adjusted for elevation of the sensor.
## What do I need?
- A computer with a working installation of weewx (v 2.5.0 as of this writing).
- An AcuLink internet bridge.
- A 5in1 Sensor.
- A live internet connection.
- A router running OpenWRT Attitude Adjustment somewhere between the Acu-Link and the Internet.
- A static DHCP lease for the AcuLink.
- The ability to debug your setup if it doesn’t work, because I’m probably not going to have much time to help.
## What’s next?
- Configure the router:
- Install the optional ‘ngrep’ and ‘ncat’ packages.
- Add the following command to the local ‘startup section’ on the Startup page under the System menu. It should be a single line ending in ‘&’, and you’ll need to substitute your AcuLink’s numerical IP address for XX.XX.XX.XX.
ncat -l 2999 --send-only --max-conns 2 --keep-open -c "/usr/bin/ngrep -l -q -d br-lan -W none 'id=' 'src host XX.XX.XX.XX && dst port 80'" &
- Copy the hackulink.py file into the weewx/drivers directory.
- Adapt the sample weewx.conf file to your environment. At the very least you may need to change the host_ip value.
- Start weewx.
- If it doesn’t work for you, figure out why.
## How does it work?
- Weewx loads the driver, the driver opens a socket connection to port 2999 on the router.
- On the router, ncat acts like a simple TCP/IP server listening on port 2999. When a client connection comes in, it starts ngrep and sends the output from ngrep to the client.
- ngrep looks for packets passing through the br-lan interface from the IP address of your AcuLink which contain ‘id=’, when it captures one, it outputs the contents to ngrep. These packets contain HTTP POST requests with the sensor data the AcuLink has received and is submitting to the AcuLink webservice. In most situations, a single packet contains the full contents of the POSTed data.
- The driver receives the captures POST data, checks it to see if it looks complete, and then further parses it, decodes the values, and yields the readings back to the weewx code that called it.
- Based on the wmr100 driver.
- Informed from the information shared by the author and commenters on: http://moderntoil.com/?p=794
- Wind Direction encoding reverse engineered by Jason Anthony
- Hacked by Erik Speckman