Liste de matériel à acheter
- 1 PZEM 004T lien
- 1 Arduino 328p lien
- 1 puce radio NRF24L01 lien
- 10 Câble pour breadboard femelle/femelle lien
Liste de matériel à récupérer
- Rallonge électrique (avec terre (conseillé))
- domino
Caractéristique technique du wattmètre PZEM004
Paramètre électrique mesure :
• Voltage
• Intensité
• Puissance Instantané
• Energie
Communications en TTL avec l’arduino
Dans domoticz
Rien à faire c’est ça qui est bien avec MYS
Dans Arduino IDE
Télécharger la librairie du PZEM 004T pour arduino :
http://vinz973.free.fr/img/PZEM004T-master.zip
et installer là.
Televersé le sketch dans votre Arduino
Code : Tout sélectionner
/**
*/
// Active le mode debug / Enable debug prints to serial monitor
#define MY_DEBUG
//#define MY_DEBUG_VERBOSE_RF24
// Mode Radio / Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Noeud de l'objet / Object Node
#define MY_NODE_ID 3
#include <SPI.h>
#include <MySensors.h>
#include <SoftwareSerial.h>
#include <PZEM004T.h>
// initialisation du PZEM004T
PZEM004T pzem(4,5); // RX,TX
IPAddress ip(192,168,1,1);
//V_VOLTAGE S_MULTIMETER
//V_CURRENT S_MULTIMETER
//V_WATT S_POWER
//V_KWH S_POWER
#define CHILD_ID_VOLTAGE 1
#define CHILD_ID_CURRENT 2
#define CHILD_ID_WATT 3
#define CHILD_ID_KWH 4
#define SLEEP_NODE true // Mettre à True pour activer la mise en sommeil (Sleep Mode) / True to activate Sleep Mode
unsigned long SLEEP_TIME = 30 * 1000; // Temps de mise en sommeil (en ms) / Sleep time between reads (in milliseconds)
MyMessage msgVolt(CHILD_ID_VOLTAGE, V_VOLTAGE);
MyMessage msgIntensite(CHILD_ID_CURRENT, V_CURRENT);
MyMessage msgWatt(CHILD_ID_WATT, V_WATT);
MyMessage msgKwh(CHILD_ID_KWH, V_KWH);
void setup() {
pzem.setAddress(ip);
}
void presentation() {
// Présenttion du sketch / Send the sketch version information to the gateway and Controller
sendSketchInfo("PZEM 004T ", "1.0");
// Déclaration des capteurs attachés au noeud
present(CHILD_ID_VOLTAGE, S_MULTIMETER);
present(CHILD_ID_CURRENT, S_MULTIMETER);
present(CHILD_ID_WATT, S_POWER);
present(CHILD_ID_KWH, S_POWER);
}
void loop()
{
float v = pzem.voltage(ip);
if (v < 0.0) v = 0.0;
Serial.print(v);Serial.print("V; ");
delay(10);
float i = pzem.current(ip);
if(i >= 0.0){ Serial.print(i);Serial.print("A; "); }
delay(10);
float p = pzem.power(ip);
if(p >= 0.0){ Serial.print(p);Serial.print("W; "); }
delay(10);
float e = pzem.energy(ip);
if(e >= 0.0){ Serial.print(e);Serial.print("Wh; "); }
Serial.println();
send(msgVolt.set(v, 1));
send(msgIntensite.set(i, 1));
send(msgWatt.set(p, 1));
send(msgKwh.set(e/1000, 1));
if (SLEEP_NODE) {
Serial.println("Sleep");
sleep(SLEEP_TIME);
} else {
delay (SLEEP_TIME);
}
}
Et voilà Apres le branchement vous devriez obtenir de belle courbe comme celle la





