diff --git a/code/espurna/sensor.ino b/code/espurna/sensor.ino index f2983eda..b3b0dcff 100644 --- a/code/espurna/sensor.ino +++ b/code/espurna/sensor.ino @@ -282,7 +282,7 @@ void _sensorInitCommands() { DEBUG_MSG_P(PSTR("[SENSOR] PZEM004T\n")); unsigned char dev_count = pzem004t_sensor->getAddressesCount(); for(unsigned char dev = 0; dev < dev_count; dev++) { - DEBUG_MSG_P(PSTR("Device %d Address %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str()); + DEBUG_MSG_P(PSTR("Device %d/%s\n"), dev, pzem004t_sensor->getAddress(dev).c_str()); } DEBUG_MSG_P(PSTR("+OK\n")); } else if(e->argc == 2) { @@ -299,7 +299,7 @@ void _sensorInitCommands() { } }); settingsRegisterCommand(F("PZ.RESET"), [](Embedis* e) { - if(e->argc > 2) { + if(e->argc > 2) { DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); } else { unsigned char init = e->argc == 2 ? String(e->argv[1]).toInt() : 0; @@ -308,7 +308,7 @@ void _sensorInitCommands() { for(unsigned char dev = init; dev < limit; dev++) { float offset = pzem004t_sensor->resetEnergy(dev); setSetting("pzEneTotal", dev, offset); - DEBUG_MSG_P(PSTR("Device %d Address %s - Offset: %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str(), String(offset).c_str()); + DEBUG_MSG_P(PSTR("Device %d/%s - Offset: %s\n"), dev, pzem004t_sensor->getAddress(dev).c_str(), String(offset).c_str()); } DEBUG_MSG_P(PSTR("+OK\n")); } diff --git a/code/espurna/sensors/PZEM004TSensor.h b/code/espurna/sensors/PZEM004TSensor.h index 5f643ae9..8f5fda3f 100644 --- a/code/espurna/sensors/PZEM004TSensor.h +++ b/code/espurna/sensors/PZEM004TSensor.h @@ -3,6 +3,48 @@ // Copyright (C) 2018 by Xose PĂ©rez // ----------------------------------------------------------------------------- +// Connection Diagram: +// ------------------- +// +// Needed when connecting multiple PZEM004T devices on the same UART +// *You must set the PZEM004T device address prior using this configuration* +// +// +---------+ +// | ESPurna | +VCC +// | Node | ^ +// | G T R | | +// +-+--+--+-+ R (10K) +// | | | | +// | | +-----------------+---------------+---------------+ +// | +-----------------+--|------------+--|------------+ | +// +-----------------+--|--|---------+--|--|---------+ | | +// | | | | | | | | | +// | | V | | V | | V +// | | - | | - | | - +// +-+--+--+-+ +-+--+--+-+ +-+--+--+-+ +// | G R T | | G R T | | G R T | +// |PZEM-004T| |PZEM-004T| |PZEM-004T| +// | Module | | Module | | Module | +// +---------+ +---------+ +---------+ +// +// Where: +// ------ +// G = GND +// R = ESPurna UART RX +// T = ESPurna UART TX +// V = Small Signal Schottky Diode, like BAT43, +// Cathode to PZEM TX, Anode to Espurna RX +// R = Resistor to VCC, 10K +// +// More Info: +// ---------- +// See ESPurna Wiki - https://github.com/xoseperez/espurna/wiki/Sensor-PZEM004T +// +// Reference: +// ---------- +// UART/TTL-Serial network with single master and multiple slaves: +// http://cool-emerald.blogspot.com/2009/10/multidrop-network-for-rs232.html + #if SENSOR_SUPPORT && PZEM004T_SUPPORT #pragma once