odya / esphome-powmr-hybrid-inverter

ESPHome config for various PowMr Hybrid Inverter models.
MIT License
115 stars 18 forks source link

Is it possible to use esp8266? #42

Open tistructor opened 6 months ago

tistructor commented 6 months ago

I repeat the title question: Is it possible to use esp8266? In order to insert the firmware into the wifi antenna supplied to the inverter.

tistructor commented 6 months ago

I did the test and it works correctly, we need to eliminate the temperature sensor inside the esp32 because the esp8266 doesn't have it.

I managed to insert this firmware into the wifi dongle supplied with the inverter.

Thanks, everything works.

In fact, I also inserted modbus commands to read the second mppt for those who have the firmware that accepts this command.

 - platform: modbus_controller
    modbus_controller_id: smg_inverter
    name: "PV Voltage2"
    id: pv_voltage2
    address: 4563
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1
    lambda: |-
      return swapBytes(x);
    filters:
      - multiply: 0.1

  - platform: modbus_controller
    modbus_controller_id: smg_inverter
    name: "PV Power2"
    id: pv_power2
    address: 4564
    register_type: holding
    value_type: U_WORD
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    accuracy_decimals: 1
    lambda: |-
     return swapBytes(x);
lufton commented 5 months ago

@tistructor I kinda made the same for 10.2kW version. Are we talking about Wi-Fi Plug Pro-05? The only problem I found is it reboots every 15-30 seconds. I measured voltage on 3.3 rail and it drops down to 0.4V periodically witch lead to reboot. I don't think I managed to break something while flashing and debugging and also not sure there wasn't an issue before I made modifications though. If I hookup external power (e.g. from USB TTL converter) then everything is okay.

tistructor commented 5 months ago

There is an esp8266 GPIO that generates a 2 HZ square wave that disables the 3.3v to turn off every 20 - 30 seconds. This problem can be eliminated by using a jumper or via firmware. WhatsApp Image 2024-05-12 at 11 09 51

The gipio is the 13th, I put this file in the esphome project helper folder and compiled. it works well.

#include "esphome.h"
#include "Arduino.h"
//#include "pins_arduino.h" se si include questo file si possono utilizzare la codifica arduino per i gpio altrimenti si deve usare la codifica esp8266
class enDonglePWM : public Component {
 public:
  void setup() override {
    // This will be called once to set up the component
    // think of it as the setup() call in Arduino
    pinMode(0, OUTPUT);
    digitalWrite(0, LOW);
    pinMode(4, OUTPUT);
    digitalWrite(4, LOW);
    pinMode(5, OUTPUT);
    digitalWrite(5, LOW);
    pinMode(13, OUTPUT);  
  }

  void loop() override {

        static uint32_t timerPWM = millis();
        static bool state = false;
        if(millis() - timerPWM > 1000){
            timerPWM = millis();
            digitalWrite(13,!state);
            state = !state;
        }
  }
};
lufton commented 5 months ago

Wow, @tistructor thanks, I'll try your solution! How did you manage to reverse-engineer that?

lufton commented 5 months ago

I've fixed mine connecting input of additional 3.3V linear voltage regulator to output of 5V regulator and it's output to 3.3V rail.

tistructor commented 5 months ago

Wow, @tistructor grazie, proverò la tua soluzione! Come sei riuscito a decodificarlo?

I checked the signals on the various pins of the esp8266 with the original firmware and saw that the gpio 13 performed this function of disabling autoreset. If you perform the procedure via firmware you do not need to make any hardware changes and if you put the original firmware you get the same factory features. I believe that some GPIOS have the function of updating the dongle's firmware remotely and with hardware modification it may present some problems in carrying out this operation. It's just a guess.

lufton commented 5 months ago

Do you think this will also work?

output:
  - platform: esp8266_pwm
    id: keep_alive_output
    pin: GPIO13
    frequency: 2Hz

upd: actually it will require some additional component like light and setting brightness to 50%.

tistructor commented 5 months ago

Pensi che funzionerà anche questo?

output:
  - platform: esp8266_pwm
    id: keep_alive_output
    pin: GPIO13
    frequency: 2Hz

upd: in realtà richiederà alcuni componenti aggiuntivi come la luce e l'impostazione della luminosità al 50%.

Try. I used the old method because I'm not an HA expert but I saw that it can also be done through HA configuration files. It should work, there are several ways to do this.

lufton commented 5 months ago

I think this should work:

interval:
  - interval: 250ms
    then:
      - output.toggle: keep_alive_output

output:
  - platform: gpio
    id: keep_alive_output
    pin: GPIO13
tistructor commented 5 months ago

https://community.home-assistant.io/t/blink-how/307243/5

tistructor commented 5 months ago

I haven't run trials, but one of these medoti should work.

lufton commented 5 months ago

output should work the same way as switch, but configuration will be shorter and I believe firmware is gonna be smaller as switch implementation is much more complicated than output.

lufton commented 2 months ago

@tistructor according to your code it looks like it pulses not 2Hz, but 0.5Hz (full cycle in 2 seconds). So what is the correct value?

tistructor commented 2 months ago

@tistructor according to your code it looks like it pulses not 2Hz, but 0.5Hz (full cycle in 2 seconds). So what is the correct value?

Yes, that's correct, I wrote wrong. 0.5Hz is the correct value.