# 05-03 Implement Scanner in TS

In three hours today I replicated the entire functionality of the C++ ESP32 Bluetooth Scanner using Typescript and node. The C++ version took me 3 weeks to make. I will discuss the reasons why I made the switch and then talk about my 3D printed case.

Nodejs is so much easier. With the first project I was allocating CPU cycle time to functions and solving buffer overflows. I debated about whether a variable should be in the heap or stack. The code was compiled, linked and uploaded onto a microcontroller with 320 kB of RAM. Yesterday I entered npm init && npm install @abandonware/noble in the console and had a fully functioning Scanner at my fingertips.

This is comparable to trying to assemble a car, but the first time you decide to hand-craft the motor, drivetrain, chassis in a very small workshop with few resources and a screwdriver. Later you give up and buy a kit for a car that you assemble in a spacious workshop with a cutting edge ABB robot. You press a button and the car self-assembles.

# Why I spent 3 Weeks handcrafting a car

In the first paragraph of my contract I state: "Wie kann man selbst ein System entwickeln, welches die Position eines Objektes mit Bluetooth Low Energy Geräten ... approximiert". The way I see it, handcrafting the car is the more complete version of developing something by oneself. Buying the car almost prebuilt is not doing it oneself. Anyone can install a node package and copypasta some code from Stackoverflow. But that is not computer science and not really programming. I did not violate my contract by using noble but it feels like cheating myself. I wanted to make a car myself and I just bought a kit.

This project is a showcase of the IoT and the ESP32 is more true to the cause. It is a $4 microcontroller that can run anywhere using a insanely low amount of power. It can be embedded in other objects. The Raspberry Pi is a fully fledged computer running the same operating system as my beefy server downstairs. The Raspberry Pi costed 4 times as much money.

# Why I bought a prebuilt car

I want this project to stay on schedule and by next week I should be finished with saving results. Using C++ and the ESP32 I would have missed that internal due date by a large margin. It is important to move on and be flexible. I am pleased that my system works is orthogonal enough to not depend on the platform. The backend and BLE server do not care and do not need to know what the client device is. My system architecture works.

# 3D Printer Case Design

The Directionality of the Radio Antenna{ width=60% }

The case is supposed to reduce signal loss as much as possible. That means that the antenna is supposed to be unobstructed and not prone to multipath fading. In an attempt to reduce fading, I built stands that elevate the beacons off the ground and let me place them anywhere I want. The ESP32 is placed vertically on the stand because the signal is emitted outwards perpendicular to the antenna in the PCB as shown above. Signal coverage is uniform and omnidirectional when the ESP32 is vertical. The device's antenna is raised above the case and not obstructed by the case or battery.

Last Updated: 11/23/2020, 9:42:47 PM