emporia-vue-local / emporia-vue2-reversing

MIT License
53 stars 12 forks source link

Decoding sensor data #1

Open krconv opened 2 years ago

krconv commented 2 years ago

Repurposing this issue for the discussion that it started. Was originally a question about connecting, and turned into a discussion about deciding the sensor data.


In the blog post, you mentioned that one of your USB-Serial adaptors wasn't working when you tried to connect to the ESP32. I'm wondering if I'm hitting the same issue; I only have one serial adaptor to test with at the moment though.

I'm using the FT232RL FTDI Mini USB to TTL Serial Converter, and getting nothing while trying to connect:

> esptool.py --port /dev/cu.usbserial-A50285BI read_flash 0 0x400000 flash_contents.bin
esptool.py v2.8
Serial port /dev/cu.usbserial-A50285BI
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

Process I'm taking to enter flashing mode:

  1. Power with 3.3v
  2. Pull IO0 pin to GND
  3. Pull EN pin to GND, and release
  4. Release IO0 pin

But that's not working; my only thought is that maybe there is something else connected with TX/RX that is interfering? And a different serial converter could sort through the noise?

Any guidance would be appreciated!


Edit by @flaviut for visibility:

There is now a ESPHome component. You can follow development at

flaviut commented 2 years ago

I've generally been supporting this here, if you'd like to move the conversation over.

@nightweyr I'm really not sure what could be going on here--the error is ERROR_TIMEOUT; the secondary processor is not responding to the request for data in a reasonable amount of time. The actual issue could be anything:

I'd try a few things, one at a time and then maybe together:

binfill3 commented 2 years ago

Thanks for the suggestions! I was putting off manually powercycling the device since I'll have to open up the panel. I'll try it this evening and post my findings in the comments of the gist page. I was able to remotely modify my esphome to use @flaviut's fork, but that didn't help.

faelenor commented 2 years ago

Hi! There are 3 power values for each clamp but only one seems to be useful. Do you know why all 3 are provided and what they could represent? I mean, I'm really curious to understand how the Atmel IC is computing them. For instance, the power value for the opposite phase is often close to the negative value of the power, but not always.

Somewhere, either in the ESP32 firmware or the cloud, Emporia automatically figure out which of the 3 value they should use, but why aren't they doing this directly in the Atmel firmware to avoid sending useless data? It's not super useful to understand all this as you have a working solution, but for some reason, I can't bear not fully understand how something works!

flaviut commented 2 years ago

Do you know why all 3 are provided and what they could represent?

Power is current * voltage. Each of the power values is for a different voltage. Keep in mind that AC is system where current and voltage continuously change--it's not enough to simply multiply, you need to multiply over a sufficiently small time interval.

For instance, the power value for the opposite phase is often close to the negative value of the power, but not always.

You are likely on a north american split-phase system. Your phases are opposite, ignoring tolerances, resistance losses, etc.

Somewhere, either in the ESP32 firmware or the cloud, Emporia automatically figure out which of the 3 value they should use, but why aren't they doing this directly in the Atmel firmware to avoid sending useless data?

Same reason the ESPHome plugin doesn't do this, and you need to set this up in the config. You need historical data, because the direction of flow can change, for example, in solar systems. It's also hard to do for circuits that stay around zero load.

faelenor commented 2 years ago

Power is current * voltage. Each of the power values is for a different voltage. Keep in mind that AC is system where current and voltage continuously change--it's not enough to simply multiply, you need to multiply over a sufficiently small time interval.

Yes, I know and that's why I found the values in the example_messages.txt confusing. If the two phases are exactly in sync but with opposite voltage (as they should be), the power value for both phases should be the same, but one value positive and one negative (assuming that the sampling rate of the ADC is high enough). That's not what I was seeing in your document. For example, the 3rd and 13th row are: P[V1]: 771.5, P[V2]: -185.5, P[V3]: -82.1 P[V1]: -56.8, P[V2]: 194.1, P[V3]: -1.0

