PCB design for a ESP32 coffee Roaster board

While I am working on my prototype ESP32 coffee roaster controller to upgrade from my Arduino UNO R3 version, thought I would take a stab at PCB design using KiCad. There does not seem to be any controller out there that does quite what I want. Seems like making custom boards is a lot easier than it used to be. There is no cost involved to actually design it except for I did pay $13 for a Udemy course: https://www.udemy.com/course/kicad-like-a-pro-3e

The nice thing I can see about this is having all the pins in one place the thermocouple(s) and the wiring will be a lot cleaner. Actually, I guess I can put socket(s) on the board for them. I could also put all the pins for a TFT display in one place and of course have 2 sockets for stepper drivers and socket for ESP32. I probably could not plug the TFT display directly into a socket on the board since it has so much overhang and TMC2209 driver would be in the way. Probably also have 1 or 2 limit switch connections.

I plan to initially draw just the draw then build up from there.

  • ESP32 DevKit

  • USB connector

  • power input

  • LED

Any thoughts on this idea.

That’s a good first project, for sure. It’s always easiest to get started with stuff where you can basically pull segments of circuits from other dev boards or the eval kits for the chips, etc.

I think you might mean headers instead of sockets? :slight_smile: Usually we’d have pin headers on the PCB and in-line sockets on the cables.

For prototyping, I’m a huge fan of using the 3.81mm pluggable screw terminals. I sang that song for many years and now the latest Jackpot has them on and people seem to like them, which is nice.

For the thermocouple, make sure you put the amp chip near the connections as it’ll have internal cold junction compensation so it’s best to try to have the plug at the same temperature as the chip.

For layout, try to keep everything on the top layer and use the bottom as only a 0V plane if you can. Try to avoid routing any traces around the edge of the board. I’d stick with making all the signal traces as 0.2mm or 0.25mm and keep the clearance as the same as your smallest trace. If you’ve got the option for a clearance from polygons/planes, I’d make that 0.05mm wider than your minimum clearance.

If you do need to drop down onto the bottom layer, keep it as short as possible. It’s often better to have 3 separate top-to-bottom-to-top transitions to skip traces than one long trace on the bottom that cuts your 0V plane in half.

Also don’t think of the process as going Idea → Schematic → Layout, you’re better off bouncing around between all of those. I often get halfway through a layout and then redo parts of the schematic to make the layout cleaner, unwrap crossing traces, consolidate multipart components differently etc.

Thanks for your comments and correcting me on the terminology. I am sure there is a lot of terminology I will not word correctly. The only board I have had made was a design by someone else on here for of a 2-stepper driver board with an Arduino Nano for a laser engraver with all thru hole components.

After looking at the Jackpot controller, looks like I can use surface mount TMC2226 drivers and keep the profile of the board a lot lower than with the TMC2209 standalone drivers I am now using.

In perusing some designs I came across the cup coaster design which seems like an interesting way to make a coffee coaster from a PCB board and is in full color. Here is the video on how he created it.

These are the parts I am currently designing for.

  • 38-pin ESP32 board rather than surface mount

    seems like there is no standard pin width on these boards. I will probably design around the one I have shown below unless there are better suggestions.

  • Two stepper drivers TMC2226 surface mount

    probably the 3.81mm pluggable screw terminals like @jono035 recommended

  • Two MAX6675 modules

  • SPI TFT display

    use jumper wires rather than plugin directly as I can see that not working well the 1st time.

  • At least 2 buttons.

  • Buzzer

  • Status LED

  • Maybe what is needed for SSR later

  • Two end stops (my sliding roaster design if it works uses 1 end stop)

    I do not need these for the flour sifter coffee roaster though

Here is my prototype setup. If this prototype works well, I might not even have a board made. I will still work on designing one though. The ESP32 development board I bought from: Amazon.com: DIYables ESP32 ESP-WROOM-32 WiFi and Bluetooth Development Board, 38-Pin, with USB Type-C and CP2102, Dual-Core ESP32 Microcontroller for IoT Projects, Compatible with Arduino IDE : Industrial & Scientific

No worries, hope you don’t mind the corrections, it’ll just help a lot if you’re trying to find components in libraries, etc.

There are a few versions of the ESP32 dev boards out there but as long as they’re the right number of pins, I haven’t found them to differ. The pin arrangement will be on 0.1" centers and there may already even be components in a library somewhere to land one.

Most SSRs are isolated input and can be triggered from relatively low voltages so there are options here. Personally, I’d make it an open-drain output and then you can run it from whatever voltage you like.

For reliability, I’d also recommend using a 12V to 5V step-down point-of-load module for running the ESP32. Their on-board regulators are ‘ok’ at 12V but stay cooler and more reliable at 5V. Something like an XP Power RBT05W25S05 is what I’ve used in the past.

