Hi guys, I’m new here.
There is few years i bought an emontx V2 and a nanodeRF and they work well during few years.
Because i had changed my server ip i need upgrade the nanodeRF after few problems for finding ther good library, they work great.
But i want hadding a DHT22 on the emontx.
On the monitor when emontx is connected i can see the goods values temps1 and humidity1 between Power1 and Vrms
97O 4610 2220 3293
But when i receive on nanodeRF values are 0 for temps1 and 100 for humidity.
> [webClient]
DHCP status: 1 IP: 192.168.10.227 GW: 192.168.10.1 DNS: 8.8.8.8 Data sent: /api/post.json?apikey=YOURAPIKEY&node=1&json={rf_fail:1} Data sent: /api/post.json?apikey=YOURAPIKEY&node=10&csv=0,0,100,3293 Time request sent Data sent: /api/post.json?apikey=YOURAPIKEY&node=10&csv=4,0,100,3293 Data sent: /api/post.json?apikey=YOURAPIKEY&node=10&csv=3,0,100,3293
I don’t understand why Power and Vrms are well transmitted .
I think i need an outside view.
EmonTX V2 Sketch
#define FILTERSETTLETIME 5000 // Time (ms) to allow the filters to settle before sending data
const int CT1 = 1;
const int CT2 = 0; // Set to 0 to disable CT channel 2
const int CT3 = 0;
#define RF69_COMPAT 0 // SET TO 1 IF RFM69
#define RF_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>
#define RF69_COMPAT 0 // set to 1 to use RFM69CW
#include <JeeLib.h> // make sure V12 (latest) is used if using RFM69CW
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; // Create instances for each CT channel
typedef struct { int power1, temp1, humidity1, battery; } 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;
#include "DHT.h"
DHT dht;
void setup()
{
Serial.begin(9600);
Serial.println("emonTX CT123DHT22 example");
Serial.println("OpenEnergyMonitor.org");
Serial.print("Node: ");
Serial.print(nodeID);
Serial.print(" Freq: ");
if (RF_freq == RF12_433MHZ) Serial.print("433Mhz");
if (RF_freq == RF12_868MHZ) Serial.print("868Mhz");
if (RF_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)
rf12_initialize(nodeID, RF_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
dht.setup(4); // data pin 4 for DHT22
}
void loop()
{
if (CT1) {
emontx.power1 = ct1.calcIrms(1480) * 240.0; //ct.calcIrms(number of wavelengths sample)*AC RMS voltage
Serial.print(emontx.power1);
}
Serial.print(dht.getStatusString());
int humidity1 = dht.getHumidity()*100;
emontx.humidity1 = humidity1;
int temp1 = dht.getTemperature()*100;
emontx.temp1 = temp1;
Serial.print("\t");
Serial.print(emontx.humidity1);
Serial.print("\t");
Serial.print(emontx.temp1);
Serial.print("\t");
emontx.battery = ct1.readVcc(); //read emonTx battey (supply voltage)
Serial.print(" "); Serial.print(emontx.battery);
Serial.println(); delay(100);
// 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
}
}