Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V9261F not showing power values in 1.15.0 #2546

Closed
Kaan88 opened this issue Oct 26, 2022 · 12 comments
Closed

V9261F not showing power values in 1.15.0 #2546

Kaan88 opened this issue Oct 26, 2022 · 12 comments
Labels

Comments

@Kaan88
Copy link

Kaan88 commented Oct 26, 2022

Device

V9261F

Version

espurna-1.15.0-dev.git7095cfff+github20220816-wemos-v9261f

Bug description

I wanted to use pre-release builds as there is no calibration page like in 1.9.4 from http://tinkerman.cat/connected-power-meter/

But for some reason I get 0 values on all the statistics in pre-release builds.

Also builds after August 16 has no web server running for wemos-v9261f build. Couldn't find out why through the commits so I couldn't test the latest version. (esp01-v9261f build does have accessible web-ui though)

Steps to reproduce

Upgrade or directly use pre-release builds. Statistics like Power, Voltage or Current stays at zero, unlike in 1.14.1

Build tools used

Custom build with only added one relay to the code. But I only added the relay recently, issue was the same.

Any relevant log output (when available)

[010137] [MQTT] Sending ESPURNA-V9261F/current => 0.000 (PID 1)
[010139] [MQTT] Sending ESPURNA-V9261F/voltage => 0 (PID 1)
[010140] [MQTT] Sending ESPURNA-V9261F/power => 0 (PID 1)
[010143] [MQTT] Sending ESPURNA-V9261F/reactive => 0 (PID 1)
[010148] [MQTT] Sending ESPURNA-V9261F/apparent => 0 (PID 1)

Decoded stack trace (when available)

No response

@Kaan88 Kaan88 added the bug label Oct 26, 2022
@mcspr
Copy link
Collaborator

mcspr commented Oct 26, 2022

Regarding different naming, I see 1ac4a61 renaming 'AC RMS' to 'Expected current', 'Expected voltage' and etc. in the code and further updates should have retained it (unless it somehow got hidden in the UI or V9261F support is differently advertised)

Behaviour with relay also seems consistent with the previous version? If there is a relay, power meter readings only go into the system when relay is ON

#define SENSOR_POWER_CHECK_STATUS 1 // If set to 1 the reported power/current/energy will be 0 if the relay[0] is OFF

(and see sensor.cpp code between #if SENSOR_POWER_CHECK_STATUS ... #endif)

@Kaan88
Copy link
Author

Kaan88 commented Oct 26, 2022

Sorry for the confusion, I get no readings even if the relay is on. I meant that I added the relay later, but did try official 1.15.0 builds with no relay and the behaviour was the same.

Probably due to this change 1ac4a61 I can only calibrate the device by editing the sensor file manually and recompiling it on 1.14.1.

Any idea why builds after August 16 would have no accessible web ui? I couldn't find a way to enable it via Telnet. (which is on by default on these builds.)

To summarize, with V9261F:

1.14.1: Sensor readings work, no calibration ui is available.
1.15.0: Sensor readings don't work, all show 0. Calibration UI is available but this makes no difference for readings.
Also, builds after August 16 have no webui for wemos-v9261f.

@mcspr
Copy link
Collaborator

mcspr commented Oct 26, 2022

Reminds me of #2483; at least one possible fix is described in the comment - change serial mode.

Xose used SoftwareSerial originally, and august builds still do. In recent builds softwareserial is optional (see UART_... flags), but parity and the rest of the options are also configurable at runtime

No idea about the web, this might've been fixed since then.

@mcspr
Copy link
Collaborator

mcspr commented Oct 26, 2022

In most recent code - also note the change in default pins
(and if parity fix is correct, it needs to be added in this section)

#elif defined(GENERIC_V9261F)
// Info
#define MANUFACTURER "GENERIC"
#define DEVICE "V9261F"
#define ALEXA_SUPPORT 0
// V9261F
#define V9261F_SUPPORT 1
// UART only reads data
#define UART_SUPPORT 1
#define UART1_BAUDRATE 4800
#define UART1_TX_PIN GPIO_NONE
#define UART1_RX_PIN 3
#define UART1_INVERT 1
#define V9261F_PORT 1

@Kaan88
Copy link
Author

Kaan88 commented Oct 26, 2022

Thanks a lot for your help so far, I'm way over my head but I managed to get readings on August 19 source.

I only added "SWSERIAL_8O1" from the snippet here: #2483
Rest of it seems to already be in the file already, except "SWSERIAL_8O1". Any downsides to this? Why was this omitted?

I still can't figure why "wemos-v9261f" builds don't have webui on newer commits, couldn't find the culprit. (so I can't check the newest stuff about changed pins and UART) "Wemos-d1mini" builds are fine.

@mcspr
Copy link
Collaborator

mcspr commented Oct 26, 2022

No downside, we just properly configure serial IO. New software based serial code is just way more strict than the old one.

August builds also had an issue in sensors continiously crashing, so that is my best guess since Web Server does not start when device goes into safe mode.
Will need to check what causes the yet another crash in current version, on pre-built and direct environments, since I have not seen any issues running -git builds it is probably something with the Core version....

@Kaan88
Copy link
Author

