Remote ESP32 Module with RS485 and CAN bus Interfaces

Post Reply
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Pete9008 »

I've designed a PCB based around an ESP32-WROOM-32E that is intended to provide a remotely mounted version of the web interface WiFi module:
RemoteESP32.JPG
The idea is that this lives outside the inverter (not mounted on the control board). This should give better WiFi signal strength, reduced electrical interference and make it easier to access the module if OTA updates stop working (it also makes it easier to get at the SD card).

It has two communication interfaces, RS485 and CAN bus. At the moment the CAN bus isn't supported in the firmware (the CAN hardware isn't tested either as I don't have a suitable chip handy!).

It also has an SD card on it to allow data logging and a real time clock to time stamp the SD card files.

The PSU, ESP32, RS485 and RTC (except for backup battery which I still need to order) are tested and working. The CAN interface hasn't been tested yet. To use with a standard OpenInverter board it will need an small RS485 interface board making to go in place of the normal WiFi module (essentially the ISL83076E block from this board plus a plug to fit with the normal WiFi module header). If there is enough interest I'll do a quick Kicad design for one.

The board is designed to accept Molex KK headers but 2.54mm pitch screw terminals may fit (untested). I intend to solder wires directly to the board on mine.

There are a few more details on using it in the github readme.

The Kicad design is here : https://github.com/Pete9008/RemoteESP32-Board
The firmware is here : https://github.com/Pete9008/esp32-web-i ... /Remote485
And a pdf of the schematic is here:
Schematic.pdf
(101.29 KiB) Downloaded 88 times
Hope it's useful to someone :)

Edit - Note - the above picture is a little out of date as far as the SD card pull up resistors are concerned so the picture doesn't match the BOM on github. The BOM is correct though.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Pete9008 »

Git repository updated to include models for 3D printable enclosures.

There are two there, a slimline one I did before realising that the RTC battery wouldn't fit inside it! It might be useful to anyone not using logging and the RTC though so have included it anyway:
NoBat.png
And a larger one that tha battery will fit in (this one is a bit bigger than I'd like so may have another go at it with the recesses for battery and ESP32 to reduce the height a little):
Bat.png
Both are designed to take a rubber grommet strain relief (9mm hole) and are not designed to be sealed and print fine.

Note - This is the first design I've done with both FreeCAD and constraint based design so I very much doubt that it's the best way of doing it!

Edit - Worth noting a few things that I'd change if doing the PCB again:
  • Add a couple of LED's!
  • Change from a push/pull to a push/push SD card holder and mount it a little closer to the board edge (I already had this socket and had originally planned on just heatshrinking it rather than having a case).
  • Use a different form factor inductor in the PSU (again this is a part I already had spare but it is a bit big and over specced for this application).
  • Possibly add/replace the battery with a permanent 12V feed and a uPower regulator (a battery is more convenient for development, a permanent supply is better for end use)
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Pete9008 »

Quick update, wasn't happy with the larger case, just a bit too bulky. However, a little bit of reworking of the battery pins gets it to fit into the smaller case:
ESP_Case.JPG
Needs a little hot glue or sealant between the battery and PCB to give it some additional support but should be OK. Was a little worried that the battery was discharging too quickly but have double checked the calcs and it should be good for years. Have cleaned all the flux of the board in case there was some leakage current and am keeping an eye on it to see if the voltage stabilises.

If there is a rev2 I'll change to a smaller surface mount crystal which should create enough space to change to a battery that lays flat as standard.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Pete9008 »

Got fed up of my old programming lead which needed manual intervention to switch the IO0 line to put the module into programming mode before programming and then again to switch it back before running so have come up with a better solution:
Prog.JPG
It uses an FT232RL based USB to serial TTL converter. These chips have both DTR and RTS lines on them, the DTR line goes to GPIO0 and is used to put the ESP32 into bootloader mode on reset while the RTS line goes to EN and applies a reset pulse to start the bootloader. You can just about see in the picture that GND, Rx and TX are in the right places on the module header but the other pins have to be isolated and wire links used to connect pin2 to DTR and Pin6 to RTS (pin1 is the bottom one, coloured black, in the picture).

With this done and the programmer plugged into the ESP board:
Prog2.JPG
The esptool (used in PlatformIO and Arduino for ESP32 programming) will automatically drive the lines to put the ESP32 into programming mode before programming it. When not in programming mode the two lines are inactive allowing the ESP32 to run normally.

One slight pain is that when using serial monitor window within PlatformIO it drives the two lines active so holding the ESP32 in reset. To get round this click into the serial monitor window and do a Ctrl-T, Ctrl-D, Ctrl-T and Ctrl-R to take the two lines inactive. There are monitor configuration flags that are supposed to do the same but I haven't been able to get them to work so far. The Ctrl-T, Ctrl-R sequence (used twice) can also be useful to reset the ESP32 from the monitor window. Guessing the same problem may be there from the Arduino monitor window but haven't tried it.

This should work for programming any ESP32 based board but obviously the header pinout may change!
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by johu »

Neat!
Have the Damien-version of the board here and will try to run the regular web interface with CAN backend.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 211
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 14 times
Been thanked: 35 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by davefiddes »

Pete9008 wrote: Tue May 16, 2023 9:28 am One slight pain is that when using serial monitor window within PlatformIO it drives the two lines active so holding the ESP32 in reset.
There is a standard(ish) bit of logic fitted to most dev boards to tackle this problem:
ESP32-programming-header.png
ESP32-programming-header.png (10.71 KiB) Viewed 7719 times
This is from the Espressif ESP32-Core-Board-V2 eval board schematics. I've built such a thing into an FTDI FT232 based programmer for ESP32 programming using a header not unlike your design.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Pete9008 »

johu wrote: Tue May 16, 2023 8:15 pm Neat!
Have the Damien-version of the board here and will try to run the regular web interface with CAN backend.
:-)
Any idea whether he has changed or modified anything?

