diff --git a/PCB/gerber.zip b/PCB/gerber.zip new file mode 100644 index 0000000..c2208a4 Binary files /dev/null and b/PCB/gerber.zip differ diff --git a/PCB/schematic.pdf b/PCB/schematic.pdf new file mode 100644 index 0000000..3253c41 Binary files /dev/null and b/PCB/schematic.pdf differ diff --git a/README.md b/README.md index b272a19..fa34eff 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,15 @@ A ESP8266 based DSMR reader, posting onto MQTT, powered directly from the meter The code should work on DSRM v2.2 and higher, only tested on V4.2. -![esp8266-dsmr](https://github.com/bram2202/esp8266-dsmr/blob/master/docs/esp8266-dsmr.jpg "esp8266-dsmr") +![esp8266-dsmr](https://github.com/bram2202/esp8266-dsmr/blob/master/docs/PCB_IRL.png "esp8266-dsmr") ## Requirements * Arduino IDE / VS code * ESP8266 board (Wemos/LOLIN D1 mini/ESP01/NodeMCU) * Basic soldering and wiring skills * (For Wemos d1 mini) CH340G driver [[link]](https://wiki.wemos.cc/downloads) +* Prototype board / breadboard / PCB +* RJ11/12/25 cable ## Library dependencies - [PubSubClient](https://pubsubclient.knolleary.net) - MQTT client @@ -61,7 +63,6 @@ The code should work on DSRM v2.2 and higher, only tested on V4.2. | timestamp| - | 0-1:24.2.1| /gas/timestamp | | device id | - | 0-1:96.1.0 | /gas/device | - ## Settings Copy `Settings.example.h` to `Settings.h` and fill in the correct data. @@ -81,40 +82,44 @@ Copy `Settings.example.h` to `Settings.h` and fill in the correct data. ## Circuit -view [scheme.pdf](scheme.pdf). +View [scheme (pdf)](pcb/schematic.pdf). Using a level shifter inverter to get the serial output from the meter into the ESP.
-The board is powered directly from the meters power supply.
+The board can be powered directly from the meters power supply (this can vary between models). + + +## Custom PCB +Create your own with the [Gerber files (zip)](pcb/gerber.zip) -**Flash the firmware before attaching the circuit,** see "know issue"! -### Parts +## PCB case +- TODO + +## Parts | Type | Amount | |:---|:---| -| ESP8266 | 1 | -| Prototyping board | 1 | -| 2.2k resistor | 2 | -| 1k resistor | 1 | -| BC547 | 1 | -| 470uf cap. | 1 | - -### RJ11 connection +| ESP8266 board| 1 | +| Prototyping board or PCB | 1 | +| 2.2k resistor (0805) | 2 | +| 1k resistor (0805) | 1 | +| BC547 or BC817 (SOT-23) | 2 | +| 470uf cap. 8x12mm | 1 | -Connecting to the DSMR witn a RJ11 in Port 1 (P1), found on most smart meters. +## DSMR connection +Connecting to the DSMR with a RJ11/12/25 (6p6c or 6p4c) cable plugged into the Port 1 (P1), found on all supported smart meters. -| DSRM RJ11 | Description | J1 pin | +| DSRM P1 | Description | PCB Pin | |:---|:---|:---| -| 1 | +5v | 1 (5v) | -| 2 | Request | 2 (5v) | -| 3 | Data GND| 3 (GND) | +| 1* | +5v | 6 (5v) | +| 2 | Request | 5 (5v) | +| 3 | Data GND| 4 (GND) | | 4 | N.C. | N.C. | -| 5 | Data | 5 (Data)| -| 6 | Power GND | 6 (GND) | +| 5 | Data | 2 (Data)| +| 6* | Power GND | 1 (GND) | +`* 1 and 6 are not needed if powered by USB.` ## Known issues -- If the level shifter inverter is connected, it's impossible to flash the firmware.
-Pin RX is used, disconnect the pin to flash new firmware. - Some DSMR cannot deliver enough power to run the Wemos stably.
Connect a 5V usb supply to fix this. diff --git a/docs/DSMR_bottem.png b/docs/DSMR_bottem.png new file mode 100644 index 0000000..2a0c50a Binary files /dev/null and b/docs/DSMR_bottem.png differ diff --git a/docs/DSMR_top.png b/docs/DSMR_top.png new file mode 100644 index 0000000..61ae5c5 Binary files /dev/null and b/docs/DSMR_top.png differ diff --git a/docs/PCB_IRL.png b/docs/PCB_IRL.png new file mode 100644 index 0000000..5e6a370 Binary files /dev/null and b/docs/PCB_IRL.png differ diff --git a/esp8266-dsmr.ino b/esp8266-dsmr.ino index 78c4252..4eb273a 100644 --- a/esp8266-dsmr.ino +++ b/esp8266-dsmr.ino @@ -26,36 +26,36 @@ typedef struct } Measurement; const Measurement measurements[] = { - {"version", "1-3:0.2.8", 10, 12, Measurement::STRING}, - {"power/timestamp", "0-0:1.0.0", 10, 23, Measurement::STRING}, - {"power/device_id", "0-0:96.1.1", 11, 45, Measurement::STRING}, - {"power/consuption", "1-0:1.7.0", 10, 16, Measurement::FLOAT}, - {"power/production", "1-0:2.7.0", 10, 16, Measurement::FLOAT}, - {"power/total_consuption_low", "1-0:1.8.1", 10, 20, Measurement::FLOAT}, - {"power/total_consuption_high", "1-0:1.8.2", 10, 20, Measurement::FLOAT}, - {"power/total_production_low", "1-0:2.8.1", 10, 20, Measurement::FLOAT}, - {"power/total_production_high", "1-0:2.8.2", 10, 20, Measurement::FLOAT}, - {"power/power_tariff", "0-0:96.14.0", 12, 16, Measurement::INT}, - {"power/short_power_outages", "0-0:96.7.21", 12, 17, Measurement::INT}, - {"power/long_power_outages", "0-0:96.7.9", 11, 16, Measurement::INT}, - {"power/phase_1/short_power_drops", "1-0:32.32.0", 12, 17, Measurement::INT}, - {"power/phase_2/short_power_drops", "1-0:52.32.0", 12, 17, Measurement::INT}, - {"power/phase_3/short_power_drops", "1-0:72.32.0", 12, 17, Measurement::INT}, - {"power/phase_1/short_power_peaks", "1-0:32.36.0", 12, 17, Measurement::INT}, - {"power/phase_2/short_power_peaks", "1-0:52.36.0", 12, 17, Measurement::INT}, - {"power/phase_3/short_power_peaks", "1-0:72.36.0", 12, 17, Measurement::INT}, - {"power/phase_1/current", "1-0:31.7.0", 11, 14, Measurement::INT}, - {"power/phase_2/current", "1-0:51.7.0", 11, 14, Measurement::INT}, - {"power/phase_3/current", "1-0:71.7.0", 11, 14, Measurement::INT}, - {"power/phase_1/usage", "1-0:21.7.0", 11, 17, Measurement::FLOAT}, - {"power/phase_2/usage", "1-0:41.7.0", 11, 17, Measurement::FLOAT}, - {"power/phase_3/usage", "1-0:61.7.0", 11, 17, Measurement::FLOAT}, - {"power/phase_1/delivery", "1-0:22.7.0", 11, 17, Measurement::FLOAT}, - {"power/phase_2/delivery", "1-0:42.7.0", 11, 17, Measurement::FLOAT}, - {"power/phase_3/delivery", "1-0:62.7.0", 11, 17, Measurement::FLOAT}, - {"gas/total", "0-1:24.2.1", 26, 35, Measurement::FLOAT}, - {"gas/device_id", "0-1:96.1.0", 11, 45, Measurement::STRING}, - {"gas/timestamp", "0-1:24.2.1", 11, 24, Measurement::STRING}, + {"version", "1-3:0.2.8", 10, 12, Measurement::STRING}, + {"power/timestamp", "0-0:1.0.0", 10, 23, Measurement::STRING}, + {"power/device_id", "0-0:96.1.1", 11, 45, Measurement::STRING}, + {"power/consuption", "1-0:1.7.0", 10, 16, Measurement::FLOAT}, + {"power/production", "1-0:2.7.0", 10, 16, Measurement::FLOAT}, + {"power/total_consuption_low", "1-0:1.8.1", 10, 20, Measurement::FLOAT}, + {"power/total_consuption_high", "1-0:1.8.2", 10, 20, Measurement::FLOAT}, + {"power/total_production_low", "1-0:2.8.1", 10, 20, Measurement::FLOAT}, + {"power/total_production_high", "1-0:2.8.2", 10, 20, Measurement::FLOAT}, + {"power/power_tariff", "0-0:96.14.0", 12, 16, Measurement::INT}, + {"power/short_power_outages", "0-0:96.7.21", 12, 17, Measurement::INT}, + {"power/long_power_outages", "0-0:96.7.9", 11, 16, Measurement::INT}, + {"power/phase_1/short_power_drops", "1-0:32.32.0", 12, 17, Measurement::INT}, + {"power/phase_2/short_power_drops", "1-0:52.32.0", 12, 17, Measurement::INT}, + {"power/phase_3/short_power_drops", "1-0:72.32.0", 12, 17, Measurement::INT}, + {"power/phase_1/short_power_peaks", "1-0:32.36.0", 12, 17, Measurement::INT}, + {"power/phase_2/short_power_peaks", "1-0:52.36.0", 12, 17, Measurement::INT}, + {"power/phase_3/short_power_peaks", "1-0:72.36.0", 12, 17, Measurement::INT}, + {"power/phase_1/current", "1-0:31.7.0", 11, 14, Measurement::INT}, + {"power/phase_2/current", "1-0:51.7.0", 11, 14, Measurement::INT}, + {"power/phase_3/current", "1-0:71.7.0", 11, 14, Measurement::INT}, + {"power/phase_1/usage", "1-0:21.7.0", 11, 17, Measurement::FLOAT}, + {"power/phase_2/usage", "1-0:41.7.0", 11, 17, Measurement::FLOAT}, + {"power/phase_3/usage", "1-0:61.7.0", 11, 17, Measurement::FLOAT}, + {"power/phase_1/delivery", "1-0:22.7.0", 11, 17, Measurement::FLOAT}, + {"power/phase_2/delivery", "1-0:42.7.0", 11, 17, Measurement::FLOAT}, + {"power/phase_3/delivery", "1-0:62.7.0", 11, 17, Measurement::FLOAT}, + {"gas/total", "0-1:24.2.1", 26, 35, Measurement::FLOAT}, + {"gas/device_id", "0-1:96.1.0", 11, 45, Measurement::STRING}, + {"gas/timestamp", "0-1:24.2.1", 11, 24, Measurement::STRING}, }; MQTTPublisher mqttPublisher; @@ -66,15 +66,20 @@ bool hasMQTT = false; bool hasWIFI = false; Logger logger = Logger("App"); +int rxPin = 3; +int lvlPin = 5; + void setup() { - // Start serial ESP8266 RX port (pin 3) Serial.begin(115200); - pinMode(3, FUNCTION_0); + pinMode(rxPin, FUNCTION_0); // RX - logger.info("Booting"); + logger.info("Start setup"); + pinMode(lvlPin, OUTPUT); // D1 + digitalWrite(lvlPin, HIGH); // Turn on RX Trans + // Setup Wifi wifiConnector = WifiConnector(); wifiConnector.start(); @@ -86,6 +91,8 @@ void setup() // Setup OTA ArduinoOTA.setHostname(WIFI_HOSTNAME); ArduinoOTA.begin(); + + logger.info("Setup complte"); } void loop() @@ -126,14 +133,14 @@ void handleString(String incomingString) switch (measurement.valueType) { - case Measurement::FLOAT: - value = String(value.toFloat(), 3); - break; - case Measurement::INT: - value = String(value.toInt()); - break; - default: - break; + case Measurement::FLOAT: + value = String(value.toFloat(), 3); + break; + case Measurement::INT: + value = String(value.toInt()); + break; + default: + break; } mqttPublisher.publishOnMQTT(measurement.name, value); diff --git a/scheme.pdf b/scheme.pdf deleted file mode 100644 index e2a4739..0000000 Binary files a/scheme.pdf and /dev/null differ