Difference between revisions of "EmonTx V3.4"
|Line 233:||Line 233:|
Whilst the system was designed to transfer data via radio it is possible to link the emonTx and
Whilst the system was designed to transfer data via radio it is possible to link the emonTx and by wires. It should be noted that this is NOT the standard setup.
====Direct connection emonTx V3 > Raspberry Pi GPIO====
====Direct connection emonTx V3 > Raspberry Pi GPIO====
|Line 282:||Line 295:|
[Ctrl+X] then [y] then [Enter] to save and exit
[Ctrl+X] then [y] then [Enter] to save and exit
Revision as of 10:02, 28 November 2014
- 1 emonTx V3.4
- 1.1 Features
- 1.2 Port Map
- 1.3 Overview
- 1.4 DIP Switch Config
- 1.5 Power Supply Options
- 1.6 Uploading Arduino Firmware
- 1.7 Standard Operation
- 1.8 Extended Operation
- 1.9 Connectivity
The emontx V3.4 is the latest version of the emonTx Low Power Wireless Energy Monitoring Node designed for monitoring AC electrical power on (up to) 4 separate (household/building) circuits using non-invasive clip on CT current sensors and an AC-AC Voltage adaptor to provide a voltage signal for full Real Power calculations. The emonTx V3.4 is a minor update over the emonTx_V3
Photo's of emonTx V3.4
New features on emonTx V3.4 over V3 shown in bold
- Measure AC Apparent Power, AC Real power* and AC RMS voltage*
- 3 x single-phase CT current sensor inputs (100A / 24KW @ 240V max)
- 1 x high sensitivity single-phase CT current sensor input channel (18.8A / 4.5KW @ 240V max)
- 1 x RJ45 input for connecting DS18B20 temperature sensors
- Single AC-AC adapter can power the unit and provide AC voltage measurement
- An on-board 3x AA battery option with remote monitoring of battery voltage
- Terminal block access to power rails, digital and analogue I/O and IRQ port for connecting pulse counting sensor / DS18B20 temperature / Aux sensors
- DIP switch selection of RF node ID and 240V/110V AC adapter selection, see #DIP Switch Config
- when AC-AC voltage adapter is connected
Using an ATmega328 microprocessor the emonTx V3.4 runs standard Arduino sketches and is easy to customise and upload code using the Arduino IDE and a USB to UART cable.
The data from the emonTx V3.4 is transmitted via wireless RFM12B / RFM68CW (433/868Mhz) to an emonBase web-connected base-station (we recommend a Raspberry Pi with an RFM12Pi) which then posts the data onto an emoncms server (e.g. http://emoncms.org) for logging, processing and graphing.
DIP Switch Config
The emonTx V3.4 has a couple of DIP switches allowing changing of node ID and setting UK/EU or US AC-AC adapter calibration without having to change the firmware. The unit must be restarted after changing DIP switch positions. Default DIP switch selection (both off) is node ID 10 and 240V AC.
Power Supply Options
There are four ways to power the emonTx V3:
- USB to UART cable - only recommended for short periods while programming, it is recommended to remove all other power sources
- 5V DC Mini-USB cable - remove jumper JP2 when powering via DC if AC adapter is present
- 3 x AA Batteries - remove jumper JP2 when powering via DC if AC adapter is present
- 9V AC-AC power adapter - with jumper JP2 closed (If jumper 2 is left open then the AC-AC adapter will be used for power sampling but not to power the emonTx V3 - see Powering via AC below)
Powering via DC (1-3)
When powering the emonTx V3 via DC (1-3) (and running the main emonTx firmware (emonTxV3_RFM12B_DiscreteSampling)) the emonTx V3 will take Apparent Power measurements, measuring only current, assuming the Power Factor of 1 and Vrms to be 230V, power saving mode will also be implemented, going into sleep mode in between readings (default every 10s) to save battery power.
The red LED indicator will illuminate for a couple of seconds then extinguish never to flash again if powering from a DC source. If the LED flashes multiple times at startup this indicates the emonTx is detecting an AC waveform - this can happen if an AC adapter has just been removed, hit the reset button if this occurs. When powering the unit via 5V USB/battery it is advisable to remove the JP2 jumper if an AC-AC adapter is present.
Powering via AC (4)
A nice feature of the emonTx V3 is the ability to use an AC-AC adapter to power the unit at the same time as simultaneously providing an AC voltage waveform sample. If the emonTx V3 detects the presence of an AC waveform (AC adapter connected) at startup it will automatically implement Real Power and Irms measurements by sampling the AC waveform. Real Power is what you get billed for and can sometimes (depending on the appliances connected to the circuit being monitored) vary significantly from Apparent Power - see Building Blocks for more info on AC power theory. For best power monitoring accuracy we recommend powering with an AC-AC adapter whenever possible.
Using the AC voltage waveform for reference also enables the emonTx to monitor the direction of the current flow, this is important for solar PV monitoring, if you notice a negative reading when you were expecting a positive one, flip the orientation of the CT. The red indicator LED will flash at startup then flash once every 10's to indicate that an AC waveform has been detected. Sleep mode will be disabled to keep a more consistent power draw on the AC circuit.
Important note regarding powering with AC: powering via AC is only recommended for standard emonTx operation without auxiliary sensors (apart from up to 4 DS18B20 temperature sensors) or equipment (e.g. relay modules) connected. Correct operation via the ac supply is critically dependant upon using the correct ac-ac adapter. If you are using the recommended ac-ac adapter and the current draw exceeds 10 mA and the mains supply is below the minimum allowable, then the circuit operation will be impaired, adversely affecting the reading accuracy of the emonTx. To avoid damage to the emonTx V3's circuits the current drawn from the AC circuit should never exceed 60mA - see technical wiki for more info. If more than 10mA of current is required it is recommended to remove jumper 2 (JP2) and power the emonTx via 5V USB. If an AC-AC adapter is connected it will only be used to provide an AC sample when JP2 is removed.
Uploading Arduino Firmware
Compiling and Uploading using Arduino IDE
The emonTx V3 uses the ATmega328 microcontroller (same as Arduino Uno) and comes with the Optiboot (Arduino Uno) serial bootloader installed. This makes it super easy to upload new code to the emonTx V3 from the Arduino IDE.
A USB to UART cable is required to upload new Arduino firmware sketches
Start by downloading the firmware, libraries and setting up the Arduino programming environment by following this guide:
Once complete the emonTx V3 firmware location should be navigable from within the Arduino IDE by going to:
File > Sketchbook > OpenEnergyMonitor > emonTxFirmware > emonTxV3
Flashing Pre-compiled .hex
The main emonTx V3.4 for RFM69CW  firmware as pre-loaded onto pre-build emonTx is also supplied as a pre-compiled .hex file.
GitHub can be used to make sure you have the latest version:
Linux : use AVRdude
$ sudo apt-get install avrdude
$ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyUSB0 -b 115200 -U flash:w:emonTxV3_RFM69CW_DiscreteSampling_433.cpp.hexx
Specifying the USB port of your USB to UART programmer and the correct name and location of the .hex file
Windows :you might be able to use the the XLoader application to upload .hex files (we have not tested this ourselves, please update wiki if you have)
Flashing the Bootloader
Should not be required
The OptioBoot Arduino Uno serial bootloader should be ready loaded onto the ATmega328 on the emonTx in the factory. If however for any reason you need to re-upload the bootloder and set the fuses this can be done:
The stock emonTx firmware can be downloaded in pre-compiled .hex form including the bootloader from github, look for .hex file including the word bootloader in the title on the emonTx V3 GitHub.
The .hex file can be flashed, and the fuses set, on the ATmega328 using the following avrdude command:
$ sudo avrdude -v -p atmega328p -c avrispmkII -P usb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m -U flash:w:emonTxV3_4_RFM12B_DiscreteSampling_bootloader.cpp.hex:i -Ulock:w:0x0F:m
or to speed things up:
$ sudo avrdude -V -u -p atmega328p -c avrispmkII -P usb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m -U flash:w:emonTxV3_4_RFM12B_DiscreteSampling_bootloader.cpp.hex:i -Ulock:w:0x0F:m
If, for any reason (e.g to make a backup) you want to read the data back from the ATmega328 this can be done with:
$ avrdude -v -p atmega328p -c avrispmkII -P usb -U flash:r:test_intel.hex:i
Arduino Firmware Info
See GitHub readme for firmware info:
All emonTx V3 firmware is available on Github:emonTxFirmware
All emonTx V3's sold pre-assembled are shipped with Discrete Sampling firmware. This is the main firmware for the emonTx V3 and has been tested and calibrated. This firmware has the following features:
- Detection of AC-AC adapter sets Apparent Power / Real Power Sampling accordingly
- Detection of battery / USB 5V or AC > DC power method and sets sleep mode accordingly
- Detection of CT connections and samples only from the channels needed
- Detection of remote DS18B20 temperature sensor connection
[Note: Detection of the inputs in use takes place at power-on. The sketch must be re-started (press the reset button) if any change is made to the input connections.]
The emonTxV3_RFM12B_Discrete Sampling firmware samples over 10 full AC cycles, so 200ms per measurement on each CT. Within this measurement it samples rapidly at about 2500 samples per second. There is then an assumption that the power does not fluctuate significantly in the time it is asleep, which is usually good enough for typical household monitoring. If greater precision is required (as is the case with PV Power Diversion it is recommended that you use PLL continuous sampling, see RFM12B firmware examples folder on GitHub.
CT Energy Monitoring
A DS18B20 digital temperature sensor can easily be connected by the emonTx V3 by connecting the sensor into the emonTx V3's screw terminal block or RJ45 connector. The default firmware (discrete sampling) supports auto-detecting one DS18B20 sensor. Many DS18B20's can be daisy-chained but this will require changes being made to the pre-installed emonTx firmware - you may also run into power draw issues depending on how you are powering the emonTx (see Power Supply Options above).
In order to save power when running off batteries the emonTx V3 supports switching off of the DS18B20 in-between readings and performing the temperature conversion while the ATmega328 is sleeping. To do this power (3.3V) is supplied to the DS18B20's power pin from Dig5, this digital pin is switched off between readings. The data connection from the DS18B20 is connected to Dig19, this I/O pin has got a 4K7 pull-up resistor on-board the emonTx V3's PCB as required by the DS18B20.
A DS18B20 sensor can be connected directly into the RJ45 socket, or an RJ45 to terminal block breakout can be used to connect multiple sensors:
Further RJ45 breakouts are available from Sheep Walk Electronics
The emonTx uses a standard RJ45 DS18B20 pin-out as used by Sheepwalk Electronics and others:
Terminal Block Connection
To connect an external DS18B20 to the emonTx V3 screw terminal block connections are as follows
|Screw terminal pin||DS18B20 Connection|
|3 - GND||GND (Black)|
|5 - Dig19||Power (Red)|
|6 - Dig5||Data (White)|
Utility Meter Interface
Optical Pulse Counting
Many meters have pulse outputs, including electricity meters (single phase, 3-phase, import and export), gas meters, water flow meters etc. The pulse output may be a flashing LED or a switching relay (usually solid state) or both. We recommend using the optical interface where available as this decouples the monitoring equipment from any high/mains voltages.
In the case of an electricity meter, a pulse output corresponds to a certain amount of energy passing through the meter (kWh/Wh). For single-phase domestic electricity meters (eg. Elster A100c) each pulse usually corresponds to 1 Wh (1000 pulses per kWh). For water and gas meters they will usually be marked to show the quantity of water (litres/gallons) or of gas (cubic meters/cubic feet) that each pulse represents.
The emonTx V3 has one interrupt input (IRQ 0, Dig2) which can be used for pulse counting. This is broken out on terminal block port 4
Read more about pulse counting on the OpenEnergyMonitor Buillding Block pagers here
emonTx V3 Hardware Connections
You should connect the pulse input into emonTx V3 terminal block port 4 (IRQ 0 / Digital 2) If you are connecting a hard-wired pulse output you may need to add a pull-down resistor onto the emonTx V3 PCB (R31) If you are using an optical counter (e.g TSL257) you should connecting the power pin to the 3.3V or 5V (if running off 5V USB)
|Screw terminal pin||Connection|
|1||5V (if powered via 5V USB)|
|4||IRQ 0 / Dig2|
We recommend powering the emonTx V3 from either a 5V USB or AC_AC adapter when used for pulse counting operation. Due to the additional power requirements of the optical pulse sensor, battery life will be significantly reduced compared to running an emonTx from 3 x AA batteries for CT operation only.
Direct Optical Interface
if you have an Elster meter (tested with Elster 100C) the emonTx V3 with an IR TSL261R sensor can be used to interface directly with the meter protocol to read off the exact accumulated watt hours that you have generated or used. This reading can be used on it's own or to cross-check and calibrate CT based measurement. See here for original blog post
The emonTx communicates data back to a web-connected base station ([shop.openenergymonitor.com/base-stations/ Raspberry Pi with RFM12Pi / RFM69Pi]) via low power 433Mhz / 868 Mhz RF
See RFM12B Building Block documentation:
Whilst the system was designed to transfer data via radio it is possible to link the emonTx and Raspberry Pi by wires. It should be noted that this is NOT the standard setup.
Direct connection emonTx V3 > Raspberry Pi GPIO
Both the raspberry pi and emontx v3 run at 3.3V so the serial RX and TX lines can connect ok. Im using the raspberrypi's 5V supply to supply the emontx with 5V power which is then stepped down to to 3.3V through the emonTx V3's voltage regulator, 5V is provided by the red wire. The ground connection is the black wire and the data going from the emontx to the raspberrypi is the green wire. I haven't connected a wire for data going the other way but this is a possible option if two-way serial is required.
Here's a simple direct serial output sketch for the emontx v3 on GitHub here
On the raspberrypi if you just want to forward the emontx data to a remote emoncms this can be done with the oem_gateway developed by Jerome which is on the standard rock solid forwarder image
See our blog post about how to configure the oem_gateway for work over a serial link rather than RFM12B RF:
The main thing you need to add to the oemgateway.conf file is the serial listener config:
<code> [[Serial]] type = OemGatewaySerialListener [[[init_settings]]] com_port = /dev/ttyAMA0 [[[runtime_settings]]] </code>
Then add the location and apikey of the emoncms server your posting too in the buffers section.
Its worth noting that the standard emontx firmware which has all the rfm12b radio packet sending code also prints a space separated string to its serial port which should work the same as the cut down serial only example above although you will still be sending radio packets.
If your using a stock Raspbien image or any other image other then the OpenEnergyMonitor ready-to-go SD card images you will need to remove the internal UART port (ttyAMA0) which is broken out on the GPIO from the console so we can read from it. To do this following:
To do this we need to access the file /boot/cmdline.txt which is mounded on a Read Only boot partition, easiest way to edit this file is to insert the Pi's SD card in a computer and edit that file there. Remove the text that make reference to the UART i.e. console=ttyAMA0,115200 kgdboc=ttyAMA0,115200
Then insert the SD card back into the Pi and edit initab
$ nano /etc/inittab
At the bottom of the file comment out the line (by adding a ‘#’ at beginning)
# T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
[Ctrl+X] then [y] then [Enter] to save and exit