Difference between revisions of "EmonTx Arduino Shield"
Glyn.hudson (talk | contribs) |
Robert Wall (talk | contribs) |
||
Line 156: | Line 156: | ||
If you're using an Arduino Leonardo (ATmega32u4) | 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: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
if (pin==5) | 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 | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
====RFM12B Interrupt Solder Jumper Setting==== | ====RFM12B Interrupt Solder Jumper Setting==== |
Revision as of 22:49, 18 September 2013
emonTx Arduino Shield
An open-hardware wireless energy monitoring Arduino compatible (Duemilanove,Uno and Leonardo) shield.


See non-invasive section of building blocks for theory behind CT energy monitoring.
Overview
- Apparent Power, Real Power*, Power Factor* and AC RMS voltage readings*
- 4 x CT Current Sensor input
- AC 9V RMS voltage sensor input
- 433/868Mhz RFM12B (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
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 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* |
* or 1 x 28 pin header
See OpenEnergyMonitor Shop for recommended CT and recommended plug-in AC-AC adapter
See building blocks for more information on CT's and AC-AC adapters.
The emonTx Shield schematic and board design in Eagle CAD format can be viewed and downloaded from the emonTx Shield SolderPad Git Repo
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:
Hardware Setup Instructions
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.
RFM12B Slave Select (SS) Solder Jumper Setting
The left hand solder jumper determines which Arduino digital I/O is used for the RFM12B SS pin. Digital 10 is the default for the JeeLib library. For standard operation Connect the solder jumper to 10 by connecting the middle pad to the left pad shown in the this image.
However if Digital 10 is required by another shield (e.g Arduino Ethernet) another free digital pin can be used for the RFM12B 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:
- Ensure the RFM12B CS pin solder jumper is not connected (middle pad not soldered to either left of right hand pads).
- Solder a wire from the middle pad (there is a hold available for this, see image above) to either Digital 8 or 9.
- Make sure you are using the latest JeeLib library
- In your sketch add the line
rf12_set_cs(8)
orrf12_set_cs(9)
depending on your chosen pin before rf12 initialise in void setup. - The steps above work for both Arduino Uno (ATmega328) and Lenoardo (ATmega32u4)
- Option 2
- Digital 5 can be used as the RFM12B 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
rf12_set_cs(5)
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
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:
<syntaxhighlight lang="cpp"> 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
} </syntaxhighlight>
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:
<syntaxhighlight lang="cpp"> 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
} </syntaxhighlight>
RFM12B 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. 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
Example Arduino Sketches
See emonTx Shield Folder in emonTx Firmware examples GitHub Repo
Follow instructions on the GitHub readme for required Arduino libraries