Robins solar diverter mk2pvrouter with Fronius - BYD battery setup

Had 8266 D1 mini on the brain. Probably because there’s one sitting on my keyboard. :wink:

At any rate, the “32” suffers from a non-linearity issue.

That said, here’s some info on how at least one user has addressed it.
He says he gets ~1% accuracy. YMMV.

That says: “by using a polynomial the output can be made accurate” How much additional load does that impose on the processor? and can it still do what is needed in the time available?

Bear in mind the ESP32 runs much faster than the 328p.
Typically 160 MHz. Max speed is 240 MHz.

I don’t know how much additional load the polynomial is. I didn’t see any info WRT it.

Another method mentioned was a lookup table. Didn’t see anything more than the mention of it though.

I take it this number is the clock. What we need to know is the ADC sample rate. I’ve never managed to track down a credible figure for anything from Espessif.

From what I can see of it, the Espressif devices I’ve seen mentioned here are excellent for the things they are intended for, it’s just that energy monitoring isn’t one of them.

I’ve seen exactly that and no more. Are you expected to measure the input characteristic and write your own - 4096 lines of lookup table? There’s little doubt it would be faster than calculating polynomials, but even if you can assume the main body is linear and so can be calculated, I wouldn’t fancy typing a few hundred values for the part where it goes badly wrong.

This Page Not Found - ESP32 - — ESP-IDF Programming Guide latest documentation mentions “Characterization based on Two Point values and fitting curve coefficients stored in eFuse” but I don’t think this is related at all to the lookup table.
This ESP32 Analog Input with Arduino IDE | Random Nerd Tutorials) makes reference to the linearity problem, but nothing more.
More likewise at https://www.esp32.com/viewtopic.php?t=1045

I recall one of the authors mentioning
The ESP32 ADC has two non-linear regions, one just below ~0.5v and the other just above ~2.5v,

The polynomial calculation is several floating point math operations, so likely eats more than just a little CPU time. Viz:

double ReadVoltage(byte pin){
  double reading = analogRead(pin); // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095
  if(reading < 1 || reading > 4095) return 0;
  // return -0.000000000009824 * pow(reading,3) + 0.000000016557283 * pow(reading,2) + 0.000854596860691 * reading + 0.065440348345433;
  return -0.000000000000016 * pow(reading,4) + 0.000000000118171 * pow(reading,3)- 0.000000301211691 * pow(reading,2)+ 0.001109019271794 * reading + 0.034143524634089;

Another user says he did some tests on the 32’s ADC speed and came up with this: (~27 ksps)

Also on that page:

In the Espressif datasheet, (topic 4.1.2), the ADC characteristics shows the following maximum sampling rates.

Description Sampling rate (max)
RTC controller 200 ksps
DIG controller 2 Msps

First question: what is a DIG controller and why has the RTC/DIG controller impact on the sampling speed? Assuming the numbers in the datasheet are valid, the measured speed differ massively from this rates. The implementation of adc1_get_raw is quite complex and does a lot of hardware initialization/locking around adc_convert().

So, the hardware might be capable to provide the claimed speeds but definitely not when using Espressif’s IDF as described in their documentation.