I made a lot of progress on my prototype. I now have all the new hardware working with the ESP32 except I still need to add 2 buttons, a buzzer and LED but they should be fairly easy. The TFT took a half day to get to work and would not have gotten it to work without ChatGPT helping me. It is an ILI9488 driver, and I had to get the Arduino library for it from here: 3.5inch SPI Module ILI9488 SKU:MSP3520 - LCD wiki but then had to modify it a little so it worked with ESP32

I am currently using these pins but will need to use 4 more for the 2 buttons, buzzer and LED status.

5 TFT CS Output
16 TFT reset Output
17 TFT DC/RS Output
18 TFT SCK Output
19 TFT MISO Input
23 TFT MOSI Output
21 MAX6675 CS Output
32 MAX6675 SCK Output
33 MAX6675 SO Input
25 Stepper DIR Output
26 Stepper STEP Output
27 Stepper ENABLE Output

I will probably use 4, 13, 14 and 22 for the buttons, buzzer and LED as ChatGPT tells me I will need a pull-up resistor to use 34, 35

Here is a photo of test setup.

I am starting to really like the possibilities with this ESP32. The TFT display has a built in SD card reader and I may only need 1 extra pin for CS if it shares the other pins internally. If not, I should still be able to get it to work with more pins. With that I can get the current date/time from Wi-Fi connection then disconnect that and use a time date stamp for saving roast temperature data to the SD Card. I could also use a webpage interface initially to enter what kind of roast or origin of coffee I am using to have that as part of the file name saved with the temperature data. I am also finding the USB plug I added to my Ryobi portable PS quite nice for keeping everything portable except for of course the 1800-watt heat gun.

Make sure you don’t accidentally double up on the reset pin… Ask me how I know.

Don’t ask him! Make him beg to humiliate himself… :laughing:

Will that give me a nice puff of smoke that is reminiscent of when green coffee beans get to a dark roast heat level? I think the last time I saw smoke with electronics was when I did something wrong on an old Ramps board. I am sure I have come close to doing that since then, but maybe the electronics boards are better protected than back then.

Nothing quite so interesting. I was trying to use it as an output by accident. Nothing really happened until I set the pin high then low again… then the esp32 rebooted.

I was working on getting the SD card reader to work and after some research I found a page that mentioned the MISO connection for the SD card reader was not wired in. Looking at mine, looks like the same problem. I am just not sure how to connect it, which pad to connect it to or whether I need a resistor in that also like the other 3 connections have. Seems like a short jumper wire soldered to the right pad would do it, but probably with a resistor in that jumper since the other 3 connections have that. Here is a photo of it. You can clearly see the SD_MISO does not have a lead off of it unless it is another layer of the board. Any suggestions?

Here is discussion on that missing connection. It is the last message in this thread.

SD card Configuration · Bodmer/TFT_eSPI · Discussion #2717 · GitHub

I found another thread on this SD and TFT problem. I probably still need to solder the jumper wire, but also in the code the SD card needs to be initialized 1st then wait 500ms then initialize the TFT as per the last comment in this thread.

ESP32-WROOM-32D, 2.4" TFT, SD Card not working - Other Hardware / Storage - Arduino Forum

I think this is the pad with the black line I have drawn to it is the one I need to solder the MISO jumper to, but I am not certain.

What a weird issue…

If you hold the board up to the light you can sometimes see if there are traces on the underside. Do you have a multimeter? If so, you can use the continuity check function to test between the pad you’re expecting MISO to be connected to and the SD_MISO through-hole. If you don’t have a multimeter, this is a great excuse to get one! I’m a big proponent of starting with at least one ‘good’ multimeter and then adding cheaper ones later. If you’ve got one piece of test equipment, it pays for it to be extremely trustworthy…

I quite like using wire-wrap wire for making jumpers like that. It’s 28-30AWG solid core wire with a very thin sheath. It’s easy to strip either using a dedicated wire wrap stripping tool or just by rolling it along the edge of a knife and then it being solid core it bends and holds into shape really nicely. I usually bend it into a shape where the stripped ends ‘stand up’ on their own, use the solder iron and solder to add a blob to each end and then place it. Add a bit of fresh solder to the joint on the board then introduce the wire wrap wire, trying to keep it hot for as little time as possible. The sheath will retract a little as it gets hot, so I tend to strip a little less than I need and assume it’ll uncover more as you solder. Then bend it into shape with pliers or tweezers and tack the other end in place. For ending at through-holes like that, you can also strip a little bit longer and put it fully through the hole and bend it over on the far side, that’ll hold it in place for long enough to solder a header or another wire in, as well, or solder the header/wire first and then tack the wire-wrap wire. If you want it to last a bit longer, some tape over the top keeps it from moving, or blob some hot-glue. NEVER USE SUPERGLUE, it fumes and leaves a non-conductive film on things.

