This model is not complete, but it gives an idea. I still lack the battery and the TF Card. The objective here is that I need a low cost CAN Adapter with Wifi to create an adapter that always work as an Analyzer as well.
Starting at left is a ESP32 Breakout board, then one of my own STM32F405RG breakout boards, a 5″ HDMI, Wireless keyboard and Raspberry PI 3 with my 5 port Hat – and your right it’s a different Hat with screw terminals, so I do have 2 x 5 port Hat’s working.
What I will do here is to wire up SPI between ESP32 & STM32 for testing, and I can add CAN breakout boards etc getting the boards to communicate. The only drawback here is that I can only use one SWD at the time, but I will get around that.
This is the same drawing as the previous post, but I added the TF Card option. Basically this is a small mini-computer Complete With display, keyboard (in the display), Wifi, Storage etc. Just for the record it actually got more “disk” and RAM than my first IBM Compatible PC.
I have never done a TF-card Interface, but I have some breakout boards laying around. As mention you can actually buy this on the NET known as “CAN32” for ca 39.-USD. It comes as a specialized breakout Board for ESP32. But, the good things is that I can easily assemble this on a vero Board to get started – and since someone else have made firmware for this we can use their project and modify it as a starting point.
What I want to achieve here is a CAN Tesrter, Analyzer & Adapter – all in one. I need CAN connectivity and I need to see what happens on several CAN Networks simultaneously. As mentioned earlier I will use a STM32 to deal with CAN and make this galvanically isolated later, but this is something I can wire up and start with while waiting for PCB’s.
Assuming the TF Board Works out I should also add this to the larger Board. I also think I want to Mount the display on ESP32 and if I have Space add the 16 analogue IO lines from STM32 as a separate port.
This design start to make a bit sence because we now use ESP32 for Wifi, HMI, Storage, while we leave CAN and IO to STM32.
The last part of this project is boxing it. In fact, we could use Bluetooth to connect to our phones/tablets as HMI rather than adding a UART based HMI as well. With Wifi I can obviously connect my laptop as HMI, but the reason I explore other options is because my laptop usually is occupied otherwise and I need the extra screen. Fiddling around swapping screens and turning Smart Phones orTablets on/off is not always the most convenient choice, so having a physical display on the adapter is a priority IMO.
It’s only one flaw here – I am making all this for CAN while I myself am a heavy user of RS485/RS-X. The STM32 I use here have 5(6) UART’s, and if I commit on using STM32F405RG I have 2 x 10Mbps RS485 capable ports that will be very handy for sniffing on my PLC system later.
The only thing is that I can’t use galvanic isolation at that speed, but I can live with that. Woops – wrong! Checking the datasheet of ADM2582E it supports data rate to 16Mbps!
Puh – I better stop writing before I add more into this – my only concern here is what speed I can get between ESP32 and STM32 on UART or SPI. I am hoping on 40ich Mbps on SPI, but that is yet a unknown that I need to investigate. I think ESP32 is capable of this, but it’s more if I am capable of using it – lets see.
It exist a project that simply add a CAN Tranceiver to a special ESP32 dev Board – called CAN32. This uses the CAN on ESP32 and provide a Wifi based CAN Interface. I have a few CAN breakout Boards and Nextion displays so I want to assemble one of these. The main drawbacks With this is (1) I am unsure about the quality of CAN on ESP32, and (2) it don’t uses a galvanic isolation.
Galvanic isolation complicate things a bit. You don’t really need it for Wifi usage, but you seriously should have it if you connect the USB to your PC With industrial equipment on the other side.
I need a CAN adapter for a special job and decided to build my own. I use ESP32 to get Wifi, Bluetooth and USB Connectivity, but I decided on adding a STM32 to get dual CAN Connectivity. ESP32 do have an undocumented CAN port as well, but I assume ExpressIF have their reasons for hiding it. The display is because I also want to use this as an Analyzer sniffing. And as a adapter of this type will be connecting to industrial equipment I also want the galvanic issolation.
This will cost me around 20.- USD in components + display and boxing, but to buy something like this I would probably have to pay 500.- to 1000.- USD if I could find one.
I have listed both UART and SPI for communication between ESP32 and STM32 because I am unsure about both on ESP32. I know they exist, but have no experience with them so I can as well just Connect both . I also added a battery option on the PSU.
Still an early draft, but show the 8 RS-485 connectors at top/bottom. I only use right angle headers in the 3D, but they are 2.54 pich so they can be replaced with other connectors.
I still have a few loose ends. RS485 circuit can be switched off into 3-state by setting RE High and DE Low (Neither receiving or sending). I need a similar way for the ESP32 to switch off the STM32F405RG so we can go low power. I also want a 3.7V Battery connected on the back.
I should have plenty with spare pins so we can add a few more leds etc. I do however need to solder up a RS485 (or find a breakout) and test that I can get UARTS where I want on ESP32.
Some users would probably request both 4-wire RS422 and RS232 and I will make a board for those later. I also need a CAN board.
As for MCU power – The MCU’s above have too much/too little. For most of the things I do they are an absolute overkill. The exception is math algorithm’s where we would need the stronger Raspberry PI. The only reason I need the STM32F405 here is because of it’s 2x10Mbps UART’s used as backbone.
Just for the record – the 3D model above is just an early draft to illustrate our options. I use those right angle headers on the 3D model, but the real can be fitted with a variety of 2.54 pitch connectors.
This draft will give me 6 (8) RS-X ports. 6 if I use the backbone and 8 if I use this stand-alone. In addition Ethernet, Wifi and Bluetooth as well as USB.
RS-X Port is 4 pins with 12V and RS485 differential signalling. Basically it feeds 12V Power to the RS-X devices. I like playing with this idea a bit. This would be a very interesting RS-X router. It’s Wifi/RS-X capability makes it an ideal bridge between Wifi and Wired networks.
This next diagram show the ESP32 Connectivity capabilities stand-alone with USB, Ethernet, RS-X, CAN, Wifi and Bluetooth. I definitely want to make this module as it will be small. I wonder if I should make this as and add-one to the STM32 based PLC board?
I drafted a GSM/Ethernet module as well as a 3xGalvanic RS485 earlier, but I am toying with the idea of attempting a PLC Module with STM32F405 using ESP32 for Ethernet/Wifi and 4-6 RS-X ports. 4 if used as PLC-module, 6 if used stand-alone. I have also 2 CAN ports if I can find space/pins for them and I actually have CAN/UART’s on ESP32 as well.
I could connect ESP32 to the backbone as illustrated below, but I have little data on it’s UART speed yet. It’s just an idea for now.
I have not made a move on my PLC concept yet for the simple reason that I have far to many designs/PCB’s that I need to work on and too little time as is. But, still fun to toy with ideas. ESP32 basically cost the same as a W5500 and can do both Ethernet, Bluetooth and Wifi. It will however need an external Phy for Ethernet.
I have a few Raspberry PI Hat’s laying around and I wonder if I should make a ESP32 based replacement for Raspberry PI Zero W. The IO on ESP32 is far more capable than the one on the PI, but we have a few limitations and less pins to play with.This is an early draft with the 3D above and PIN mapping below.
|Raspberry PI Pin||ESP32 PI||Description|
|3||8 – GPIO32||GPIO2 / I2C-SDA|
|5||9 – GPIO33||GPIO3 / I2C-SCL|
|7||10 – GPIO25||GPIO4|
|8||11 – GPIO26||GPIO14 / UART-TXD|
|10||12 GPIO27||GPIO15 / UART-RXD|
|19||27 GPIO15||GPIO10 / MOSI|
|21||28 GPIO2||GPIO9 / MISO|
|23||30 GPIO4||GPIO11 / CLK|
|24||31 GPIO16||GPIO8 / CE0|
|26||33 GPIO17||GPIO7 / CE1|
|27||ID_SD I2C ID EEPROM|
|28||ID_SC I2C ID EEPROM|