I've put the CAN transceiver on mine now. Not bothered about using it to talk to the inverter (as the RS485 should be much faster) but I'm thinking about porting over a bare minimum of GVRET to allow it to be used as a SavvyCAN dongle and also provide CAN logging to the SD card (to a separate file to the inverter data).
davefiddes wrote: Wed May 17, 2023 10:47 am

There is a standard(ish) bit of logic fitted to most dev boards to tackle this problem:
ESP32-programming-header.png
This is from the Espressif ESP32-Core-Board-V2 eval board schematics. I've built such a thing into an FTDI FT232 based programmer for ESP32 programming using a header not unlike your design.
Thanks, I'm familiar with that circuit and have used it before but unfortunately didn't put the components on my board and couldn't be bothered putting them on the programmer (but it would be a better solution!).

I've now found the right config to get the PlatformIO monitor to behave without them. In the platformio-local-override.ini just add the lines:

Code: Select all

monitor_dtr = 0
monitor_rts = 0
and it should behave (it will still give the ESP32 a brief reset pulse when the monitor starts but in some ways that's useful).

For the Arduino monitor I think you would need the transistor circuit though.

Edit - it would seem that there are similar lines in the Arduino ESP32 board definition that do the same for the Arduino serial monitor (https://arduino.github.io/arduino-cli/0 ... ification/). Not tried it but supposedly setting:

Code: Select all

esp32s3.serial.disableDTR=true
esp32s3.serial.disableRTS=true
might fix it in there?? (the transistors still seems like a better solution though!)
Peakon28
Posts: 14
Joined: Sun Dec 06, 2020 8:37 pm
Has thanked: 4 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Peakon28 »

Hey Pete,

I love the idea of the external ESP 32 module. I wanted to make my own by using your design but the firmware link doesn't exist anymore. Did you move it to a different repository?
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by johu »

Peakon28 wrote: Sat Oct 14, 2023 8:30 pm I love the idea of the external ESP 32 module. I wanted to make my own by using your design but the firmware link doesn't exist anymore. Did you move it to a different repository?
I'm not Pete, anyhow this firmware implements the CAN interface https://github.com/jsphuebner/esp32-web-interface
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
jrbe
Posts: 265
Joined: Mon Jul 03, 2023 3:17 pm
Location: CT, central shoreline, USA
Has thanked: 92 times
Been thanked: 65 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by jrbe »

davefiddes wrote: Wed May 17, 2023 10:47 am There is a standard(ish) bit of logic fitted to most dev boards to tackle this problem:

ESP32-programming-header.png

This is from the Espressif ESP32-Core-Board-V2 eval board schematics.
I've been reading about programming the ESP32 and found this 2 npn reference circuit. But it seems some are still running into programming issues and are adding a .1 - 1uf capacitor to the enable line to add a bit of a boot delay. That seems to fix the programming issues.
There are others that claim only the en capacitor is required to program the ESP32 (and that the 2 npn transistors aren't required.) This is how the current openinverter ESP32 boards are configured (just the en capacitor with a feed resistor for boot delay.)

Anyone that has tested both methods have any feedback on them? I'm working on the gen 3 leaf adapter board. It's currently setup with the enable capacitor / resistor (aka boot delay). Asking for that but the info should still help here.
Peakon28
Posts: 14
Joined: Sun Dec 06, 2020 8:37 pm
Has thanked: 4 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Peakon28 »

johu wrote: Sun Oct 15, 2023 2:50 pm I'm not Pete, anyhow this firmware implements the CAN interface https://github.com/jsphuebner/esp32-web-interface
Thank you Johannes, but did I understand correctly that there is no RS485 implementation?
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by johu »

Not on the inverter side, lacking direction selection pin
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
royhen99
Posts: 195
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 14 times
Been thanked: 94 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by royhen99 »

Pete's hardware had option for full duplex RS485, but would still need an apropriate transceiver connected to serial RX and TX lines. I have recovered the code from my backup drive. I have not tested this and not sure how far Pete got without re-reading this thread.
Attachments
esp32-web-interface-Remote485.zip
(175.93 KiB) Downloaded 44 times
Peakon28
Posts: 14
Joined: Sun Dec 06, 2020 8:37 pm
Has thanked: 4 times

Re: Remote ESP32 Module with RS485 and CAN bus Interfaces

Post by Peakon28 »

Thank you Johannes and Royhen99. I am planning to implement the transceiver on the Open inverter board.
Post Reply