Dear markf,
thank you for your reply , i've tryed the code you past here but with
this one it really don't work in any way, i've tryed different corrections but
no workout....... and i dont know why
(the first one work in part like i want)
other thing, i am using an arduino nano maybe is this?
the pin setup is invertd, because if i have pin low no power from pin,
and if set to high i have around 5 volts, but no problems
because if i invert all the instruction work correctly.
the only problem is that if i connect this relays board, i get a wrong readings from the
ammeter (high then without ) and read some power that is not real also when charge is swithced off .

maybe the board is not good for this project? , i need to say that the project is not yet ended so the
nano is powered by the pc only no power supply can this create problems?
now i past the code corrected tested if see any error
and the schematic of relays board
you sincerelly sergioT .
#define R1pin 13 // Relay #1 pin number
#define R2pin 12 // Relay #2 pin number
#include "EmonLib.h"
#include <Wire.h> // Libreria wire già presente in Arduino ide
EnergyMonitor emon1;
//Inserire la tensione della vostra rete elettrica
int rede = 230.0; // Italia 230V in alcuni paesi 110V
//Pin del sensore SCT su A1
int pin_sct = 1;
//============================================================
void setup()
{
Serial.begin(9600);
emon1.current(pin_sct, 29);
pinMode(R1pin, OUTPUT); // Relay #1
digitalWrite(R1pin, LOW); // Relay OFF (a LOW energizes the relay)
pinMode(R2pin, OUTPUT); // Relay #2
digitalWrite(R2pin, LOW); // Relay OFF (a LOW energizes the relay)
}
//============================================================
void loop()
{
bool allarmeSuoneria = false;
bool allarmeLampada = false;
//Calcolo della corrente
double Irms = emon1.calcIrms(1480);
//Mostra il valore della Corrente
Serial.print("Corrente : ");
Serial.println(Irms); // Irms
if (Irms >= 1.4) { // *** if (Amp > 1.5A) ***
if ( !allarmeSuoneria ) {
Serial.println("Attenzione!: Superamento Soglia");
allarmeLampada = true;
allarmeSuoneria = true;
digitalWrite(R1pin, HIGH); // Lampada accesa
digitalWrite(R2pin, HIGH); // Suoneria accesa
}
else if (Irms >= 0.3) { // *** if (0.5A < Amp <= 1.5A) ***
if ( !allarmeLampada || allarmeSuoneria )
Serial.println("Inizio : Tensione al minimo");
allarmeLampada = true;
allarmeSuoneria = false;
digitalWrite(R1pin, HIGH); // Lampada accesa
digitalWrite(R2pin, LOW); // Suoneria Spenta
}
else { // *** else (Amp <= 0.5A) ***
if ( allarmeLampada )
Serial.println("In attesa,No Tensione ");
allarmeLampada = false;
allarmeSuoneria = false;
digitalWrite(R1pin, LOW); // LAMPADA OFF
digitalWrite(R2pin, LOW); // Suoneria OFF
}
// Ritardo
delay(1000);
}
}