Difference between revisions of "EmonTx Arduino Shield"

From OpenEnergyMonitor Wiki
Jump to: navigation, search
(Design Files & Part List)
(emonTx Arduino Shield)
Line 10: Line 10:
 
|}
 
|}
  
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*  
Line 18: Line 18:
 
*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 29: Line 29:
 
See [http://openenergymonitor.org/emon/buildingblocks building blocks] for more information on CTs 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 CAD board design, in Eagle CAD format, can be viewed and downloaded from the emonTx Sheild Hardware [https://github.com/openenergymonitor/Hardware/tree/master/emontx-shield-smt emonTx Shield GitHub]'''
+
'''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==
Line 52: Line 52:
 
====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]. '''
+
 
+
 
+
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. The first option requires hardware modification, the second requires software modification. We recommend the first option:
+
  
 
# '''Option 1''':
 
# '''Option 1''':
#* Ensure the RFM12B CS pin solder jumper is not connected (middle pad not soldered to either left or right pads).
+
#* 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.
 
#* 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]
 
#* Make sure you are using the latest [http://github.com/jcw/jeelib JeeLib library]
#* 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.   
+
#* 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)
 
#* The steps above work for both Arduino Uno (ATmega328) and Lenoardo (ATmega32u4)
  
Line 69: Line 66:
 
#* Digital 5 can be used as the RFM CS pin by connecting the solder jumper the other way.  
 
#* Digital 5 can be used as the RFM CS pin by connecting the solder jumper the other way.  
 
#* Modifying the JeeLib library is required since Digital 5 is on a different port
 
#* 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 <code> rf12_set_cs(5) </code> must be added before rf12 initialise in void setup.  
+
#* 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>.  
 
#* 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 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 134: Line 131:
 
===Arduino Compatibility===
 
===Arduino Compatibility===
  
Some 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 that 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.
+
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]
  
'''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]'''
+
'''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'''
 
'''Pin use'''
Line 147: Line 144:
 
==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

Revision as of 18:09, 10 March 2017

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

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 correct component 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 Ω resistor for that input channel:


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:

  1. 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)
  1. Option 2
    • Digital 5 can be used as the RFM CS 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 connection to Arduino, see this this building block section For RFM69CW see [openenergymonitor.org/emon/buildingblocks/RFM69cw 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