Close

Fighting with NFC

A project log for E-paper instant camera

An instant camera where the "film" can be used again and again.

cameronCameron 02/09/2023 at 21:410 Comments

So after the first proof of concept with the Raspberry Pi and direct SPI connection for the screen I was fairly satisfied. At least for a few weeks. It bothered me that I needed to use a connector at all. I started to look up about wireless charging, thinking that potentially I could power the screen wirelessly and send the photo to it over bluetooth or wifi or something. This would make the device much more user friendly.

It was also clear that the Raspberry Pi was a dead end for this kind of thing. It was overkill, and made everything bigger and more complicated. I would ideally do the next version on a microcontroller.

This was around 2020, and I was checking the waveshare website to see if there were any new cool e-ink screens I could play with (I was also working a little bit on my Postcard Frame idea around this time too). And incredibly, they had just started selling wireless screens, with no battery, powered by NFC. This was everything I was looking for, already in a relatively neat product. No need for me to even print a case! Of course I bought a couple to play with straight away. That's how I began my long mission to communicate with these NFC e-paper screens with an ESP32.

https://www.waveshare.com/wiki/4.2inch_NFC-Powered_e-Paper

Unfortunately, the documentation for the screens themselves was not amazing. There was an android app (no source code available of course) to control them, but my phone can't do NFC and I wasn't going to build a phone into my camera idea. There was also a big, bulky, STM32 based demonstration board from Waveshare which could be used with it. This was also far from ideal, and the code was hard to understand, and ultimately I wanted to do this on something like an arduino or ESP (as I only knew the arduino environment at that time). So I needed to find another way to communicate with these neat NFC e-paper screens.

At first I bought a random NFC reader kit and connected it to an ESP32 to see if I could get it to read anything from the screen. Nothing at all. I knew nothing about NFC so there could have been 100 reasons, but I figured maybe I needed to use exactly the same chip as in the Waveshare demo board. Upon further research the Waveshare board seemed to be basically an X-Nucleo NFC05A1 demo board from ST, running basically the example code. I couldn't find anywhere the exact commands used for communicating with the screen itself, so emailed Waveshare directly to ask. No response at this point. But I bought the ST demo board and figured, even if I couldn't find any examples online to follow, it communicated over SPI so I should be able to get it to talk with an ESP32.

So the SPI communication turned out to be a relatively straightforward. Now I needed to communicate with the ST25R3911B NFC chip itself. Fortunately there is an amazing hardware abstraction library from ST for precisely this, but built around their STM32. As I was basically googling and reading forums to try and work out how to do this stuff, moving to a less popular ecosystem was going to hurt a lot. So I started trying to get the ST RFAL library working on an ESP32. After a much longer time than it should have taken (I am definitely not an embedded programmer), I found that the only issue preventing the code running on an ESP32 was the Interrupt calls, which could be very easily replaced in the library. I don't know if I did this properly or even did a good job, but I managed to get it running and reading the Waveshare e-paper screens.

Then of course came the question of how to talk with these e-paper screens. The demo code from Waveshare had no information on this. Luckily, in the mean time, I received a reply from Waveshare with a strange excel with the screen commands, and from that I was able to work out how to upload an image. I finally managed to take a photo with an ESP32CAM board and display it on an NFC e-paper screen, using the X-Nucleo NFC05A1 board.

Discussions