Oh boy! One more edition of Pixels Camp!
The hype was unreal. My preparation for Pixels Camp stared way earlier, in September. This year I wanted to bring something new and different. Since I’m no good with API’s and web projects, I decided to make something that I’m good at, and that is hardware!
After some time of brainstorming I settled on an web controlled LED matrix, like one of those “scrolling text displays”. Why a LED matrix? Because I never did one before, “electronics bucket list” kind of deal. Next time I’ll make a real badge, OK?
The following months I spent my spare time designing the circuit and the PCB for the Pixels Camp Badge. These were the features I wanted to include in the badge:
- Lots of 0603 LEDs (351, 39x9)
- Wifi enabled with an ESP32
- USB or battery powered (with battery charging)
- Small-ish form factor (small enough to be considered a badge)
I started the design process with the matrix. This was pretty straightforward, just a simple XY matrix: Lots of LED’s there, thank god for Altium’s advanced paste patterns!
Next the layout: It was at this time that the badge size and shape was defined. Also saw that I would need to make a separate board for the microcontroller and the rest of the electronics. So the final badge would be a “PCB sandwich” connected by 2.54mm headers.
That was the easy part, next i started designing the schematic. These were the main design challenges:
- Charging and power switching circuit
- Usb to serial and sketch upload circuit
- LED driver connections
And here’s how I solved them:
The main goal of this circuit is to switch the power source between USB and battery. I will separate this into two parts, charging and switching.
We need to be able to switch between USB (5V) and battery (3.xV), in a way such that when there’s USB power present, the main circuit is powered by USB and the battery is getting charged using power from USB. This is the circuit I came up with: Vbus: USB power. Vbat: Battery power When VBus is connected there’s a small voltage drop on the schottky diode, this voltage polarizes the P-Channel MOSFET (T1) and disconnects the battery from the rest of the circuit. When VBus is not present the MOSFET gate gets GND from R5 and switches on.
There’s also a main power switch that turns the rest of the circuit off. In this case, a switch controls another P-Channel MOSFET (T2).
An LTSpice simulation of this circuit can be found in the repo folder “Simulations”.
The charging is done with a common lipo charging IC, in this case, the MCP73831T. You can find more details of the charging circuit on the datasheet.
There are also 2 LEDs on the back of the main board showing the power and charge state.
How pretty :)
Why an ESP32? Because I wanted a beefy micro that could be able to run a web server while driving the LED matrix. And no doubts that the ESP32 can do this easily. Here are some of the ESP32’s specs:
- Dualcore 32-bit Xtensa microprocessor
- Low power co-processor
- Wi-Fi 802.11 b/g/n
- Bluetooth v4.2 BR/EDR e BLE
- 2x I2C interfaces
- 2x I2S interfaces
- CAN Bus 2.0 support
Everything in this nice package with a built-in PCB antenna: The ESP schematic part is preety straight-forward: I also added a resistor voltage divider in order to measure the battery voltage using one the ESP’s analog inputs.
In order to communicate with the ESP32 via USB, an USB to Serial driver IC is needed. I chose the CH340G as it’s commonly used for this and it’s very cheap. It seems that it has some driver compatibility issues with some windows versions, and maybe in the next version I’ll replace this with an CP2102.
There are some aspects to keep in mind when designing this circuit. First, don’t forget to swap RX and TX, second, don’t forget to add the required crystal oscillator to the circuit (I totally didn’t forget about these last two) , and last, the upload circuit.
The upload circuit is important because the ESP32 can only be programmed if the GPIO0 is tied LOW at power up (or reset). The CH340G can do this automatically with the DTR and RST pins, we only need a simple BJT circuit to drive the pins.
I needed an LED driver that could handle all of these LEDs, I settled on a IS31FL3741, similar to the IS31FL3731 used on these Adafruit LED matrices. This driver IC communicates with the ESP32 via I2C. I2C is not the fastest communication protocol out there, but 1Mhz shoub be more fast enough for this application.
I’ll have to admit that the IS31FL3741’s datasheet is not the best, and that was the cause of some problems and design flaws. Hopefully, ISSI provided a free development board for the LED driver. The development board played a very important role on the debugging process. All about that will be covered in the next blog post.
For the driver schematic I mostly followed the example on ISSIs datasheet:
I also added some extra connections for additional interfacing. Like, push buttons: Push buttons with pullup resistors As well as a dedicated reset push button: And some indicator LEDs: The web part is there because I also wanted an excuse to learn a bit of web development. The point was to add a web interface where a user could type in a message to be displayed on the matrix. The interface between the web server and the firmware is not quite there yet but it would look something like this: I can hear KillMaster in the distance arguing that Bootstrap sucks, but hey! It’s easy enough for me to learn! And it runs surprisingly smooth on the ESP32.
Unfortunately this part is still not complete, mostly due to time. I was able to host the web server on the ESP32, but I wasn’t able to access the web server data on the main program thread. Furthermore, testing the WIFI part on Pixels Camp wouldn’t be an easy task due to Pixels’s forever overloaded WIFI.
In the next blog post I’ll be covering the rest of the PCB design, manufacturing processes and more! Don’t miss it!
In the meantime, you can check the project’s Github repo for all the files, schematics and additional information.