Building our own Base Shield for an ESP32
In the field of embedded development and IoT, hardware selection and assembling processes are topics that need be taken care of. After deciding the right microcontroller for a project; compatible sensors, actuators and displays should be selected. Even finding the working library for the sensor can take some time.
Several development kits and brands ease these development processes by introducing combined solutions. Regarding the protoyping phase, thanks to the “shield” approach for several boards in the market, the compatible sensors can be directly plugged to them; no need for breadboards or jumpers.
At ThingForward, we are testing new IoT solutions in order to provide solid support to our customers’ needs, and at our developer workshops, we’ve been using NodeMCU’s ESP8266 and the Grove Connector/Shield system for quite some time now.
Additionally we’re using several boards for prototyping like NodeMCU, ESP32, STM32, MSP430 etc.. Speaking of which, we find NodeMCUs ESP32 DevKitC powerful because of its rich peripheral set, WiFi module, Bluetooth radio solutions by SoC and its affordable price.
The only problem was that there were no shields produced for this development board. This is the motivation that led us to start with our own hardware from scratch. Todays topic is producing our first piece of development hardware and how we did it. With our shield, it is possible to plug your Grove Sensors directly by using digital, analog and I2C ports. It also allows you to use 9 ports at the same time; in other words, there are no shared input/outputs between different connectors.
Here it is, ThingForward's Grove-compatible base shield for NodeMCU ESP32 DevKitC :)
Image 1: NodeMCU ESP32 DevKitC Shield
Let's analyse the production process. The overview looks like this:
- Designing schematic file
- Generating the board file
- Arranging the components
- Routing the board
- Adding silkscreen and copper pours
- Checking errors
- Generating the Gerber files
- Finding a PCB producer
The first step was designing the PCB schematic. There are several tools to design circuits and make them producible. We used the most significant one, Eagle from Autodesk. One definitely needs knowledge about electronics and circuit design, but Eagle can do many things automatically. Especially for our shield which only consist of connectors and passive elements.
Please remember that the shield only routes the bus to the new connectors. Here is the result of designing schematic:
Image 2: Shield Schematic
Here we selected what we need; LEDs, resistors, connectors and headers. After that, the ports are renamed according to its originals. The next step was generating board file by using the schematic:
Image 3: Shield Board
That needs a little bit of arrangement. The yellow lines represent the connections that need to be done by the user. After a little touch up with text editing, drawing and replacing, the design looks like this:
Image 4: Shield Board Design
Now we can give our shield some functionality, routing the board with bus connections. By clicking on green points, the connections can be drawn. We used red lines to show top layer bus:
Image 5: Shield Board Design - Top Layer
On this design, we used two-layered PCB. The blue lines on the image below show the bottom layer bus:
Image 6: Shield Board Design - Bottom Layer
Take Home Notes (1): Auto-Router feature of Eagle, give it a chance :)
Connections are done, drilling holes are arranged, more fancy texting a.k.a silkscreen applied and copper pours are added. Everything's together:
Image 7: Shield Board Design - Top and Bottom Layer
It looks ready now. Eagle provides us several tests for error checking:
Image 8: Shield Test Tools
The first one is ERC, which stands for "Electrical Rule Check". With ERC, the electrical errors can be checked on schematic as pin names, missing junctions and bus overlapping. The second and the most important one is DRC, "Design Rule Check". According to current set of design rules, this tools examines your board and lets you know whether it's producible. This set of rules can be given as an input file or you can use the default values. These errors can be traced via pop-up warnings/errors windows. Please remember that the results of these tests should be faultless.
Just one step before producing our PCB, the Gerber files should be generated. Gerber files are the common and universal language of PCB schematics. Every single Gerber file shows the layers of the PCB and gives the right information to the PCB producers.
After generating Gerber files, it is time to find PCB producer. We ordered our PCBs from EuroCircuits and we're pretty happy about the results. They're located in Germany and the shipment process only takes 1-2 days after the production is finished.
Let's look at our very first production:
Image 9: PCB v1
You can be sure that the text looks alright on Eagle file, but the result after production look quite different.
Take Home Notes 2: Even though current PCB producers also accept your Eagle files to produce it, it's always recommended to generate your own Gerber files. This is also a good method to control whether everything looks alright. (i.e. Text problem on ThingForward badge and its frame.)
Here is the second version of the PCB we ordered:
Image 10: PCB v2
This PCB is called "naked proto" by EuroCircuits. This is good as a first validation of dimensions, pin locations etc. But there is no solder-stopping coating on these PCBs and soldering the small parts are really hard!
Take Home Notes 3: Keep in mind, naked proto PCB's are good for a first check, but hard-to-solder PCB's.
Lessons learned, here is the final design:
It's time to solder the parts:
Image 12: PCB Soldering
After soldering the DIP connectors, pinheads, LED and the resistor, here is the example project with BME280 sensor and an LED:
Image 13: ESP32 Shield with BME280 and LED
Here is the console output of a first test:
$ pio device monitor --- Miniterm on /dev/cu.SLAB_USBtoUART 9600,8,N,1 --- --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- Temp: 25.34C Pressure: 99675.00Pa Altitude: 138.26m Humidity: 34%
To sum up, it was a fun adventure for us to design and produce a shield for one of the MCUs we're using. The advantage of designing open source hardware is that you can find everything easily online.
Take Home Notes 4: If you can't find it, try to produce it :)
We're looking forward to using this Base Shield and the ESP32 as the new standard development board for our workshops!
Your ThingForward Crew
- Design files emirez/iot-pcb-nodemcu-grove-shield
- Supplement 1: https://learn.sparkfun.com/tutorials/using-eagle-board-layout
- Supplement 2: https://dl.espressif.com/dl/schematics/ESP32-Core-Board-V2_sch.pdf