Hi
I wondering if it´s possible to covert the ac9v port on the emontx in to a "ct4" port so i can use one more current ct sensor.
I have looked at the schematic on the emontx and changed the r13 to a jumper and the r14 to a 18ohm resistor. And i have tried to change in the emonTx CT123 example (see below) but i am not very good at the program part.
Right now i don´t get any value in to the node10_4 port but on the other port works fine.
Any help is appreciated
Best regards
Gurre
*/
#define FILTERSETTLETIME 5000 // Time (ms) to allow the filters to settle before sending data
const int CT1 = 1;
const int CT2 = 1; // Set to 0 to disable CT channel 2
const int CT3 = 1; // Set to 0 to disable CT channel 3
const int CT4 = 1;
#define freq RF12_868MHZ // Frequency of RF12B module can be RF12_433MHZ, RF12_868MHZ or RF12_915MHZ. You should use the one matching the module you have.
const int nodeID = 10; // emonTx RFM12B node ID
const int networkGroup = 210; // emonTx RFM12B wireless network group - needs to be same as emonBase and emonGLCD
const int UNO = 1; // Set to 0 if your not using the UNO bootloader (i.e using Duemilanove) - All Atmega's shipped from OpenEnergyMonitor come with Arduino Uno bootloader
#include <avr/wdt.h>
#include <JeeLib.h> // Download JeeLib: http://github.com/jcw/jeelib
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Attached JeeLib sleep function to Atmega328 watchdog -enables MCU to be put into sleep mode inbetween readings to reduce power consumption
#include "EmonLib.h"
EnergyMonitor ct1,ct2,ct3,ct4; // Create instances for each CT channel
typedef struct { int power1, power2, power3, power4; } PayloadTX; // create structure - a neat way of packaging data for RF comms
PayloadTX emontx;
const int LEDpin = 9; // On-board emonTx LED
boolean settled = false;
void setup()
{
Serial.begin(9600);
Serial.println("emonTX CT123 example");
Serial.println("OpenEnergyMonitor.org");
Serial.print("Node: ");
Serial.print(nodeID);
Serial.print(" Freq: ");
if (freq == RF12_433MHZ) Serial.print("433Mhz");
if (freq == RF12_868MHZ) Serial.print("868Mhz");
if (freq == RF12_915MHZ) Serial.print("915Mhz");
Serial.print(" Network: ");
Serial.println(networkGroup);
if (CT1) ct1.currentTX(1, 111.1); // Setup emonTX CT channel (ADC input, calibration)
if (CT2) ct2.currentTX(2, 111.1); // Calibration factor = CT ratio / burden resistance
if (CT3) ct3.currentTX(3, 111.1);
if (CT4) ct4.currentTX(4, 111.1); // Calibration factor = (100A / 0.05A) / 33 Ohms
rf12_initialize(nodeID, freq, networkGroup); // initialize RFM12B
rf12_sleep(RF12_SLEEP);
pinMode(LEDpin, OUTPUT); // Setup indicator LED
digitalWrite(LEDpin, HIGH);
if (UNO) wdt_enable(WDTO_8S); // Enable anti crash (restart) watchdog if UNO bootloader is selected. Watchdog does not work with duemilanove bootloader // Restarts emonTx if sketch hangs for more than 8s
}
void loop()
{
if (CT1) {
emontx.power1 = ct1.calcIrms(1480) * 240.0; //ct.calcIrms(number of wavelengths sample)*AC RMS voltage
Serial.print(emontx.power1);
}
if (CT2) {
emontx.power2 = ct2.calcIrms(1480) * 240.0;
Serial.print(" "); Serial.print(emontx.power2);
}
if (CT3) {
emontx.power3 = ct3.calcIrms(1480) * 240.0;
Serial.print(" "); Serial.print(emontx.power3);
}
if (CT4) {
emontx.power4 = ct4.calcIrms(1480) * 240.0;
Serial.print(" "); Serial.print(emontx.power4);
}
// because millis() returns to zero after 50 days !
if (!settled && millis() > FILTERSETTLETIME) settled = true;
if (settled) // send data only after filters have settled
{
send_rf_data(); // *SEND RF DATA* - see emontx_lib
digitalWrite(LEDpin, HIGH); delay(2); digitalWrite(LEDpin, LOW); // flash LED
emontx_sleep(5); // sleep or delay in seconds - see emontx_lib
}
}
Re: convert 9vac port into a "ct4" port
I'm not a pro, regarding arduino programming but I think you're correct modifying the example file, but you need to modify Emonlib.cpp too.
See https://github.com/openenergymonitor/EmonLib/blob/master/EmonLib.cpp Lines 39 to 52 (sorry I'm on ipad now) and you see what I mean.
Regards
Re: convert 9vac port into a "ct4" port
Got it to work
Thank you very much for the help. It was the emonlib.cpp i needed to change.
Regards
Gurre