Category Archives: ESP32

Raspberry PI Hat’s

It’s been many Hat’s lately as I am focusing more and more on this as my main core for everything. I still have a load of Hat’s that I want to start on, but I won’t exactly have much spare time the coming year. This is just a summary of projects that I am working on and intend to complete.

XPortHub. Basically a communication Hub With CAN, RS485, RS232, SPI, I2C, USB + Micro SD Card, RTC, Flash etc. This Board is actually assembled and so far working well.

Wifi Hat based on ESP32 to enable a low-cost Wifi/Bluetooth With CAN, RS485 and a few IO ports. I have PCB for this Board, but have yet not assembled or tested it.
32 x IO / Servo Controller.

Not ordered.

8 x DC Motors + 16 x Sensors.
7 x 5-Wire Stepper Driver.
3KW Universal motor driver, Capable of 60V @50A on 3-Phase, DC, Stepper or Solenoids.
NB-IoT/4G Hat.
Light-weight 60V PSU. This is only a test board with the Hat format.
LoRa + GPS Hat. Shown With 12km 1W configuration.
LoRa + GPS Hat. Shown With 6.5km 0.1W configuration.
2A Motor Controller. Can run 6 x 3 Phase, 4 x Steppers, 9 x DC motors or 18 Solenoids/PWM signals. This is still work in progress.
3KW 3Phase Motor Controller. This uses DRV8301 and is designed for 60V@50A. This actually need a revision before it is ordered.
Mini stand-alone 3-Phase Controller for 2A. This is assembled and is working, but the 60V DC/DC needs a revision.
CAN – USB Adapter. Assembled in rev 1.1 and working.
ESP32 Utility Driver – 4 sensors, 8 Servo/IO, 2 H-Bridge, 7 PWM signals. This is assembled and working rev 1.1.
Model Train Cockpit Controller. This is a failure and need a revision + a support adapter. A rev 1.2 is on my list.
STM32FxxxRx Breakout Board. Assembled and tested for F105 and F405.
Breakout for STM32F031F4 or STM32F042F6. Assembled and working.
My SWD Adapter. This will need an upgrade, but it has been one of my most usefully designs. It enables me to use a small 1.27 pich footprint on my designs and deal With ST-Link 2.54 Pitch. Next Version will have Reset and Boot Connectors.
Micro sensors and actuators. I had 4 of these designs and the Temperature, Light, Proximity sensor will be upgraded. More external sensors will be added later.

And more – many of my older designs have either been ditched or evolved into more mature designs listed above. I will be focusing more and more on the new Raspberry Hat format for everything. The exception will mainly be a series of intelligent sensors evolving out of my STM32F031F4 micro designs.



Ethernet/Wifi Hat

I want an Ethernet module to by list of boards. I can always use Raspberry PI 2/3, but I would still like to make my own as well. In the past I have used W5500 a few times, but this time I want to dig into ESP32.

ESP32 already have the TCP/IP stack, it has Wifi/Bluetooth and an Ethernet interface. A few vendors have also show schematics for Ethernet on ESP32, so it makes sense upgrading my ESP32 Hat with Ethernet. I do have the space if I drop the RS485 etc. A quick check also tell me that I have the pins as well.

The Raspberry PI Header can be sacrificed if I need to. CAN is the backbone bus and this is most attractive if I want to replace Raspberry PI as Wifi/Ethernet GW.

This Hat is not a priority, but I will make it at some point.

New PCB’s

The first 2 Hat’s of my new series arriving – I paid for the fast track because I will be assembling and testing these over x-mas. The PCB at left (above) and below is the XPortHub, the other is the ESP32 based Wifi Hat. The picture below is on top of a Raspberry PI 3 A+ and mechanics fits perfectly. Also the Micro SD card was perfect, so this looks good.

Wifi Module

I moved CAN to the same place as the X Hub and will be using this from now. Added jumpers for RS485 vs UART out. The rest is as before:

  • ESP32
  • RPI connector using SPI
  • CAN port
  • RS485/UART port
  • USB Serial/Programming port.
  • 5 x Sensor ports.