I wouldn’t personally worry too much about that resistor but if you do want to add one, I’d tack one side to the SD card socket pad and then wire-wrap as above off the far side of the resistor.

The socket pins follow the pinout of the SD card itself, with the exception of the card-detect contacts. So I’d look at that socket and assume that the 9 pins on the left are the SD card pins and the card-detect pins are on the right, next to the bit that looks like the contact for them.

The pinout for the SD card in SPI mode is:

  1. nCS
  2. DI (data in)
  3. VSS1
  4. VDD
  5. SCLK
  6. VSS2
  7. DO (data out)
  8. N/C
  9. N/C

But the pinout is actually 9 as the offset pin on the left then 1 through 8, so

So checking that board against that, from left to right:
Pin 9 is N/C so that looks right.
Pin 1 goes to SD_CS, that looks right.
Pin 2 looks right, Data In comes from MOSI
Pin 3 appears to connect to the reference plane, which is usual for a VSS (0V) pin.
Pin 4 is Vdd but I can’t see any traces. I assume it might come from something on the other side?
Pin 5 goes to SD_SCK, that looks right
Pin 6 goes to the reference plane, correct for VSS
Pin 7 is the one you’ve highlighted and lines up with Data Out, so that should connect to SD_MISO.
Pin 8 is N/C.

So yeah, looks like you need to connect that black highlighted pin to SD_MISO and then I’d also check and see if there is 3.3V going to pin 4 at all.

On a related note, that PCB is … not great. At the very least, more vias and it should absolutely have a separate 0V return connection near those SD card lines. The ‘ideal’ scenario is using something like a ribbon cable with the fast signals interleaved between 0V or slow signals.

I got the multimeter out and checked continuity between the MISO from the 4-pin header and went through the pads on the SD card and it is connected to that 7th pad. Yesterday I had checked that between the SD_MISO and TFT MISO but not to the SD pad. I was able to get the SD card to work but even initializing the SD 1st before TFT and various other scenarios, I could not get them both to work together. The combination of this particular LCDWIKI library, this TFT board, and the ESP32 SPI implementation is not cooperating. After playing with this prototype, think I want a touch screen anyway, so if I just wanted to use the TFT of this display without the SD it should work ok.

Anyone have suggestions for a reliable 3.5” or 4” touch screen to work with ESP32 and one with a better driver than an ILI9488 driver? I probably want to go to 4”. If I am only going to build a prototype 1 off and not make a PCB, one with a built in ESP32 on it might be ok if it has enough connections for the TMC2209, MAX6675, buttons, buzzer and LED (May not need this).

This is one I was considering if it is a ST7796S Driver and not an ILI9488.

Amazon.com: Hosyond 4.0 Inch 320x480 TN Capacitive Touch Screen LCD Display Module SPI Serial ST7796S Driver for Arduino R3/Mega2560/ESP32 : Electronics

[Edit] I was able to get the SD card and TFT screen to work together after all. ChatGPT had to patch the library: LCDWIKI_SPI. It also seems noticably faster writing to the screen.

I created my 1st simple PCB design in KiCad using that udemy toutoral and am at least ready to begin my custom PCB design. I am planning to use a real ESP32-S3-DevKitC-1-N8R8 Development Board on a socket on the custom PCB. I could not find this in the parts library, but did find this one: https://www.snapeda.com/parts/ESP32-S3-DEVKITC-1-N8R8/Espressif%20Systems/view-part/

Is this a good resource for that part? I did not create an account for this site yet.

Here is an image of the PCB design I did from that tutorial. It is called an LED Torch. Push the button and the LED lights up. Obviously a very simple board. i still have a lot to learn about KiCad and PCB design

Here is my current wiring for my coffee roaster using the breakout board for the current 38 pin ESP32 that I have. I am going to the 44-pin board as it will give me more breathing room for pins and think I will not have enough with the 38-pin board if I add touch screen, another thermocouple, another stepper driver and at least 1 limit switch. The wiring below is currently all I am using for my roaster design at the moment.

I’ve looked at SnapEDA in the past and it has been fine. I’d double check everything you’re planning on using.

For some things that are critical, size-wise, it’s a good idea to get them ahead of time and then print out a 1:1 scale of the PCB to check them against. That’s a good way to spot silly issues like using the wrong pitch or wrong row spacing etc.

Moving forward from the example PCB, I would start by allowing yourself plenty of room on the board and having things spaced out a bit for breathing room. You can always shrink it down later, it’s harder to expand things.

Keep the bottom layer for a 0V reference plane/return path as much as possible. Try to avoid long traces in it, especially when they run under traces on the top layer.

