Category Archives: ESP32

CAN/RS485-Wifi Adapter

I have mentioned that I need a dual CAN to Wifi Adapter as well as a dual RS485 to Wifi adapter, so I decided to make one that can serve both needs. This uses ESP32 to get Wifi, USB and Bluetooth and a STM32F405RG to get dual CAN as well as dual 10Mbps RS485 – all galvanic isolated.

The CAN Adapter is for professional usage, while the RS485 is partly as an adapter to my PLC system as well as a Wifi adapter to my DPS5005 & DPS5020 based PSU’s.

Layout on this was a bit tricky due to the size of the 9-pin D-Sub connectors and I am not done, but the current draft look very promising. Hopefully I will have this in rev 1.0 around October. Size is 100 x 70mm.

I actually started end partly developed a different adapter last time I needed CAN. I never finished that design, but much of the design is tested, verified and reused here. The only missing part is wired Ethernet.

ESP32 Oscilloscope & Logic Analyzer

Most of my Oscilloscope & Logic Analyzer needs are on frequencies below 1Mhz, and ESP32 have 16 12-bit ADC channels, so it would not take much to create a 16 channel low frequency Oscilloscope/Logic analyzer. This is why I bought a ESP32-WROVER dev kit. Wrover have 4Mb SRAM as well as all the features of ESP32.

Max sampling rate on ESP32 is 2Msps. The details here are not well documented, but if we assume a minimum of 10 samples per Hz we should be able to sample frequencies up to 200Khz. Even more interesting is that ESP32 contains support of programmable Gain through it’s logic pad’s. Again I must state that my knowledge in this area is limited and so it doc on the subject, so I need to experiment and see what I can achieve.

The good thing is that all I need is a breadboard and a kit costing 10.- USD to test this out. No guarantees, but it will regardless be interesting playing with the ESP32 ADC channels.

ESP32/STM32/Raspberry PI – all in one dev kit

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.

Not so mini CAN Adapter

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.

CAN Adapter with Wifi

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.

PLC – Connectivity Module

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.

PLC – Connectors Top/Bottom

This new Connectivity Module have 8 x RS485 connectors. I use the front for the antenna and USB, while top/bottom for connectors that most likely will be permanently wired.

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.

PLC-Connectivity Module

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?