Fab Academy portfolio Sara Kutkova

Final Project - Oracle

I am not religious, and I don’t really believe in higher power, but I believe in placebo effect. Sometimes when I’m down, I would like to receive a divine advice, some sort of encouragement to find inner strength, even though it’s made up.

   

Therefore, in this project, I will make an Oracle -> a device that will give you your personalized advice, maybe based on the religious texts. You can imagine it as Chinese fortune cookies, but more personal.

Mood board

I like the “biblically accurate angels” posts. There are many different types of angels mentioned in the bible.

Source of image

I think the cutest of them all are the seraphim’s and thrones! They have many eyes to see everything (and are allegedly most powerful), so those are great angels to receive the Oracle from.

I then browsed the internet for some inspiration, and made a mood board.

(Sources of the images (from top right corner) here, here, here, here and here)

Based on that, I made my sketch:

How will it work from user perspective (simplified)

  1. register online, and fill up a form with your basic information
  2. add your fingerprint to the database
  3. once a day, you will be able to receive a “prophecy” from a great oracle
  4. you come to the oracle, scan the finger and get a small paper with divine advice

How will it work behind the scenes

Diagram:

Sizes:

Components:

Project plan

Testing the thermal printer

I started to test the thermal printer. It is the Adafruit Mini Thermal Receipt printer.

The documentation page about this printer says that when you connect it to power, and long press the button, it will by default print a test page.

So I used the power supply, and set it up according to the printers datasheet (5-9V and more than 1.5A). However, when I long pressed, the printer moved the paper, but haven’t printed anything. Suspicious!

I tried both sides of the paper, different sizes but nothing worked. So I moved on and tried to use the recommended library, and some example code from it.

Nothing was printing! I even used my arch nemesis oscilloscope to see if the UART works as intended, to see if we are really sending the data from the XIAO to the printer.

Finally, I remembered that in the UART, the receiver pin (RX) and transmitter pin (TX) should be connected not to each other (like ground to ground) but rather the TX from the microcontroller to RX from the printer and the RX from microcontroller to TX of the printer. I remember making this mistake in the past, hope I will learn now.

At last, the printer is now working! I can more to the next step.

Files

Arduino code for testing printer [.ino file]

Testing the fingerprint sensor

The Capacitive Fingerprint Sensor I am using is from DF robot. It can store up to 80 fingerprints, and it can detect it from any angle.

As its visible on the picture below, the cables coming from the sensor had just wire ending. I didn’t want to solder them directly, so before starting to work with the sensor, I wanted to make nice connectors at the end of those cables.

So I used the dupont connector kit with crimping tool.

   

Kris made a nice video explaining how to make these. In short: Cut bit of the cable isolation, crimp the first “wings” around is isolation (picture on the left below), and then crimp the second and third wings (one after another) around the bare wires (picture on the right below). Before I crimp the wings it’s nice to get them closer together with piles. We used the 1.6 mm dent on the crimping tool.

   

Then you carefully insert the metal part into the bigger plastic hole of the component. As you are inserting the metal part, the plastic sprint will lift. You will hear a little “pop” and see the metal square fit nicely in the hole on the side.

After the connectors were done, it was time to test the fingerprint sensor. I will be using the XIOAO ESP32C3 with it.

The DF robot has quite nice sensor documentation on their wiki, and also an Arduino compatible library on Git - you have to download it, and put it into the Arduino library folder by yourself. There is some sample code and nice diagram of the sensor and its cables in the DF wiki (image below).

Source of the image

At the bottom of the Git READme it shows the compatibility of this sensor with microcontrollers - there is not RP2040 chip, so I’ll rather use the ESP.

So I connected it according to diagram, compiled and uploaded the example code… And nothing happened.

I saw a video and pictures of someone using the fingerprint sensor, and it seems like there is an LED that is supposed to light up. It did not, and so I (as a weakling) gave up – but turns out that the LED should not be on by default. Then Kris helped me get this working.

Debugging session ft. Kris

As it was advised in the sensor wiki, we started by switching from software serial to hardware serial. What exactly is the difference? I asked the chat GPT:

Software serial and hardware serial refer to methods of serial communication in microcontrollers.

Hardware serial uses dedicated hardware (such as UART peripherals) to handle serial communication, providing reliable, high-speed data transfer with less CPU overhead. This method is typically more robust and efficient.