Kaan88 commented Oct 28, 2022

Would this crash log be of any help? I just tried the latest dev, and I also changed my connection go gpio3, instead of 2. Didn't help, always goes into safe mode.

>>>stack>>>

ctx: todo
sp: 3ffffe90 end: 3fffffc0 offset: 0000
3ffffe90:  3fff0320 00000001 00000102 4023e9c7
3ffffea0:  00003fe8 00000001 00000102 4021771b
3ffffeb0:  00000000 4bc6a7f0 000000a3 3fff0ba4
3ffffec0:  00000000 00000000 4bc6a7f0 00000000
3ffffed0:  00002928 00000525 40100a72 3fff0ba4
3ffffee0:  3fff0320 3fff40b0 3fff40b0 40217a44
3ffffef0:  3fff0320 3fff0318 000000a3 402184e4
3fffff00:  3fffdad0 3fff0318 000000a3 40218b57
3fffff10:  3fff0464 3fff0858 3fff3ba4 4024e0cd
3fffff20:  3fff5254 0000009f 3fff3b84 4024e0cd
3fffff30:  3fffdad0 3fff1858 3fff3b84 40228d34
3fffff40:  3fffdad0 3fff0830 3fff0830 00000000
<<<stack<<<

@mcspr
Copy link
Collaborator

mcspr commented Oct 28, 2022

Stack contents, no. Everything should be decoded using an .elf that was used to create the .bin file
(see .pio/build/$env/ and our decoder script), since only SDK function addresses are fixed and we just don't know what's been called with what arguments, etc. (like function addresses starting with 4..., vars with 3...)

Let me check v9261f code again before retrying.

mcspr added a commit that referenced this issue Dec 4, 2022
ref. #2483, #2546 and #2554
instead of waiting for our time window, attempt to read & parse everything
discard unknown data more frequently, and attempt to store more data as well
@Kaan88 Kaan88 closed this as completed Dec 5, 2022
@fragolinux
Copy link

@mcspr hi, could you please help me in compiling a new build for my device? I had it working in the past, now updated to
espurna-1.15.0-dev.gitfb31449e+nightly20220613-wemos-v9261f.bin and no values are read anymore...

i have a wemos d1 mini with tx connected with optoisolator and resistor to D4 on the wemos... what parameters do i have to add to the config file? I'm using gitpod to compile, eventually... thanks!

@mcspr
Copy link
Collaborator

mcspr commented Apr 8, 2024

I think this should still apply?
https://github.com/xoseperez/espurna/wiki/PlatformIO

btw it is https://github.com/xoseperez/espurna/releases for .bin, nightlies repo was not updated for a while

@fragolinux
Copy link

I think this should still apply? https://github.com/xoseperez/espurna/wiki/PlatformIO

btw it is https://github.com/xoseperez/espurna/releases for .bin, nightlies repo was not updated for a while

hi, i tried 1.15.0-dev.gitb409dc27+github230330 (wemos v9261f variant), but again it does not read the data from the device...

trying to compile using platformio, via gitpod, but don't know which parameters to add to change the v9261f tx pin to D4, where is connected and works if using previous 1.14.1 bin file
thanks

@mcspr
Copy link
Collaborator

mcspr commented Apr 9, 2024

trying to compile using platformio, via gitpod, but don't know which parameters to add to change the v9261f tx pin to D4, where is connected and works if using previous 1.14.1 bin file

https://github.com/xoseperez/espurna/wiki/Sensors#v9261f-based-power-sensor

ESPurna build config uses -D{KEY} and -D{KEY}={VALUE} in build flags and #define {KEY} {VALUE} in .h files. -D{KEY} is there mostly for hardware, so check out config/hardware.h. When there are {KEY} and {VALUE} for certain settings, check out config/general.h or config/sensors.h.

Since .ini only has hw flag

espurna/code/platformio.ini

Lines 642 to 644 in 37d2837

[env:wemos-v9261f]
extends = env:esp8266-4m-base
build_src_flags = -DGENERIC_V9261F

We'd have to look at config/hardware.h. As you can see, default hardware UART TX & RX are used

#elif defined(GENERIC_V9261F)
// Info
#define MANUFACTURER "GENERIC"
#define DEVICE "V9261F"
// V9261F
#define V9261F_SUPPORT 1
// UART only reads data
#define UART_SUPPORT 1
#define UART_SOFTWARE_SUPPORT 1
#define UART1_BAUDRATE 4800
#define UART1_TX_PIN GPIO_NONE
#define UART1_RX_PIN 3
#define UART1_INVERT 1
#define UART1_PARITY Odd
#define V9261F_PORT 1
#define ALEXA_SUPPORT 0

A single pin is used in case of V9261F, which is UART RX. Changing it from 3 to 4 should set the new build default.

#define UART1_RX_PIN 4 // aka D4

Or, you can change runtime setting via terminal (WebUI debug, telnet, HTTP / MQTT api terminal opts) on existing device

set uartRx0 4
reset

After device reboots, it would use the new setting. This would override the default 3 set by the build flag, but uartRx0 would go back to 3 when device settings are erased (e.g. using factory.reset command or holding configured button0 for 10sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants