tobiasfaust / SolaxModbusGateway

Modbus RTU to MQTT Gateway
GNU General Public License v3.0
54 stars 17 forks source link

Ethernet support for WT32-ETH01 #26

Closed kagehisa closed 4 months ago

kagehisa commented 11 months ago

Is it planned to have an ethernet port of this gateway for the WT32-ETH01 board? I know this is a niche request but some people have only ethernet access to their solar inverters. Is there something planned?

tobiasfaust commented 11 months ago

Hi, Not planned so far. But its an interesting use Case. I ordered one to test it. Please be patient some weeks.

kagehisa commented 5 months ago

Hi, has there been any progress on this?

tobiasfaust commented 5 months ago

Hi Unfortunally, Not yet :( I already have the Hardware but no time to test. Actually i work on splitting the huge register.h into smaller files and able to edit them at webfrontend.

i will keep this issue on my todo List.

tobiasfaust commented 4 months ago

new release 3.2.0 is ready. Now I´m working on this

kagehisa commented 4 months ago

Thank you! If there is anything I can help with let me know. If it is wihin my capabilities I'm happy to help.

tobiasfaust commented 4 months ago

@kagehisa, please test it

kagehisa commented 4 months ago

@tobiasfaust, I checked out the dev branch and launched:

This went without a hitch. But when I try to upload it with:

esptool -p /dev/ttyUSB0 -b 921600 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x8000 partitions.bin 0x1000 bootloader.bin 0x10000 firmware.bin 0x180000 littlefs.bin

I get the following error:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting....... Chip is ESP32D0WDQ5 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: c4:de:e2:b2:1f:f8 Changing baud rate to 921600 Changed. Enabling default SPI flash mode... Configuring flash size...

A fatal error occurred: File littlefs.bin (length 1441792) at offset 1572864 will not fit in 2097152 bytes of flash. Use --flash->size argument, or change flashing address.

Am I using the wrong firmware target in PlatformIO? I guessed firmware ESP32 should work based on the docs.

tobiasfaust commented 4 months ago

The Parameter —flash_size has to adapt, depend on your Board please Check the Output of esptool.py --port PORT flash_id If something like that appears: Detected flash size: 4MB Can you adapt the parameter like this

kagehisa commented 4 months ago

Ok, thanks! 4MB flash size worked. I'll do the Modbus connection tomorrow.

Edit: Connected the device to my WIFI, but switching to Ethernet is not working. It is not taking over any settings at all. As soon as I save, the page gets reloaded and the option for WIFI is set again. Same for all the other settings.

@tobiasfaust : Where did you look up the required Pin numbers for connecting the RS485 module? The code states RX=2, TX=4 and RTS=5. But this does not make much sense with the pin configuration in this document. I have something in the back of my mind that the espressifIDE Pin convention was somehow different from what you would expect from the datasheets.

tobiasfaust commented 4 months ago

You can change pin assignment via settings what you want. Can you Check seriell console for log Output? At my side Ethernet works well.

kagehisa commented 4 months ago

Nope that is my problem, I can't. Whenever I try to change a setting and hit save, the page gets a reload and the Settings are gone. Since debug level is initial at zero, there is nothing on the debug out terminal either. I'll try to rebuild and reflash, could be an issue with the littlels.bin, since the webpage is not shown correctly (style sheet) either...

tobiasfaust commented 4 months ago

Can you please Open the Webpage in source Mode and try to Open the /web/Javascript.js separately. Its ok?

please Open the Page of files section, which files in each folder will show? Please Post some screenshots of files,- baseconfig,- modbus section

Edit: just tested, no problems while saving settings at my side ...... has to be test...

kagehisa commented 4 months ago

Hi, thanks for the hint with the Javascipt.js. Source mode tells me it is not finding anything: Screenshot_20240214_125140

That is what I get for the files section: Screenshot_20240214_125417_2

But it is weird, when I build the fs image I get the following output from platformIO:

Building in release mode Building FS image from 'data' directory to .pio/build/firmware_ESP32/littlefs.bin /regs/Deye_SUN_SG04LP3.json /regs/Solax-MIC.json /regs/Solax-X3.json /regs/Solax-X1.json /regs/Growatt-SPH.json /regs/Sofar.json /web/Javascript.js /web/style.css /web/UpdateResponse.html /web/PageHandleFS.js /web/UpdatePage.html /web/JsAjax.js

So the files should be there.

tobiasfaust commented 4 months ago

hhh, no files are in your filesystem. Can you upload littlefs.bin again? You can check it by webpage "files"

kagehisa commented 4 months ago

I did with: esptool -p /dev/ttyUSB0 -b 115200 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x180000 littlefs.bin

And got:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting........ Chip is ESP32D0WDQ5 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: c4:de:e2:b2:1f:f8 Enabling default SPI flash mode... Configuring flash size... Erasing flash... Took 6.01s to erase flash block Wrote 1441792 bytes at 0x00180000 in 141.5 seconds (81.5 kbit/s)... Hash of data verified.

Leaving... Hard resetting via RTS pin...`

Still no files in the system. Same behaviour as before. It is almost as if I'm writing on a write protected device without getting an write error.

Is there a way to inspect the content of the generated littefs.bin?

tobiasfaust commented 4 months ago

please test upload with:

esptool.py -p COM6 -b 921600 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partition-table.bin 0x1000 bootloader.bin 0x10000 firmware_file.bin 0x290000 littlefs.bin

kagehisa commented 4 months ago

Alright! That did the trick, had to replace partition-table.bin with partitions.bin and firmware_file.bin with firmware.bin but thats about it. I can now change settings. I will do the other tests from here on out.

tobiasfaust commented 4 months ago

Oh yes, that is only a template I changed that in Wiki to the right one.

kagehisa commented 4 months ago

Sorry it took me so long, I came down with a pretty bad flu. Switching to Ethernet works fine, I configured the board connections and was able to "talk" to my solax X3 inverter. So from my side everything works fine. Thanks again for the effort!

Do you want me to add a small sentence regarding flashing the wt32-eth01 board with the greater flash size and the changed flash adress for the littlefs.bin in the corresponding wiki page?

tobiasfaust commented 4 months ago

Hi sounds well. Thanks for your offer, what should I Write down at the Wiki Page?

kagehisa commented 4 months ago

I would just specify that this board requires the 4 MB flash size instead of 2 and the required littlefs.bin adress change.

Or just like this: For WT32-ETH01 (and similiar boards) use the following command to flash the device via the esptool:

esptool -p /dev/ttyUSB0 -b 921600 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partitions.bin 0x1000 bootloader.bin 0x10000 firmware.bin 0x290000 littlefs.bin