Software serial, on the other hand, emulates serial communication using software, allowing additional serial ports on pins not dedicated to hardware UART. While it offers flexibility, it can be less reliable and slower, as it relies on the CPU to handle timing and data transmission.

In practice, it meant that we used this:

#include <HardwareSerial.h>

HardwareSerial FPSerial(0);
FPSerial.begin(57600, SERIAL_8N1, -1, -1);

Instead of this:

#include <SoftwareSerial.h>

SoftwareSerial Serial1(2, 3);  //RX, TX
#define FPSerial Serial1

Throughout our debugging session the ESP32 had problems uploading the file (error shown on the image below) – the usual fix of “holding the boot button while connecting the cable" did not work out. We tried different cable, different PCB and later even different computer. It is probably true that my MacBook have this problem more often, but also the Think Pad was quite uncooperative. Later we figured out that if you also press a reset button after you connect the Xiao again, it solves this issue. We wondered whether it might be because it is already using Serial to communicate with the sensor? And by resetting there is the opportunity to upload the new code or something.

Always after we successfully uploaded the new code, we disconnected and reconnected the microcontroller, and just after then opened the serial monitor.

// THIS CODE DOES NOT WORK
// this is the original example from the DFRobot_ID809 library

#include <DFRobot_ID809.h>
#define COLLECT_NUMBER 3
#define IRQ         6  //IRQ pin 
#define FPSerial Serial1

DFRobot_ID809 fingerprint;

void setup(){
  /*Init print serial*/
  Serial.begin(9600);
  /*Init FPSerial*/
  FPSerial.begin(115200);
  /*Take FPSerial as communication serial of fingerprint module*/
  fingerprint.begin(FPSerial);
  /*Wait for Serial to open*/
  while(!Serial);
  /*Test whether the device can properly communicate with mainboard
    Return true or false
    */
  while(fingerprint.isConnected() == false){
    Serial.println("Communication with device failed, please check connection");
    /*Get error code information*/
    //desc = fingerprint.getErrorDescription();
    //Serial.println(desc);
    delay(1000);
  }
}

void loop(){ 
    // rest of code here
}

But that was not the end of our troubles. The Xiao could still not connect to the sensor - one of the cables (ground) connecting the fingerprint scanner was broken! We discovered it by checking all the connections with the multimeter.

But still no luck running the example code. However, then we tried testing for the baud rate of our sensor (different code from DF wiki). This worked, and showed us a different baud rate (for the serial connection between the Xiao and fingerprint sensor) than in the example code – 57600.

#include <DFRobot_ID809.h>

#define FPSerial Serial1
DFRobot_ID809 fingerprint;

uint32_t ID809_BPS[5] = {9600, 19200, 38400, 57600, 115200};
uint8_t i = 0;

void setup(){
  /*Init print serial port */
  Serial.begin(9600);
  /*Test module baud rate */
  FPSerial.begin(ID809_BPS[i]);
  Serial.print(".");
  while(fingerprint.begin(FPSerial) == false){
    i++;
    FPSerial.begin(ID809_BPS[i]);
    Serial.print(".");
  }
  Serial.println(" ");
}

void loop(){
  Serial.print("Module baud rate:");
  Serial.println(ID809_BPS[i-1]);
  Serial.println("-----------------------------");
  delay(1000);
}

So we tried again the original example code with the updated baud rate -> this did not work, and still said that “not connected”. Weiiird. So we used the base of the code that was supposed to just check the bout rate, and then when it connected to the sensor, we inserted the rest of the code.

What are the changes?

  • in the working example, DFRobot_ID809 fingerprint; is declared before HardwareSerial FPSerial(0);
  • in the working example we are checking for the correct baud rate in the loop
  • there is no while(fingerprint.isConnected() == false) loop. In the working example we are just not checking that.

At the end, we also added pinMode(D0, INPUT_PULLUP); to the setup function – after this, the fingerprint scanner worked as intended. Yay!!

Working example code: Arduino code for testing the fingerprint sensor [.ino file]

Note: We also added to some places delay(100); –> we thought that there might not be enough time for the microcontroller and the fingerprint sensor to connect, and it will then always fail. Not sure if helps, but it probably does not do any damage.

Integrating the printer with fingerprint sensor