NFC Gadget with E-paper Display

What is it?
This is a final project I did for EE256 Board Level Design! I got inspired from a youtube video that made a NFC key fob emulator and decided I should make one for myself.
I have some experience designing a pcb before, and a lot of experience using arduino, circuitpython etc. so I figure I should go a little bigger this time, that’s why I chose to not go with circuitpython/arduino route and go direct to STM32 toolchain this time. (My first project was like Lab3, routed the wire to fit for a different form factor, and my second project is a n+1 redundant lipo power supply board which requires no programming. )
I figured that with the help of the open sourced youtube video and datasheet, this should be a quite manageable project. But it turned out to be quite a steep learning curve. Nevertheless, I’m glad that I did this project, and now I’m very familiar with this (seems to be one of the most popular) embedded development workflow. I plan to do a high voltage bldc motor controller project next, so this is also a great preliminary project to light up the technology tree.
Scope of the project
In my planning, it should be able to:
- Measure the temperature with onboard DS18B20Z sensor (to fulfill the 2 sensor requirement)
- Accept some basic user input through a button (to fulfill the 2 sensor requirement in case something failed)
- Measure the UV intensity through an I2C module LTR390UV (to fulfill the 2 sensor requirement)
- Have I2C port for expandability
- Able to display QR code, nice pictures, or whatever through the E-paper display (no energy consumption when not refreshing) [uses SPI connection]
- Able to transmit data through UART to computer (also helps debugging).
- Powered by a 3V coin cell battery and should last all year.
- You can tap the gadget to get a custom URL read on any Android or iOS phone.
- Able to emulate NFC cards through UID.
- Nimble and should fit inside a pocket easily.
Details
Schematics and routing
With it all planned out, we started by putting down all the reference designs. We used the V2 design in the E-paper datasheet, and the reference design provided in ST25DV64KC datasheet. The power supply I uses TPS61221DCK reference design. As for the rest of the signals, and buttons, they are pretty straight forward. The finished schematic looks like this:
Looking good! The outline size limit of our final project is 99x99mm, but I want it to be as small as it gets. So after some tweaking, I think 43x60mm is the best I can do I fit all the components on board. (Which also makes it very hard to route…) All the courtyards are packed without any extra space together, I also picked the smallest footprint of ST25DV ic to save space.(which turns out to be a very bad idea). I think I’m pushing it as much as I can.
Breadboard verification
Since there are quite a lot of places that can go wrong, we decided to verify it with breadboard first before send it out. So we bought the mcu, QFP adapter board and all the hardwares online. We were able to catch several bugs during the test. With a working circuit, we are also able to get a head start in writing the code, since the timeline is going to be pretty tight toward the end of the quarter. It turned out to to be super useful.
Bring up and debug
And the board came! I soldered the front side with lab paste (which is already dried out) and it weren’t that good. I had to scrape for the residues and rework the st25dv chip. And for the backside I used my own low temperature paste with a hot air gun. It turned out much better.
This is the really time consuming part. Since I made some change to the design after the verification, and had to add some components to make sure I can pass the demo requirement. I initially relied heavily on chatgpt to learn all the concepts, but later in the process I was able to mostly debug myself which I’m very proud! I also had to migrate several driver libraries for all the modules used onboard to STM32L051. Debugging C code is not always the most relaxing process!
One of the issue I encountered is that MCU processes everything in a loop, meaning that if something is blocking, then everything else won’t work. This is particularly bad when the temperature read takes 800ms, as it would block the nfc process and won’t allow data to be removed from buffer in a timely manner. So I had to rewrite the wait as a time counter, check every loop if the past time has reached 800ms. This shed light on a lot of the things I never really thought of when writing code on a computer, and I find it fascinating.
I was going to add more pictures since my mcu has 64Kbytes of flash, (can fit 5 more pictures). But Keil don’t allow me to compile anything > 32Kbytes in free version. It wasn’t easy to bypass this limit (need to regenerate my code and use Clion). So I had to resort to other options (e.g. turn on/off the led with the button instead)
Also we had a lot of issue using the new ST25DV64KC chip. We read in the datasheet that no hardware modification is required between KC and K chip, but it turns out the software and registers are very different. After a few days of debugging and trying to modify the code, we decided to just get the K version instead.
Finally after 70+ hours of work and uphill battle, I got it to work!
Some final touches
At this point I’m pretty much just relaxing and doing it for fun. So I made an enclosure to make it look more “complete”, and also did a quick rendering in Blender (cause who doesn’t like nice pictures).
What would I do differently
- I would definitely stick with ST25DV64K, instead of the new KC chip. It’s much newer but there is not nearly enough discussions online to help me debug effectively.
- I would also double check the pinout against the standard definitions before send to the fab. My stemma qt connector has the SCL and SDA pins swapped (because I was looking at the STEMMA definition) and I didn’t find out until a day after trying to figure out why my i2c is not working. My display fpc connector is also drawn backward and I had to buy another extension cable to flip it around. (Turns out the reference design in the datasheet have pins connected from the top instead from the board side.)
- I would also check the i2c address of each module I plan to use before I send the board. I realize later that LTR390UV have the same exact I2C address as ST25DV and neither of them is capable of changing the address. Unfortunately I don’t have the i2c2 pulled out from mcu so I have to give up the LTR390UV module.
- I would also use genuine, high quality components. I’m lucky that I got THE good one from 3 knock off DS18B20Z I ordered. But my lab mate tried the other two and the best one he got only works for temperature > 27C (80F)
- I would put more test pads on the board, especially pull out every pin from the mcu so that later when something doesn’t work, I can always switch to another one.
- I would 100% use bigger version of the QFN pads instead of the smaller one to save space. It’s soooo hard to solder, with the smaller one, paste don’t want to enter the stencil, and I can’t even check it with microscope…
- I actually like 0 ohm resistor better than scratch pads. Much easier to remove, so I might use that more later.
- Bigger buttons….
- I would probably try Clion next time instead of Keil (given the annoying 32Kbytes constraint)
What’s next?
As I mentioned earlier, my next project is going to be driving a high voltage bldc motor. Specifically I bought an awesome little (fancy) hair dryer motor that supposedly spins up to 100k rpm under 110V DC with minimal noise. All for $6. It would be very handy thing if I can drive it to it’s full power 150W.
I looked around, there is not much ic on the market that support output voltage > 110V, so it’s really pushing the envelope. I found one on ST website STSPIN32F0252 that works up to 250V. As the name suggests, it’s a SiP that has a built in STM32F0 and a motor controller, which is very convenient since I just learned all about programming the ST chips! So I’m pretty excited about this project!
Apart from that I’m also very interested in making my own mini linux computer. But it looks way beyond my scope right now and I would consider it again sometime in the future.
Github
If you are interested to make one yourself, or improve it, schematics, pcb and firmware will be posted below as soon as I got the ownership of my repo from course staff!