Start by trying to get everything placed in a way that makes sense. You’ll see the lines indicating which pins connect to what, spend time trying to make those make as much sense as possible. You don’t want to have 10 wires going to one thing have to cross 10 wires going to something else if they can help it. Put the effort in at this stage to move pins around, change the positions of components, rotate stuff so it makes sense, etc. Examples would be that the LCD can be rotated 180 degrees while keeping the same orientation, plugs that go off to wires can be pretty much anywhere on the edge of the board but buttons will need to be in a relatively logical location for your UI/UX consideration. Use the flexibility of things that can be flexible, for instance.

More pins is good, but I’d also say that it pays huge dividends to try to avoid feature creep as much as possible. It may feel good to try make a board that can do everything you’ll ever want to do, but you’ll pay for that in design time, complexity, troubleshooting effort and wasted money if you have to have it remade. Instead, I prefer to just make sure I can connect to any spare pins in some relatively easy way, so I can add some hand wired sections if I need to. In your case with an ESP devkit, you can easily tack wires to the solder joints for the pin headers or even add another interposer board in between yours and the ESP32, so I would be confident you can easily add stuff later without needing to design it in now.

For SMT components, I’d recommend at least 0805, potentially even 1206 if you’re not confident with SMT soldering. Having a good temperature controlled iron with a good quality tip helps. Some thin solder wick, flux paste in a syringe, thin solder and some isopropyl alcohol and swabs for cleaning up afterwards make life easy. Also a good set of tweezers, ideally ones that don’t go to a point but to a ~0.25mm flat or something. Consider how you might add some magnification, too. In an ideal world I assume you’ll get the board assembled by someone like JLC PCB and it’ll all work first try. In reality, be ready to have to replace components due to them being backwards, upside down, needing to lift legs and solder jumper wires onto things, change components values etc.

I’d also avoid anything smaller than a SOD-123, SOT-23, SOIC or similar for discrete components. Avoid no-lead packages if you can (like QFNs, CSNs, etc.). Avoid fine-pitch TQFP and TSSOP packages where possible, too. Unless you’ve worked with them before, they can be frustrating without decent tools and experience.

It’s also a good idea to put a series resistor in line with every single connection you make between ICs. Not only does that give you a way to route wires underneath without changing layers, it can be useful to limit current in the event of an incorrect connection and to slow down the logic transitions, which will make it less likely that they interfere with other signals on the board, etc.

Make sure every single power pin has a dedicated 100nF or 1uF decoupling capacitor, something like a 25V X7R is fine. When you do the placement, place this so that they’re close to the power pins and keep them there. Power traces should be routed into the pad of the decoupling capacitor first and then into the chip. The 0V side of the decoupling cap should be taken out sideways from the pad and go to a via to 0V as close as possible. Better is use one on either side, etc.

That’s a bunch of random thoughts to get started. If you have a read through anything I’ve written on the Jackpot posts there should be some similar PCB design related information there, too.

Glad to see someone else giving this a shot. I’m just going through the process of bringing up a 1000V/50A high frequency inverter design at work for a 20kW wireless charging system. So far it’s going well, we’ve reached 50% rated power with zero issues, so that’s fun.

Back To The Future Great Scott GIF by PeacockTV - Find & Share on GIPHY

Are you setting up wireless car charging like the rest of us do charging our phones?!

Sadly, no. In the past I worked on wireless charging for golf carts, then EVs, then in-road systems for charging while driving, then 75kW modules for electric trucks that can be combined to do 450kW and beyond.

Now this is for a much less exciting industrial/materials handling application.

It has been a fun ride along the way, though. Got to work on some cool stuff like the Rolls Royce Phantom EV, the Drayson Racing electric LMP1 car (Edit: Oh, yeah, that’s the car in my profile pic!), worked with a few companies on vehicles that never really saw the light of day, as well. Got to design stuff that was eventually adapted for the medical and safety cars for the Formula E.

In fact, if you go to the BMW museum in Munich and look under the Rolls Royce Phantom prototype, it still has the wireless charging system that was designed by 4 of us in New Zealand and hand built mostly by me and another guy. Last I heard, the 3x on-board chargers they used slowly died one after another and in the end the only way to charge it was the wireless system which never failed once.

That is honestly really interesting - thanks for the aside. I have always had a fascination with induction and how they are getting more and more efficient and working on those cars must have been a blast. I am now working in the automotive materials space (business side now, much more boring), but it’s in Detroit which seems like 15 years behind the rest of the world. No wonder we can’t allow imports, there is no way Motown would compete right now - going YOLO at the beginning of the decade chancing high-end profits in the EV space and then abandoning all investment instead of pivoting to match. Sad really.

If you ever want to slap one of your induction machines on the bottom of my EV you’re invited to my garage any day! :grinning_face_with_smiling_eyes: