ArduCounter: Unterschied zwischen den Versionen

Aus FHEMWiki
(Description of the module ArduCounter created)
 
(FHEM(R))
Zeile 11: Zeile 11:


The arduino board counts impulses on every configured input pin using pin change interrupts. It reports the counted number of impulses per pin together with the time between the first and last impulse per pin.
The arduino board counts impulses on every configured input pin using pin change interrupts. It reports the counted number of impulses per pin together with the time between the first and last impulse per pin.
The module converts this to readings like power consumption and it is not affected by delays or the load of your fhem server.
The module converts this to readings like power consumption and it is not affected by delays or the load of your FHEM server.
Counters are configured using attributes that define which Arduino pins should count pulses and in which intervals the counted numbers should be reported.
Counters are configured using attributes that define which Arduino pins should count pulses and in which intervals the counted numbers should be reported.



Version vom 24. Januar 2017, 17:45 Uhr

ArduCounter
Zweck / Funktion
Count pulses, calculate time between pulses and convert this to readings for e.g. power consumption of Energy meters
Allgemein
Typ Contrib
Details
Dokumentation Thema
Support (Forum) Sonstiges
Modulname 98_ArduCounter.pm
Ersteller StefanStrobel (Forum / Wiki)
Wichtig: sofern vorhanden, gilt im Zweifel immer die (englische) Beschreibung in der commandref!

The ArduCounter module works together with an arduino board connected via usb that runs the provided ArduCounter.ino sketch to count impulses from energy meters with an S0 interface or similar devices in configurable intervals.

The arduino board counts impulses on every configured input pin using pin change interrupts. It reports the counted number of impulses per pin together with the time between the first and last impulse per pin. The module converts this to readings like power consumption and it is not affected by delays or the load of your FHEM server. Counters are configured using attributes that define which Arduino pins should count pulses and in which intervals the counted numbers should be reported.

Availability

The module has been checked in to the contrib area.

The corresponding arduino sketch can also be found under contrib in the subdirectory arduino/.

Prerequisites

This module requires Device::SerialPort or Win32::SerialPort module as well as an arduino uno, nano, jeenode or similar device that runs the ArduCounter sketch.

Define

define <name> ArduCounter <device>

<device> specifies the serial port to communicate with the Arduino.

The name of the serial-device depends on your distribution. You can also specify a baudrate if the device name contains the @ character, e.g.: /dev/ttyUSB0@9600

Example:

define AC ArduCounter /dev/ttyUSB2@9600

Configuration of the module

Specify the pins where S0 interfaces are connected to as

attr AC pinX rising pullup

The X in pinX can be an Arduino pin number with or without the letter D e.g. pin4, pin5, pinD4, pinD6 ... After the pin ypu can define if rising or falling edges of the signals should be counted. The optional keyword pullup activates the pullup resistor for the given Arduino Pin.

Example:

define AC ArduCounter /dev/ttyUSB2@9600
attr AC factor 1000
attr AC interval 60 300
attr AC pinD4 rising pullup
attr AC pinD5 rising pullup

this defines two counters connected to the pins D4 and D5, each with the pullup resistor activated. Impulses will be counted when the signal changes from 0 to 1. The ArduCounter sketch which must be loaded on the Arduino implements this using pin change interrupts, so all avilable input

Get-Commands

info
send the internal command show to the Arduino board to get current counts. This is not needed for normal operation but might be useful sometimes for debugging.

Set-Commands

raw
send the value to the Arduino board so you can directly talk to the sketch using its commands. This is not needed for normal operation but might be useful sometimes for debugging.

Supported readings

pinX
the counted total of impulses for pin X
powerX
the result of (delta count) / (delta time) * factor.
the number of pulses counted during the last reporting interval diveded by the time between the first pulse and the last pulse in the interval, multiplied by a configurabe factor.

Attributes

do_not_notify
...
pin.*
Define a pin of the Arduino board as input. This attribute expects either rising, falling or change as value, followed by on optional pullup.
interval
Define the reporting interval after which the Arduino board should hand over the count and the time from first to last impulse per pin.
This Attribute expects two numbers as value. The first is the minimal interval, the second the maximal interval.
Nothing is reported during the minimal interval. The Arduino board just counts and remembers the time between the first impulse and the last impulse for each pin.
After the minimal interval the Arduino board reports count and time for those pins where impulses were encountered.
If no impulses were encountered, the pin is not reported until the second interval is over.
The default intervals are 60 seconds as minimal time and 5 minutes as maximum interval.
factor
Define a multiplicator for calculating the power from the impulse count and the time between the first and the last impulse