The X Hub is a better match for Raspberry PI, but this can replace Raspberry PI to get Wifi and with the CAN port you can stack up IO as much as you want.

ESP32/RPI Adapter – Ground Plane Check

A trick I use is that I connect GND to the ground plane to avoid ground loops. But, what I need to watch out for is isolated icelands that is not connected. I realized that the EDA don’t check this, so I check it manually by using MSPaint to paint the ground plane. In this case it is ok as all areas used actually are connected to ground.


Model Train Control System – Part 4 Connectors

The illustration above show the number of connectors we could need on the Train Control System. I intend to use 1.25mm JST Micro connectors, but space is very limited so this will be a challenge.

  • #1 is the 6 pin programmer port. It is no way to get the programmer with USB connection on the controller so I create a 6 pin program port and a separate programmer board. The intention is to wire this up so we have access to the port below the train. Once this is coded we can also use the Wifi for updates. 
  • #2 is the 2 pin power port
  • #3 is the 2 pin Motor port. 
  • #4 is the 2 pin Super-Cap port. Super cap is like a small battery that will keep the system alive as we move over track gaps. 
  • #5 is the extension port to a 2nd controller board.

To optimize this I plan to reduce this to two connectors. One for Motor, Power and Super-Cap and a 2nd for Programming/Extension. I believe 2 connectors are doable, but I need to draw the packages and make a PCB layout before I actually know.

ESP32/RPI Adapter

This is an early mockup of a ESP32 based adapter for Raspberry PI. I like this early mock-up’s because they give me an idea about what we can get away with. in this case I can add 3-4 connectors top-left to get some extra IO, but I will still have plenty of space.

I need to connect and experiment with CAN and UART’s on ESP32 before I finalize this board. But, I do like this form-factor. I can probably also squeeze this down to a smaller format dropping the IO connectors.

I added 1 x CAN, 1xRS485 and 1xUART. The later is perfect for HMI etc. This will as mentioned work as a RPI Hat or stand-alone Wifi connector. The good thing about ESP32 is that it is still a decent, low cost breakout even if you do not use Bluetooth or Wifi.

Raspberry PI PLC Adapter

The release of Raspberry PI 3A+ is a good host for a mini level system due to it’s powerfully 4 x 64 bit CPU, but as the RPI itself do not contain any com connectors we need to use an adapter card. I decided to try ESP32 because that makes it dual purpose. ESP32 can act stand-alone using it’s own Wifi or just gateway to Raspberry PI for more power and to enable a RS232, RS485 and CAN port.

I use the GPIO and SPI port to communicate with Raspberry PI and CAN or RS485 for the rest of the network – or I just use the ESP32 as host for lower cost – depending on Application.

Model Train Control System – Part 3 Programmer

Part 3 of the Train Controller will go to a separate USB card we need to connect for initial programming of the ESP32. On this we connect GPIO0, ChipPU and the default UART. This is needed to program and develop the FW on ESP32.

The USB chip is a CH340G. Most other designs will use a FTDI chip, but you will not see a FTDI chip in any of my designs. That Scottish company bricked my 3D printer a few years back and I simply dot trust them + CH340G is low cost, well supported and always work.

This schematics is borrowed from the utility driver. I think I can use it “as is”, but I will add a separate 3.3V regulator to feed the ESP32 power from the USB while programming. This means I need a 6 pin programmer port with +3.3V, RX, TX, GPIO0,ChipPU and GND. I will make a micro JST on the board and maybe an optional connector board that can be available under the train so we can connect without direct access to the control system. This is because I need some flexibility around hiding parts of the system in small locomotimes.


Model Train Control System – Part 2 H-Bridge

The second part of the Train control system is it’s motor driver. This is based on a classic L9110 H-Bridge chip. This allows us to drive a 500mA DC motor in both direction and we regulate speed with PWM duty. We need to return to speed adjustments later but we will be using the PWM signals on the ESP32 for this purpose.

This is where I went wrong on my previous version as I connected M1A and M1B to Inpu only capable ports. I discovered the error later as I tested the utility driver.

R1 & R2 is pull up’s that in this case is needed so the motor don’t accidentally start as we power up. C4 is to clip away DC motor noise.