<> = Windmessgerät = Das Windmessgerät hat drei Funktionen: * Erkundung von windreichen Standorten für eine Kleinwindkraftanlage * Überwachung und Schutz der Windkraftanlage * Berechnung der Effizienz des Windrades {{attachment:anemometer.jpg|Anemometer|width="640px"}} == Erkundung von Standorten == Geeignete Standorte von Windkraftanlagen sollen möglichst durchgängig gute Windverhältnisse haben. Um diese zu erkennen ist es sinnvoll, mehrere mögliche Standorte zu vermessen und dann den besten Standort auszuwählen. Zu diesem Zweck werden die Winddaten über mehrere Wochen von einem Computer aufgezeichnet (z.B. Raspberry Pi). == Überwachung der Windkraftanlage == Der Windsensor erkennt gefährliche Windgeschwindigkeiten und bremst bzw. schaltet die Windkraftanlage ab. Weiterhin ist es möglich, auch den Ladezustand der Akkumulatoren zu überwachen. {{attachment:anemometer_am_mast.jpg|Anemometer am Mast}} == Effizienz == Aus der Windgeschwindigkeit und Luftdichte lässt sich die Windenergie berechnen. Verglichen mit der am Generator erzeugten Energie lässt sich berechnen wie effizient die Windenergie in elektrischen Strom umgewandelt wird. ---- How to set up a cup anemometer for measuring wind speeds The design in hard- and software is kept simple as possible. The idea was to use good available parts and make an easy to adapt solution. Alternativ setups for special purposes are mentioned at the end of each paragraph. = hardware = * Raspberry Pi with sd-card and power supply (I'll just call it Pi) * this howto should work with every revision, tested with Pi rev3 * easy setup, runs Debian, plenty of Open Source Software * https://www.raspbian.org - Debian Linux distribution optimized for Pi * download image and install image to sd-card * you may work with keyboard and screen at the Pi or integrate it into your . local network connecting to it via ssh * cup anemometer spare part for WH1080 or similar * https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf - cup anemometer and wind vane assembly * we won't use a wind vane for this special project * http://www.philpot.me/weatherinsider.html - see how the sensor works inside (reed switch) * notice: the cup anemometer rotates once per second at 1.492mp/h or 2.4km/h wind speed * connecting anemometer to Pi GPIO pins {{attachment:raspberry-pi_pin-info.png }} Bildquelle: http://raspberrypi.ws/ Creative Commons Lizenz by-cc-sa 4.0 * you need some wires and a small resistor, which you probably have lying around (no extra costs) * very basic soldering knowledge & equipment will be helpful unless you use a breadboard * the example code will use 3.3V, GND and GPIO 4 * check the location of GPIO pins for your specific Pi revision * http://raspberrypi.ws/ * set it up like this: {{attachment:anemometer_led_Schaltplan.png}} * [[attachment:anemometer_led_Steckplatine.png]] * [[attachment:anemometer_led.fzz]] * http://elinux.org/RPi_GPIO_Interface_Circuits - how to interfer with GPIO pins * http://codeandlife.com/2012/07/03/benchmarking-raspberry-pi-gpio-speed/ -- access gpio in various programming languages == costs == * Raspberry Pi kit 70€ * cup anemometer 20€ * battery powered raspberry pi (link are in German) * strom pi aufsatz und dann an Akku ran * http://www.elv.de/zusatzboard-strompi-fuer-raspberry-pi-arduino-u-v-m.html * http://www.elv.de/topic/strompi-bedienung.html * http://www.raspberry-pi-geek.de/Magazin/2014/05/Stromversorgung-per-Windturbine == hardware alternatives == === openwrt based hw e.g. gl-ar150 === * cheaper than pi with power supply and wifi, easy to set up * little less power usage, good hardware documentation * https://wiki.openwrt.org/toh/gl-inet/gl-ar150 * https://wiki.openwrt.org/doc/hardware/port.gpio - read gpio ports on openwrt devices * http://hacklabos.org/2014/04/playing-with-gpio-and-sensors-on-openwrt/ === openwrt cheap consumer ap wr741, wr841 === * http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/gpio * https://wiki.openwrt.org/doc/hardware/port.gpio * https://forum.freifunk.net/t/wr841-i2c-sensoren/12324 * https://trac.raumfahrtagentur.org/wiki/Projekte/muninlite-Wetterstation - muninlite plugin * opkg install micropython muninlite ==== using gpio with just a few inputs/s ==== * https://wiki.openwrt.org/doc/howto/hardware.button * openwrt barrier braker 14.07 {{{ mkdir -p /etc/hotplug.d/button vi /etc/hotplug.d/button/01anemo #!/bin/sh logger button $BUTTON was $ACTION ##good to know which button was pressed ## we use qss aka wps button here [ "$BUTTON" = "wps" ] && [ "$ACTION" = "pressed" ] && { echo 1 > /sys/class/leds/tp-link\:green\:qss/brightness } [ "$BUTTON" = "wps" ] && [ "$ACTION" = "released" ] && { echo 1 > /sys/class/leds/tp-link\:green\:qss/brightness } }}} ==== finding gpios ==== * leds are useable as gpio in- & output pins {{{ echo none > /sys/class/leds/tp-link\:green\:lan4/trigger echo 17 > /sys/class/gpio/export }}} * find out which led is on what gpio: {{{ #!/bin/sh GPIOBASE=`cat /sys/class/gpio/gpiochip*/base | head -n1` GPIOmin=`expr $1 + $GPIOBASE` GPIOmax=`expr $2 + $GPIOBASE` nums=`seq $GPIOmin $GPIOmax` cd /sys/class/gpio for i in $nums; do echo $i > export; echo out >gpio$i/direction done while true; do for i in $nums; do echo 0 > gpio$i/value done sleep 1 for i in $nums; do echo 1 > gpio$i/value done sleep 1 done }}} === pyboard === * low power consumption, pure python * standalone datalogger with sd card out-of-the-box * no network * http://micropython.org/ 40€ === esp8266 === * low power consumption, lua scripting * wifi * <10€ * e.g. NodeMCU Board === arduino === * wide spread, very good documentation * lower power consumption with using libraries like "LowPower" or "Jeelib" * needs hat for sd card, no network * ultra low power is possible for autonomous long term measuring * http://www.re-innovation.co.uk/web12/index.php/en/projects/wind-datalogger - low cost open source wind data logger (arduino) * https://github.com/re-innovation/WindLogger * https://www.openhomeautomation.net/arduino-battery/ - How to Run an Arduino for Years on a Battery * http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer - Windgeschw. & Richtung mit Arduino messen * http://www.geeky-gadgets.com/arduino-wind-speed-meter-anemometer-project-30032016/ - Arduino Anemometer (expensive parts from Adafruit) * https://systemausfall.org/wikis/howto/Arduino - programming with python === pi zero w + mcp3208 === * http://rasp.io/analogzero/ * ca. 40€ * 1W power consumption * wlan, full debian ---- = data aggregation & visualisation = * python script reads the sensor for a few seconds and counts the ticks * munin-plugin calls python script * munin collects the numbers in a rrd database and generates graphs * graphs are published via local lighttpd webserver {{attachment:anemometer_hacking.jpg}} == use GPIO with raspberry pi == * install python gpio api: {{{ aptitude install python-rpi.gpio }}} == use GPIO with Bananapi == * fetch sources from github and install: {{{ git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi sudo apt-get update sudo apt-get install python-dev gcc cd RPi.GPIO_BP python setup.py install }}} == get reed switch state via gpio == * create the scriptfile at /usr/local/bin/anemometer.py {{{ #!/usr/bin/env python '''munin plugin for reading anemometer pulses on gpio pins on raspberry pi''' import time, sys import RPi.GPIO as GPIO class anemometer(): def __init__(self): ''' initialize the pin for the anemometer sensor ''' self.SENSOR_PIN = 4 self.count = 0 # tell the GPIO module that we want to use the chip's pin numbering . scheme GPIO.setmode(GPIO.BCM) # setup pin as an input with pullup GPIO.setup(self.SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # threaded event, to detect voltage falling on anemometer # bouncetime is in ms - edges within this time will be ignored GPIO.add_event_detect(self.SENSOR_PIN, GPIO.FALLING, bouncetime=30) self.starttime = time.time() # deal with events by calling a function GPIO.add_event_callback(self.SENSOR_PIN, self.inputEventHandler) def inputEventHandler(self, pin): ''' count the edges and calculate windspeed... with "triggerflanke" you decide how much falling edges to count until we start the speed calculation small values will result in short reaction time und precise values high values will take longer and give a good average over the time very high values may need a longer sleep value in the main method espacially at low wind speeds ''' self.count += 1 triggerflanke = 10 if self.count == triggerflanke: # the sensor ticks twice per rotation (2 falling edges) # so with triggerflanke=20 this happens after ten rotations currenttime = (time.time() - self.starttime) # calculating windspeed windspeed = triggerflanke / (currenttime * 1.3) # exit printing the windspeed sys.exit(windspeed) def cleanup(self): GPIO.cleanup() # don't leave a mess if __name__ == "__main__": anemometer = anemometer() time.sleep(20) sys.exit(0) # no data - no wind - return 0 }}} * http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-2 - get GPIO edges * https://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/ - read gpio inputs * http://abyz.co.uk/rpi/pigpio/ - read more precise with pigpio (wasn't necessary for this project) * http://www.eng.utah.edu/~cs5780/debouncing.pdf - about bouncing and how to handle it properly == munin plugin == {{attachment:anemometer-stadthafen_rostock.png}} * now that we can aggregate the windspeed data let's collect it properly * install munin software: {{{ aptitude install munin munin-node }}} * create a new plugin /etc/munin/plugins/anemometer {{{ #!/usr/bin/python ## this plugin starts a python script to return sensors data import os, re, sys, urllib, subprocess # check pluginname for sensors (anemometer_sensorname) sensor = os.environ.get('code', sys.argv[0][(sys.argv[0].rfind('_') + 1):]) if sensor == None: sensor = 1 if len(sys.argv) == 2 and sys.argv[1] == "autoconf": print "yes" elif len(sys.argv) == 2 and sys.argv[1] == "config": print 'graph_title windspeed by sensor' print 'graph_vlabel windspeed in m/s' print 'graph_category sensors' print 'graph_args --base 1000 -l 0' print 'windspeed.label Sensor %s' % sensor else: cmd = "python /usr/local/bin/anemometer.py" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell = True, stderr=subprocess.STDOUT) speed, speed_err = p.communicate() print 'windspeed.value %s' % str(speed) }}} * allow plugin running as root in: /etc/munin/plugin-conf.d/munin-node {{{ [anemometer] user root }}} * test with''munin-run -d anemometer'' this should print one line * used theme for webfrontend "munstrap" * read further * https://m21.hyte.de/wiki/Projekte/muninlite-Wetterstation - Munin Plugin schreiben * http://munin-monitoring.org/wiki/SpikeRemoval - ungewollte Werte entfernen == webserver config == * install lighttpd webserver: {{{ aptitude install lighttpd }}} * /etc/lighttpd/conf-enabled/30-munin.conf {{{ fastcgi.server = ( "/munin-cgi/munin-cgi-graph" => (( "bin-path" => "/usr/lib/munin/cgi/munin-cgi-graph", "socket" => "/var/run/lighttpd/munin-cgi-graph.sock", "check-local" => "disable", )) ) alias.url += ( "/munin/" => "/var/cache/munin/www/" ) }}} * activate fastcgi in lighttpd (needed for zooming in munin graphs): {{{ lighty-enable-mod fastcgi }}} * restart webserver {{{ systemctl restart lighttpd.service }}} * check http://localhost/munin/ in a browser at the Pi * or replace "localhost" with the IP address if you work via network