P1 Wifi Gateway doesn't send data

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

P1 Wifi Gateway doesn't send data

#1 Post by Bluesky » 02 Dec 2019, 17:13

I use a Wemos D1 R1 with Espeasy mega 20191123 installed to read the smart meter (ISKRA ME382) I've tried a lot of things but the wemos isnt sending data to domoticz or Putty. Wifi is up and running and I can login on the wemos. I checked the data cable from the meter with a scope and it is sending data (non inverted) every 10 seconds to GPIO 14 (D5). Domoticz connects with the wemos but resets the connection every minute because there's no data.
Then I've tried a usb connection to my pc with putty set to serial reading and then config readings from the wemos are shown, however, when I disconnect GPIO 14 the data flow stops. I use a direct cable without the transistor and a 10K pullup R connected to the data pin of P1 and D5 from the wemos. The blue SCK led blinks every 10 seconds. Any ideas what's going wrong?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#2 Post by TD-er » 02 Dec 2019, 17:31

I think you're using "Communication - P1 Wifi Gateway" right?

That plugin uses the Serial0 port, which is the same port as you use to program the ESP.
This also means you must disable the log on the serial port, but keep the serial enabled checkbox checked.

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#3 Post by Bluesky » 03 Dec 2019, 16:58

Thanks for your reply. I checked the settings but still no cigar, Domoticz and Putty doesn't recieve data. It looks like there is no communication at all although wifi works flawlessly.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#4 Post by TD-er » 03 Dec 2019, 17:31

So you changed the P1 port to the RX/TX pins of the Wemos? (Gpio 3/1)

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#5 Post by Bluesky » 03 Dec 2019, 20:11

The data pin of the P1 port is connected via a 10K pullup resistor to GPIO14 (D5).

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#6 Post by TD-er » 03 Dec 2019, 23:34

Bluesky wrote: 03 Dec 2019, 20:11 The data pin of the P1 port is connected via a 10K pullup resistor to GPIO14 (D5).
And why is that?
I did look into the code of that plugin and it seems like it is using Serial0 to read the data.
Serial0 is connected to RX/TX (Gpio 1/3) and not on GPIO14.
It is possible to swap Serial0 to other pins, but those are 15 and 13 (and 15 needs some special treatment to make the unit boot properly)
So either way, it seems a bit odd to me to use GPIO14.
Do you use some guide which uses these pins?

Or are you using a different plugin?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#7 Post by ThomasB » 04 Dec 2019, 04:22

I agree with @TD-er that you seem to be using the wrong pin on the ESP8266.

I don't have experience with the ME382 so I downloaded its manual and reviewed the P1 serial interface. See pages 84-86 in this doc:
https://www.telematicasistemi.it/it/doc ... _V1.02.pdf

It is a 3-wire interface that requires connections to +5VDC for the Request signal (optocoupler power), Ground, and Data. The Data signal is open collector TTL, so a 3.3V pull-up resistor (1K ohm) is required on the Wemos board. There is a chance the Request signal will work with 3.3V, but be prepared to use 5V if you run into trouble.

The ME382 manual also mentions that baud rate is fixed at 9600. But check it with your o-scope and confirm the correct baud rate for the Gateway plugin.

Further research indicates that the meter's Data signal needs to be inverted. A transistor can be used for this. I found a schematic that was posted by @Domosapiens for a similar E-meter, see below:
download/file.php?id=3427

Also, some Wemos D1 clone boards are missing the serial protection resistors that provide basic isolation from the onboard USB chip. So after wiring the P1 interface, confirm the E-meter's Data signal levels are valid by using your o-scope; Data should swing from 0 to 3.3V when the meter communicates.

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#8 Post by TD-er » 04 Dec 2019, 08:42

For the serial pins it may help sometimes to put a 500 Ohm resistor in series with the signal to compensate for impedance mismatch and some simple protection of the pins (not sure if any connected USB to serial chip is 5V tolerant).
For 9600 baud frequencies you don't really need impedance matching, because "ringing" will not really be an issue on these frequencies.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#9 Post by ThomasB » 04 Dec 2019, 17:32

For the serial pins it may help sometimes to put a 500 Ohm resistor in series with the signal to compensate for impedance mismatch and some simple protection of the pins ...
I don't recommend doing that on the Wemos D1 R1. That's because there are series protection resistors on the RX / TX inputs of the board's USB chip. Adding the external resistor on the RX pad will create a voltage divider and attenuate the signal level.

See R3 on the schematic:

WemosD1R1.jpg
WemosD1R1.jpg (88.48 KiB) Viewed 21116 times

Long story short, directly connecting external serial to the RX pad is the recommended way to go. But as mentioned before, some Wemos D1 clone boards have omitted the serial protection resistors on the USB chip. That cost cutting mistake causes signal bus contention problems when using external serial. O-Scope measurements will find such surprises.

- Thomas

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#10 Post by Bluesky » 04 Dec 2019, 19:07

