Hi,
I have node with ESP8266 and a MCP9808 sensor, powered by a Li Ion battery and I’m trying to transform the voltage into percents. After some measurements I got the values and I found the polynome which make the approximation. I wrote the following code but I got multiple errors, like "error: invalid operands of types ‘float’ and ‘int’ to binary ‘operator^’ ".
I also tried with ** instead ^ , and I got errors again.
Can you tell me where I’m wrong ?
sensor:
- platform: mcp9808
name: "temperature 2"
accuracy_decimals: 3
update_interval: 5s
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 5
send_first_at: 5
- platform: adc
pin: A0
id: "VCC"
name: "VCC Voltage"
- platform: template
name: "esp.2.battery_level"
unit_of_measurement: '%'
update_interval: 60s
accuracy_decimals: 1
lambda: |-
return (-977211.49558157 * (id(VCC).state ^ 6) + 5411281.4640799 * (id(VCC).state ^ 5) -12466351.8144136 * (id(VCC).state ^ 4) + 15293079.3922985 * (id(VCC).state ^ 3) -10535836.6353753 * (id(VCC).state ^ 2) + 3864709.89796487 * (id(VCC).state) -589669.805433792 );