Anyway, I tried to dump the raw power values in my setup and they are exactly as I would expect them. The power value for phase A is always very close to the negative value of phase B for all clamps and that makes sense. I'm not sure why you got weird numbers in the example_messages_txt file, maybe you have a different setup (but the voltage and frequency points to a North American setup too).

Same reason the ESPHome plugin doesn't do this, and you need to set this up in the config. You need historical data, because the direction of flow can change, for example, in solar systems. It's also hard to do for circuits that stay around zero load.

That makes sense, thanks!

flaviut commented 2 years ago

maybe you have a different setup (but the voltage and frequency points to a North American setup too).

I don't know if that's the case for me. I live in a condo, so the whole electrical thing gets a lot more complicated. I might just have 2 phases out of 3.

Actually, now that I look at it, I'm sure I have two out of three phases. My V2 is offset from V1 by 120 degrees according to that same file. It'd be 180 for split phase.

faelenor commented 2 years ago

Actually, now that I look at it, I'm sure I have two out of three phases. My V2 is offset from V1 by 120 degrees according to that same file. It'd be 180 for split phase.

That is very strange, I didn't know it was possible! Split-phase systems are supposed to be 2 lines that are out of phase by 180 degrees (that's what the wikipedia article you sent explains and that's what I've always seen). If you really have 2 out of 3 phases with an offset of 120 degrees, that could be a problem. It means that all your 240v equipment is working at only 75% of their rated power! Do you have a well defined load on one circuit, like a 1000w heater or something like that? You could look at its power usage reported by the Vue and see if it really is 1000w or closer to 750w.

flaviut commented 2 years ago

If you really have 2 out of 3 phases with an offset of 120 degrees, that could be a problem. It means that all your 240v equipment is working at only 75% of their rated power!

Yup. I guess you're right. I never thought about that.

Regardless, all the appliances are rated to work at both 240V & 208V. That's what I see when I check random manuals for various appliances.

faelenor commented 2 years ago

Yeah, they will work but may have lower performance (oven/water heater will take longer to heat for instance). I found a thread explaining that this is not common, but it can sometimes be seen in condos or in some areas. That's interesting, I didn't know about this!

blackburn42330 commented 2 years ago

In the US it is single phase or three phase. Most people believe there are 2 phases in a single phase scenario but there isn’t. It’s just two separate transformer windings that are in phase with each other. There are some old plants that have two phase 5 wire systems but it is very odd and I only have ever seen it once.   But a residence in the US is most certainly single phase unless it is a farm or something.  On Tuesday, April 5, 2022, 10:07:39 AM CDT, Francis Pagé @.***> wrote:

Yeah, they will work but may have lower performance (oven/water heater will take longer to heat for instance). I found a thread explaining that this is not common, but it can sometimes be seen in condos or in some areas. That's interesting, I didn't know about this!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

BlagovestKambarev commented 2 years ago

Hello I'm writing a driver for Berry's Emporia32. I read everything about the topic. I dumped the i2c bus. I reviewed cpp and h files for ESPHome. Things are working out for me. But I have a few questions:

  1. What are the indications for "Power data" used for in the accounts?
  2. When I take the bytes of the data for "Current data" in the file "emporia_vue.cpp" it is commented that they are not multiplied by a factor, but the data I receive are: 69, 77, 82 ..... The reports are constantly floating up and down . The load I measure is 44W. In order to get the above statements true, I have to multiply by a coefficient: 0.0022. How do you consider the consumption if you do not apply a coefficient for the indication? If all goes well, I'll draw a Tasmota "C" driver. Greetings Blagovest.
flaviut commented 2 years ago

Hey @BlagovestKambarev, let's discuss this in https://github.com/flaviut/emporia-vue2-reversing/issues/8.


For anyone else, locking since this particular issue is resolved, but still very interesting, so I'd rather not close it.

If you think I should unlock it or you have something else to discuss, please open a new issue!