Thanks for your replies, I appreciate it. I think my Wemos is a clone so this could make sense. I ordered a Wemos d1 Mini, it should come within a couple of days.

Here is where I started (in dutch): http://www.esp8266thingies.nl/wp/wp-con ... eiding.pdf I used the latest espeasy mega which comes with the 044 P1 wifi gateway plugin. That plugin must be connected to GPIO 14 (that is what the author says) so that is what I did. I also used serial server and in that case it has to be connected to the RX pin but that was doing nothing either. So there might be a big chance that my Wemos is a clone and therefore not working.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#11 Post by ThomasB » 04 Dec 2019, 19:42

So there might be a big chance that my Wemos is a clone and therefore not working.
It's much too early to draw that conclusion. I see other things that need to be investigated first.
1. Missing RX data inverter.
2. Wrong pin used for RXD.
3. Confirm Request signal voltage.
Here is where I started (in dutch): http://www.esp8266thingies.nl/wp/wp-con ... eiding.pdf
I read a translated version of the document. I could not find any mention of using GPIO14. But I did see that the ESPEasy version was R104 released in 2016. That is a very old version and much has changed. So don't trust anything in the doc without further investigation & confirmation.

But more importantly, this published project appears to be discussing a complete kit that includes a "P1 Port" shield for connecting the E-Meter. The shield includes the transistor inverter that was mentioned earlier. Here is the text:
The Wemos D1 mini module with P1 port shield makes it possible to read the meter readings of a smart meter with P1 port wirelessly. When the kit is used in a Domoticz system, the meter readings will be continuously transferred to the Domoticz system. The Wemos module runs on ESPeasy (http://www.esp8266.nu), which means that the module can be configured and controlled entirely via a web interface.

The P1 port is connected to the actual smart meter via an optocoupler. This ensures that the smart meter cannot be damaged via the P1 port. The disadvantage is that the optocoupler inverts the signals. The P1 shield in this kit inverts the signals back to standard TTL level (via a simple transistor) and offers them to the serial in port on the ESP8266 which can then offer the data via WiFi.

The kit consists of a Wemos D1 mini, a P1 port shield, an RJ-11 cable (approx. 60 cm) and a USB power adapter. This is all you need to read a smart meter via WiFi.
So you will need to replicate the P1 Port shield. The schematic posted earlier is a good reference for building the required serial interface.

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#12 Post by TD-er » 04 Dec 2019, 19:51

I've also read the Dutch link you gave and I don't need Google translate for it :)

CTRL-F in the document for 14 does only give 2 occurrences in the P1 raw example data shown.

Can you connect the P1 to the RX of the ESP?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#13 Post by ThomasB » 04 Dec 2019, 20:46

I've also read the Dutch link you gave and I don't need Google translate for it
Opschepper! ;)
Can you connect the P1 to the RX of the ESP?
That is a good start. But RX Data needs the inverter circuit. Plus the Request signal needs 5V power (but maybe 3.3V is possible).

If building the P1 shield is a hardship then the site that sells it is http://www.esp8266thingies.nl/wp/about/
The full kit (Wemos board, P1 shield, RJ11 cable) is 22 EUR. Keep in mind that I have no experience with the seller or his project.

- Thomas

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#14 Post by Bluesky » 05 Dec 2019, 20:16

I've received the wemos mini and I think this is a clone board also because the Wemos name is'nt printed on it. But anyway, I made a new inverter circuit and connected it to the RX pin but no result. It looks like there's no data traffic on the local network. I can connect directly tot the wemos (espeasy) but when I want to login to the plugin (ip with port, 192.168.2.12:8088) there's no page to be found so maybe there isn't a server active. Tomorrow I'm gonna hook up the scoop and see what the inverter circuit is doing. I'll keep you posted !

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#15 Post by ThomasB » 05 Dec 2019, 20:56

I made a new inverter circuit and connected it to the RX pin but no result.
Also confirm that 5VDC power is correctly wired to the E-Meter's Request input.
I can connect directly tot the wemos (espeasy) but when I want to login to the plugin (ip with port, 192.168.2.12:8088) there's no page to be found so maybe there isn't a server active.
If P1 web access is not working then enable the weblog (set to debug). Watch the running log from your browser. This should show all the activity during P1 communication. Don't enable serial log because the serial port is needed by the E-meter.
Tomorrow I'm gonna hook up the scoop and see what the inverter circuit is doing.
Great. The o-scope is ideal for debugging this.

- Thomas

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#16 Post by Bluesky » 08 Dec 2019, 12:46

I hooked up a scope and the meter is sending signals to the RX wire, however, there is no communication between the wemos and domoticz or putty.
ThomasB wrote: 05 Dec 2019, 20:56 If P1 web access is not working then enable the weblog (set to debug). Watch the running log from your browser. This should show all the activity during P1 communication. Don't enable serial log because the serial port is needed by the E-meter.
- Thomas
I watch the log in espeasy and this is what it says:
62577: WD : Uptime 1 ConnectFailures 0 FreeMem 20800 WiFiStatus 3
92577: WD : Uptime 2 ConnectFailures 0 FreeMem 20800 WiFiStatus 3
122577: WD : Uptime 2 ConnectFailures 0 FreeMem 20768 WiFiStatus 3

