Difference between revisions of "EmonTx Arduino Shield"

From OpenEnergyMonitor Wiki
Jump to: navigation, search
m
 
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
=emonTx Arduino Shield=
 
=emonTx Arduino Shield=
'''An open-hardware wireless energy monitoring Arduino compatible (Duemilanove,Uno and Leonardo) shield.'''  
+
'''An open-hardware wireless energy monitoring Arduino compatible shield.'''  
 +
 
 +
'''[https://wiki.openenergymonitor.org/index.php/EmonTx_Arduino_Shield Purchase from OpenEnergyMonitor shop]
  
 
{|
 
{|
[[File:EmonTx Shield top3D.png|400 px|emonTx Shield Front]]
+
[[File:EmonTx_Shield_NanodeRF_1CT.jpg|600 px|emonTx Shield Front]]
[[File:EmonTx_Shield_Back.png|300 px|emonTx Shield Back]]
+
 
  
 
|}
 
|}
  
See non-invasive section of [http://openenergymonitor.org/emon/buildingblocks building blocks ] for theory behind CT energy monitoring.
+
See the ''non-invasive'' section of [http://openenergymonitor.org/emon/buildingblocks building blocks ] for theory behind CT-based energy monitoring.
 
==Overview==
 
==Overview==
 
*Apparent Power, Real Power*, Power Factor* and AC RMS voltage readings*  
 
*Apparent Power, Real Power*, Power Factor* and AC RMS voltage readings*  
*4 x CT Current Sensor input
+
*4 x CT Current Sensor inputs
 
*AC 9V RMS voltage sensor input
 
*AC 9V RMS voltage sensor input
*433/868Mhz RFM12B  / RFM69CW(HopeRF) wireless transceiver to transmit/receive data to other OpenEnergyMonitor and JeeNode modules
+
*433/868MHz RFM12B  / RFM69CW(HopeRF) wireless transceiver to transmit/receive data to other OpenEnergyMonitor and JeeNode modules
 
*On-board DS18B20 digital temperature sensor (not included as standard)
 
*On-board DS18B20 digital temperature sensor (not included as standard)
 
*Status LED
 
*Status LED
*Compatible with Duemilanove,Uno and Leonardo
+
*Compatible with Duemilanove, Uno and Leonardo
 
*Compatible with OpenEnergyMonitor modules (emonGLCD, emonBase - NannodeRF etc.)
 
*Compatible with OpenEnergyMonitor modules (emonGLCD, emonBase - NannodeRF etc.)
 
<nowiki>
 
<nowiki>
Line 22: Line 24:
  
 
==Design Files & Part List==
 
==Design Files & Part List==
 
{| class="wikitable"
 
!Quantity
 
!Part
 
|-
 
|10x
 
|470K (yellow, violet, yellow, gold)
 
|-
 
|5 x
 
|10uF
 
|-
 
|4x
 
|33R 1% (orange, orange, black, gold, brown)
 
|-
 
|4x
 
|10K 1% (brown, black, black, red, brown)
 
|-
 
|4x
 
|4K7 (yellow, violet, red, yellow, gold)
 
|-
 
|4x
 
|3.5mm jack (Rapid: 20-0157)
 
|-
 
|1x
 
|0.1uF (100nF)
 
|-
 
|1x
 
|470R (yellow, violet, brown, gold)
 
|-
 
|1x
 
|100K 1% (brown, black, black yellow, brown)
 
|-
 
|1x
 
|2.1mm DC barrel
 
|-
 
|1x
 
|RFM12B / RFM69CW 868/433Mhz (HopeRf)
 
|-
 
|1x
 
|82mm/165mm Ant
 
|-
 
|1x
 
|3mm LED
 
|-
 
|''1x''
 
|''DS18B20 temperature sensor (not included as standard)''
 
|-
 
|1x
 
|6 pin ISP header (female)
 
|-
 
|2x
 
|6 pin header*
 
|-
 
|2x
 
|8 pin header*
 
|-
 
|}
 
<nowiki>
 
* </nowiki>or 1 x 28 pin header
 
 
  
 
See OpenEnergyMonitor Shop for [http://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct recommended CT] and [http://shop.openenergymonitor.com/components/ recommended plug-in AC-AC adapter]
 
See OpenEnergyMonitor Shop for [http://shop.openenergymonitor.com/100a-max-clip-on-current-sensor-ct recommended CT] and [http://shop.openenergymonitor.com/components/ recommended plug-in AC-AC adapter]
  
See [http://openenergymonitor.org/emon/buildingblocks building blocks] for more information on CT's and AC-AC adapters.
+
See [http://openenergymonitor.org/emon/buildingblocks building blocks] for more information on CTs and AC-AC adapters.
  
'''The emonTx Shield schematic and board design in Eagle CAD format can be viewed and downloaded from the [http://solderpad.com/openenergymon/emontx-shield emonTx Shield SolderPad Git Repo]'''
+
'''The emonTx Shield schematic and board design, in Eagle CAD format, can be viewed and downloaded from the [https://github.com/openenergymonitor/Hardware/tree/master/emontx-shield-smt emonTx Shield GitHub]''' page.
  
 
==Build Guide==
 
==Build Guide==
Follow the component labels on the PCB using the part list above to identify the components and the completed build photo below to double check the correct placement. If you are going to use a current transformer with an internal burden resistor (e.g. the YHDC SCT-013-030 or another "voltage output" type), do not fit the 33 &Omega; resistor for that input channel:
 
  
 +
[[File:Shield_components.jpeg|600 px|emonTx Shield SMT PCB & Thru-Hole Components]]
  
[[File:EmonTxShiledV1.0_front_web.png|200 px|emonTx Shield Top]] [[File:EmonTxShiledV1.0_rear_web.png|200 px|emonTx Shield Top]]
+
You will need to add the various connectors to the pre-assembled circuit board:
  
[[File:EmonTx Shield top2D.png|300 px|emonTx Shield Top]]
+
The RFM12B / RFM69CW radio module goes onto the pads marked with its outline, ensuring that it is the correct way round. If you are in any doubt about the orientation of the radio module, the antenna pin on the radio is at the top left in all the photos here [link: https://learn.openenergymonitor.org/electricity-monitoring/networking/which-radio-module], and it must line up with the antenna pad, which is next to the large hole by C2.
 +
 
 +
You must solder an antenna into that large hole. The RFM69CW can be damaged if it is operated at or near full power without the correct antenna.
 +
 
 +
'''Caution''': The connectors for the Arduino headers, ISP, a.c adapter and c.t’s go on the opposite side to the radio module and the small components. The screw connector block, FTDI and links go on the same side as the radio module and the small components. Refer to the pictures below. If you cover over the label “CT1” etc, the socket is on the wrong side.
 +
 
 +
If you will be using a current transformer with an internal burden resistor (e.g. the YHDC SCT-013-030 or another “voltage output” type), you must remove the 33 Ω resistor for that input channel. If you are using a c.t. that requires a different value of burden, a wire-ended resistor can be soldered in the holes provided at each end of the fitted 33 Ω resistor. If the value of burden that you need is higher than 33 Ω, you will need to remove the fitted 33 Ω resistor. If lower, you can add a parallel resistor to bring the combined resistance down to the correct value.
 +
 
 +
[[File:EmonTx_Shield_Assembled.jpg|300 px|emonTx Shield Top]] [[File:EmonTx_Shield_rear.jpg|300 px|emonTx Shield Top]]
 +
 
 +
[[File:EmonTx_Shield_SMT_RFM69CW.jpg|300 px|RFM69CW]]
  
  
Line 102: Line 54:
  
  
On the top of the board there are two solder jumpers which '''need to be connected before emonTx Shield can operate'''. To make connection the middle solder pad should be connected with a blob of solder to either the left of right solder pad, depending on the connection required. The solder can be re-melted and adjusted at a later date if required.
+
On the top of the board, there are two solder jumpers (older boards only) which '''need to be connected before the emonTx Shield can operate'''. On later boards, these have been replaced by header pins and jumper links.
 
   
 
   
  
Line 110: Line 62:
 
====RFM12B / RFM69CW Slave Select (SS) Solder Jumper Setting====  
 
====RFM12B / RFM69CW Slave Select (SS) Solder Jumper Setting====  
  
 +
The left hand solder jumper determines which Arduino digital I/O is used for the RFM SS pin. Digital 10 is the [http://github.com/jcw/jeelib JeeLib library] default. '''For standard operation, connect the solder jumper to 10 by connecting the middle pad to the left pad shown in [http://wiki.openenergymonitor.org/index.php?title=File:EmonTx_Shield_top2D.png this image]. '''
  
 +
However if Digital 10 is required by another shield (e.g Arduino Ethernet) another free digital pin can be used as the RFM SS pin. There are two options available. The first option requires hardware modification, the second requires software modification. We recommend the first option:
  
The left hand solder jumper determines which Arduino digital I/O is used for the RFM SS pin. Digital 10 is the default for the [http://github.com/jcw/jeelib JeeLib library]. '''For standard operation Connect the solder jumper to 10 by connecting the middle pad to the left pad shown in the [http://wiki.openenergymonitor.org/index.php?title=File:EmonTx_Shield_top2D.png this image]. '''
 
  
 +
; '''Option 1''':
 +
* Ensure the RFM12B SS pin solder jumper is not connected (middle pad not soldered to either left or right pads).
 +
* Solder a wire from the middle pad to either Digital 8 or 9. There is a hole available for this, see the image above.
 +
* Make sure you are using the latest [http://github.com/jcw/jeelib JeeLib library]
 +
* Add the line <code> rf12_set_cs(8) </code> or <code> rf12_set_cs(9) </code> depending on your chosen pin, before <code>rf12 initialise</code> in the <code>void setup()</code> section of your sketch. 
 +
* The steps above work for both Arduino Uno (ATmega328) and Lenoardo (ATmega32u4)
  
However if Digital 10 is required by another shield (e.g Arduino Ethernet) another free digital pin can be used for the RFM CS pin. There are two options available to do this. The first option requires more hardware modification, while the second requires more software modification. We recommend the first option:
 
  
# '''Option 1''':
+
; '''Option 2''':
#* Ensure the RFM12B CS pin solder jumper is not connected (middle pad not soldered to either left of right hand pads).
+
* Digital 5 can be used as the RFM SS pin by connecting the solder jumper the other way.  
#* Solder a wire from the middle pad to either Digital 8 or 9. There is a hole available for this, see the image above.
+
* Modifying the JeeLib library is required since Digital 5 is on a different port
#* Make sure you are using the latest [http://github.com/jcw/jeelib JeeLib library]
+
* For pin 5 to be used as the CS pin the line <code> rf12_set_cs(5) </code> must be added before <code>rf12 initialise</code> in <code>void setup()</code>.  
#* In your sketch, add the line <code> rf12_set_cs(8) </code> or <code> rf12_set_cs(9) </code> depending on your chosen pin, before rf12 initialise in void setup. 
+
* The following lines must be added to RF12.cpp in the JeeLib library in the <code> void rf12_set_cs(uint8_t pin) </code>function:
#* The steps above work for both Arduino Uno (ATmega328) and Lenoardo (ATmega32u4)
+
 
+
#'''Option 2'''
+
#* Digital 5 can be used as the RFM CS pin by connecting the solder jumper up the other way.  
+
#* Modifying the JeeLib library is required since Digital 5 is on a different port
+
#* For pin 5 to be used as the SS pin the line <code> rf12_set_cs(5) </code> must be added before rf12 initialise in void setup.  
+
#* and the following lines must be added to RF12.cpp in the JeeLib library in the <code> void rf12_set_cs(uint8_t pin) </code>function:
+
  
  
Line 184: Line 135:
  
  
The right hand solder jumper sets the RFM12B interrupt pin. The setting of this jumper depends on which Arduino board the shield is connected. '''Connect the jumper to Digital 2 for Arduino Uno/Duemilanove or Digital 3 for Arduino Leonardo.''' These pins connect to the special hardware interrupt pin INT0.
+
The right hand solder jumper sets the RFM12B interrupt pin. The setting of this jumper depends on which Arduino board the shield is connected to. '''Connect the jumper to Digital 2 for Arduino Uno/Duemilanove or Digital 3 for Arduino Leonardo.''' These pins connect to the special hardware interrupt pin INT0.
  
  
For more information on RFM12B connection to Arduino see this [http://openenergymonitor.org/emon/buildingblocks/rfm12b-wireless this building block section]
+
For more information on RFM12B & RFM69CW connection to Arduino, see this [https://learn.openenergymonitor.org/electricity-monitoring/networking/rfm12_69 this building block section]
For RFM69CW see [openenergymonitor.org/emon/buildingblocks/RFM69cw this building block section]
+
  
  
 
===Arduino Compatibility===
 
===Arduino Compatibility===
  
Some Arduino clone boards that have on-board Ethernet (e.g. one made by Freetronics in Australia) and some Ethernet Shields appear to use Analog I/O for purposes connected with the Ethernet controller. This is not compatible with the use of that analogue input(s) for voltage or current measurements. On the Freetronics unit, it appears that there are pull-up resistors for the MAC address chip attached to A4 and A5 that can be disconnected by cutting track jumpers, which when cut disable MAC addressing but enable proper use of CT 4 input for current measurements.
+
Arduino clones that have on-board Ethernet (e.g. at least one of the Australian-made Freetronics boards) and some Ethernet Shields appear to use Analog I/O for purposes connected with the Ethernet controller. This is not compatible with the use of the analogue input(s) for voltage or current measurements. On the Freetronics unit, it appears there are pull-up resistors for the MAC address chip attached to A4 and A5 that can be disconnected by cutting track jumpers to disable MAC addressing, but enable use of CT 4 input for current measurements.
 
More details can be found here:
 
More details can be found here:
 
[http://forum.freetronics.com/viewtopic.php?f=4&t=6024 freetronics forum] and  
 
[http://forum.freetronics.com/viewtopic.php?f=4&t=6024 freetronics forum] and  
 
[http://openenergymonitor.org/emon/node/5624#comment-23409 OpenEnergyMonitor forum]
 
[http://openenergymonitor.org/emon/node/5624#comment-23409 OpenEnergyMonitor forum]
  
 +
'''The EmonTx Arduino shield is not compatible with other Arduino shields that use I2C. [https://community.openenergymonitor.org/t/emontx-shield-and-lcd-l2c-freezes-with-bad-values-on-ct3/1006/24 see forum thread discussion]'''
 +
 +
'''Pin use'''
 +
 +
[[File:pin_use.png]]
  
 
==Example Arduino Sketches==
 
==Example Arduino Sketches==
  
See emonTx Shield Folder in [https://github.com/openenergymonitor/emonTxFirmware emonTx Firmware examples GitHub Repo]
+
See the emonTx Shield Folder in [https://github.com/openenergymonitor/emonTxFirmware emonTx Firmware examples on the GitHub Repo]
  
Follow instructions on the GitHub readme for required Arduino libraries
+
Follow the instructions in the GitHub readme for the required Arduino libraries

Latest revision as of 12:47, 20 June 2018

emonTx Arduino Shield

An open-hardware wireless energy monitoring Arduino compatible shield.

Purchase from OpenEnergyMonitor shop

emonTx Shield Front

See the non-invasive section of building blocks for theory behind CT-based energy monitoring.

Overview

  • Apparent Power, Real Power*, Power Factor* and AC RMS voltage readings*
  • 4 x CT Current Sensor inputs
  • AC 9V RMS voltage sensor input
  • 433/868MHz RFM12B / RFM69CW(HopeRF) wireless transceiver to transmit/receive data to other OpenEnergyMonitor and JeeNode modules
  • On-board DS18B20 digital temperature sensor (not included as standard)
  • Status LED
  • Compatible with Duemilanove, Uno and Leonardo
  • Compatible with OpenEnergyMonitor modules (emonGLCD, emonBase - NannodeRF etc.)

* with 9V AC adapter

Design Files & Part List

See OpenEnergyMonitor Shop for recommended CT and recommended plug-in AC-AC adapter

See building blocks for more information on CTs and AC-AC adapters.

The emonTx Shield schematic and board design, in Eagle CAD format, can be viewed and downloaded from the emonTx Shield GitHub page.

Build Guide

emonTx Shield SMT PCB & Thru-Hole Components

You will need to add the various connectors to the pre-assembled circuit board:

The RFM12B / RFM69CW radio module goes onto the pads marked with its outline, ensuring that it is the correct way round. If you are in any doubt about the orientation of the radio module, the antenna pin on the radio is at the top left in all the photos here [link: https://learn.openenergymonitor.org/electricity-monitoring/networking/which-radio-module], and it must line up with the antenna pad, which is next to the large hole by C2.

You must solder an antenna into that large hole. The RFM69CW can be damaged if it is operated at or near full power without the correct antenna.

Caution: The connectors for the Arduino headers, ISP, a.c adapter and c.t’s go on the opposite side to the radio module and the small components. The screw connector block, FTDI and links go on the same side as the radio module and the small components. Refer to the pictures below. If you cover over the label “CT1” etc, the socket is on the wrong side.

If you will be using a current transformer with an internal burden resistor (e.g. the YHDC SCT-013-030 or another “voltage output” type), you must remove the 33 Ω resistor for that input channel. If you are using a c.t. that requires a different value of burden, a wire-ended resistor can be soldered in the holes provided at each end of the fitted 33 Ω resistor. If the value of burden that you need is higher than 33 Ω, you will need to remove the fitted 33 Ω resistor. If lower, you can add a parallel resistor to bring the combined resistance down to the correct value.

emonTx Shield Top emonTx Shield Top

RFM69CW


Hardware Setup Instructions

On the top of the board, there are two solder jumpers (older boards only) which need to be connected before the emonTx Shield can operate. On later boards, these have been replaced by header pins and jumper links.


EmonTxShield solderJumper.jpg


RFM12B / RFM69CW Slave Select (SS) Solder Jumper Setting

The left hand solder jumper determines which Arduino digital I/O is used for the RFM SS pin. Digital 10 is the JeeLib library default. For standard operation, connect the solder jumper to 10 by connecting the middle pad to the left pad shown in this image.

However if Digital 10 is required by another shield (e.g Arduino Ethernet) another free digital pin can be used as the RFM SS pin. There are two options available. The first option requires hardware modification, the second requires software modification. We recommend the first option:


Option 1
  • Ensure the RFM12B SS pin solder jumper is not connected (middle pad not soldered to either left or right pads).
  • Solder a wire from the middle pad to either Digital 8 or 9. There is a hole available for this, see the image above.
  • Make sure you are using the latest JeeLib library
  • Add the line rf12_set_cs(8) or rf12_set_cs(9) depending on your chosen pin, before rf12 initialise in the void setup() section of your sketch.
  • The steps above work for both Arduino Uno (ATmega328) and Lenoardo (ATmega32u4)


Option 2
  • Digital 5 can be used as the RFM SS pin by connecting the solder jumper the other way.
  • Modifying the JeeLib library is required since Digital 5 is on a different port
  • For pin 5 to be used as the CS pin the line rf12_set_cs(5) must be added before rf12 initialise in void setup().
  • The following lines must be added to RF12.cpp in the JeeLib library in the void rf12_set_cs(uint8_t pin) function:


If you're using an Arduino Uno (ATmega328), in the file RF12.cpp, replace the entire function "void rf12_set_cs(uint8_t pin)" with this:

void rf12_set_cs(uint8_t pin)
{
#if defined(__AVR_ATmega32U4__)     //Arduino Leonardo
  if (pin==10) cs_pin=6;      // Dig10, PB6    
  if (pin==9)  cs_pin=5;      // Dig9,  PB5
  if (pin==8)  cs_pin=4;      // Dig8,  PB4           
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined (__AVR_ATmega328P__) // ATmega168, ATmega328
  if (pin==10) cs_pin = 2;      // Dig10, PB2
  if (pin==9) cs_pin = 1;       // Dig9,  PB1
  if (pin==8) cs_pin = 0;       // Dig8,  PB0
  if (pin==5)
  {
    cs_pin = 5;         //PD5
    #define SS_DDR      DDRD
    #define SS_PORT     PORTD
  }

#endif
}


If you're using an Arduino Leonardo (ATmega32u4), in the file RF12.cpp, replace the entire function "void rf12_set_cs(uint8_t pin)" with this:

void rf12_set_cs(uint8_t pin)
{
#if defined(__AVR_ATmega32U4__)     //Arduino Leonardo
  if (pin==10) cs_pin=6;      // Dig10, PB6    
  if (pin==9)  cs_pin=5;      // Dig9,  PB5
  if (pin==8)  cs_pin=4;      // Dig8,  PB4           
#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined (__AVR_ATmega328P__) // ATmega168, ATmega328
  if (pin==10) cs_pin = 2;      // Dig10, PB2
  if (pin==9) cs_pin = 1;       // Dig9,  PB1
  if (pin==8) cs_pin = 0;       // Dig8,  PB0
  if (pin==5)
  {
    cs_pin = 6;         //PD6
    #define SS_DDR      DDRC
    #define SS_PORT     PORTC
  }

#endif
}

RFM12B / RFM69CW Interrupt Solder Jumper Setting

The right hand solder jumper sets the RFM12B interrupt pin. The setting of this jumper depends on which Arduino board the shield is connected to. Connect the jumper to Digital 2 for Arduino Uno/Duemilanove or Digital 3 for Arduino Leonardo. These pins connect to the special hardware interrupt pin INT0.


For more information on RFM12B & RFM69CW connection to Arduino, see this this building block section


Arduino Compatibility

Arduino clones that have on-board Ethernet (e.g. at least one of the Australian-made Freetronics boards) and some Ethernet Shields appear to use Analog I/O for purposes connected with the Ethernet controller. This is not compatible with the use of the analogue input(s) for voltage or current measurements. On the Freetronics unit, it appears there are pull-up resistors for the MAC address chip attached to A4 and A5 that can be disconnected by cutting track jumpers to disable MAC addressing, but enable use of CT 4 input for current measurements. More details can be found here: freetronics forum and OpenEnergyMonitor forum

The EmonTx Arduino shield is not compatible with other Arduino shields that use I2C. see forum thread discussion

Pin use

Pin use.png

Example Arduino Sketches

See the emonTx Shield Folder in emonTx Firmware examples on the GitHub Repo

Follow the instructions in the GitHub readme for the required Arduino libraries