You said "watch the running log from your browser" could you be more specific?

Thanks in advance !

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#17 Post by TD-er » 08 Dec 2019, 13:44

There are several ways to access the logs.
- Serial
- Syslog service running on some (Linux) host in your network
- Web page (Tools => log)

If you have things connected to the serial port, like the P1 adapter you have, then you cannot use the serial port for monitoring.
So then it makes sense to look at the logs via the web page.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#18 Post by ThomasB » 08 Dec 2019, 18:51

I hooked up a scope and the meter is sending signals to the RX wire,...
Signal activity is a good sign. But are the RxD voltage levels correct? That is to say, with everything connected, do the serial data bits on the ESP82ss's RX pin swing from 0.0V to 3.3V? Are the edges square (not severely rounded)?

The scope will allow you to confirm the baud rate that must be used in the plug-in. The E-Meter is suppose to be 9600 baud, but confirming it with the scope is a wise move.
You said "watch the running log from your browser" could you be more specific?
TD-er did a nice job of explaining system log access. But if you need specific steps, then follow this:
Step 1. Visit Tools->Advanced.
* Set Web Log Level to Debug.
* Set Serial Log Level to None.
* Uncheck Enable Serial Port (it will be enabled by the P1 plugin).
* Save page.
Step 2. Now go to Tools->Log. This is Web page log viewer.
Step 3. Watch the log for several minutes. If the E-Meter is communicating you will eventually see its details buried in the log messages from everything else.

Keep in mind that incorrect settings in the P1WifiGateway plug-in will cause communication failure and log messages will probably be missing.

- Thomas

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#19 Post by Bluesky » 09 Dec 2019, 18:25

Thank you for your detailed answer ! The log shows no connection, however, when domoticz is running I get a log saying P1 smart meter is connected. That means the log is working. But after 1 minute the connection resets because domoticz isn't receiving data. So all in all I'm getting no messages, only the status of espeasy itself:

62577: WD : Uptime 1 ConnectFailures 0 FreeMem 20800 WiFiStatus 3
92577: WD : Uptime 2 ConnectFailures 0 FreeMem 20800 WiFiStatus 3
122577: WD : Uptime 2 ConnectFailures 0 FreeMem 20768 WiFiStatus 3

This said I think the Wemos mini isn't sending data at all but the scope readings from the meter are ok.

Is there a way to connect a data source to the rx pin? So I can see the Wemos does sends data over the network.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P1 Wifi Gateway doesn't send data

#20 Post by TD-er » 09 Dec 2019, 20:16

To what pin is the P1 now connected on the Wemos?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: P1 Wifi Gateway doesn't send data

#21 Post by ThomasB » 09 Dec 2019, 21:25

This said I think the Wemos mini isn't sending data at all but the scope readings from the meter are ok.
The P1 Wifi Gateway expects specially formatted E-Meter data. Log / Gateway messages aren't sent if there is anything wrong with the data signal, or if the data format is incompatible, or if the plug-in's serial settings are incorrect. Plus the Gateway must have an active connection to your domoticz server too. It appears there is a problem with at least one of these things.
Is there a way to connect a data source to the rx pin? So I can see the Wemos does sends data over the network.
You could use an external USB serial dongle to confirm the RX pin is working. Your simulated serial messages would need to be a replica of the raw telegram data sent by a Iskra ME382 e-meter. If the format is wrong the entire data packet will be ignored. So using your own data source is not an ideal way to troubleshoot.

I have a different idea for useful troubleshooting. GPIO12 (D6) will briefly go logic high whenever an RX data byte is received from the E-Meter. Use your o-scope and confirm that there is activity (logic low-high-low pulse) on GPIO12 whenever there is a data byte sent to the RX pin. This won't prove that the data is valid, but it will confirm that something was received. Please report back on what you find.
To what pin is the P1 now connected on the Wemos?
Besides sharing that info, please post a screen shot of the P1 Wifi Gateway device page so that we can see the settings that have been entered there.

12-10-2019 EDIT:
Step 1. Visit Tools->Advanced.
* Set Web Log Level to Debug.
* Set Serial Log Level to None.
* Check Enable Serial Port (SEE NOTE BELOW).
* Save page.
* Reboot.
Also, repeat your tests with the Enable Serial Port enabled (box checked). So enable it, save the page, then reboot. Do you now see anything new in the logs and/or does GPIO12 show activity?

- Thomas

Bluesky
New user
Posts: 8
Joined: 02 Dec 2019, 16:48

Re: P1 Wifi Gateway doesn't send data

#22 Post by Bluesky » 11 Dec 2019, 16:52

Thomas, thank you for your reply. I'm a little bit short of time now but I will provide you the info and i'll test GPIO 12. I reply within a couple of days. Again, thank you, much appreciated !

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests