Everything AI – TOC

This blog has plenty of posts about AI, some are about AI tools, others are about installing AI locally, so this post is where I am putting all the AI stuff I have ever blogged about in one place !

The section Local AI is about creating your own AI server using freely available sources, the API section lists all the services that provide an API that can be used remotely (Most can not be installed locally anyway), and the Online Services is where you can get things done via AI online (That can be used using your browser, whether they provide an API or not, and whether they can be installed locally or not is a different story)

Continue reading “Everything AI – TOC”

HID Proxy Voodoo

A small device to help people build the things that don’t exist yet

There is a frustrating category of inventions that nobody builds.

Not because they are bad ideas.

Not because they are impossible.

Simply because the number of people who need them is too small.

If you are making a product for millions of people, development costs can be spread across a large market.

But what if the thing you want to build is for a few hundred people?

Or ten?

Or one?

This is especially true in accessibility.

A person may need a very specific input device because of a particular disability, a particular activity, or simply because the commercially available options do not fit their needs.

The problem is not always engineering.

Sometimes the problem is that every single one of these devices starts from zero.

Someone has to solve USB.

Someone has to write firmware.

Someone has to design electronics.

Someone has to build prototypes.

And all of that happens before anyone even knows whether the idea works.

I think this is backwards.


What if experimenting was cheap?

Imagine you have an idea for a completely new controller.

Not a normal keyboard.

Not a normal mouse.

Something that does not exist.

Maybe it is a wooden mechanism with a few switches.

Maybe it uses a potentiometer.

Maybe it is built from parts found in a workshop.

Maybe it looks ridiculous.

That is exactly how many good ideas start.

A piece of wood.

A few screws.

A sensor.

A crazy thought.

The problem is that turning that crazy thought into something a computer understands usually requires a lot of knowledge that has nothing to do with the actual invention.

You shouldn’t need to become a USB expert just to answer a simple question:

“Does this idea work?”


The idea behind the HID Proxy

The concept is simple:

Create a hardware platform that sits between the physical world and the computer.

A device that understands human input devices.

A device that can combine, translate, and create new inputs.

Instead of building a new USB device from scratch every time, use a flexible platform that already handles the difficult parts.

The first version is based around ESP32-S3 and STM32 microcontrollers and is designed around three main ideas:

1. Accept existing HID devices

Connect things like:

  • keyboards
  • mice
  • game controllers
  • joysticks
  • steering wheels
  • pedals
  • switches

and use them as building blocks.

2. Create new HID devices

Take simple electronics:

  • buttons
  • potentiometers
  • sensors
  • custom mechanisms

and turn them into devices the computer already understands.

A homemade controller should not require a homemade USB stack.

3. Manipulate and combine inputs

Sometimes the interesting device is not a single input.

Maybe a joystick and some buttons need to become a completely different controller.

Maybe two devices need to work together.

Maybe a non-standard interface needs to control a standard computer.

The hardware should be the easy part.


Why accessibility?

This project started as a general-purpose idea, but accessibility is where I think it has the strongest purpose.

The smaller the target group, the harder it becomes to justify development costs.

A company can spend thousands designing a product for millions of users.

But who funds a device needed by twenty people?

Or a device needed by a small group with a rare condition?

Those ideas often disappear, not because they are bad, but because the economics make them impossible.

If the cost of experimentation becomes low enough, more of those ideas can exist.

That is the goal.

Not to replace professional medical equipment.

Not to pretend one board can solve every accessibility challenge.

Simply to make it easier for people with good ideas to test them.


But isn’t this just a maker board?

Yes.

And no.

An engineer or hobbyist should absolutely be able to keep one of these in their toolbox.

The same way someone keeps an Arduino, a multimeter, or a breadboard nearby.

Not every experiment becomes a product.

Most don’t.

That is fine.

The purpose of experimentation is not that every idea succeeds.

The purpose is making failure cheap enough that people are willing to try.


The software side

There are many possible ways to use the platform.

A beginner might connect a few components and use a simple scripting language such as Lua.

Copy a small example.

Change a few numbers.

Test an idea.

A more experienced developer might replace parts of the firmware completely.

Someone else might only use the hardware design as a foundation for their own project.

I don’t think there should be one “correct” way.

The platform should disappear into the background and let people focus on the thing they are actually trying to build.


Why am I building this?

This is the part where I am supposed to write something inspirational.

I could say that I have always dreamed of changing lives.

That would not be completely false.

I do want this project to have a positive impact.

But the real answer is more complicated.

I like making things.

I like the moment when an idea stops being an idea and starts moving.

A machine doing something because I imagined it and built it is still one of the most satisfying feelings I know.

Somewhere along the way, that feeling became weaker.

While thinking about why, I came across research around the overjustification effect—the idea that external rewards can sometimes replace the internal motivation that made you enjoy something in the first place.

I do not think that explains everything.

But I think it explains part of it.

This project started because I was working on something else, only to discover that the thing I was building already existed.

Normally that means the project goes into a drawer.

Instead, I looked at all the work already done:

The research.

The designs.

The ideas.

The piles of pseudocode.

And I asked:

“What if this effort becomes a tool that helps other people build things?”

Maybe that is a better destination.


Quality matters

One thing I want to make very clear:

This is not meant to be a “quick hack that works sometimes.”

For accessibility especially, reliability matters.

A clever prototype is interesting.

A device someone depends on is something else entirely.

I do not want to cut corners simply because something works in a demonstration.

The objective is not just flexibility.

It is flexibility built on a reliable foundation.


Where does this go?

Honestly?

I don’t know yet.

Some parts will likely become open source.

Some parts may take more time, especially anything involving networking and security.

A device that controls a wheelchair, communication system, or another important tool deserves careful consideration.

“Open” and “secure” are both important goals, and sometimes they require difficult decisions.

The hardware will evolve.

The software will evolve.

The community around it—if one forms—will probably influence it in ways I cannot predict.


How can you help?

At this stage, the biggest challenge is simple:

Building hardware costs money.

Prototype boards.

Components.

Manufacturing.

Testing.

The boring things that are absolutely necessary before the interesting things can happen.

If you believe this idea is worth exploring, support can take many forms:

  • Sponsorship.
  • Technical feedback.
  • Testing.
  • Sharing the project with someone who may benefit.

The goal is not to build one product.

The goal is to make it easier for people to build the products that do not exist yet.


Final thoughts

I don’t know if this will become a commercial product.

I don’t know if it will become a widely used platform.

But I do know this:

There are people with ideas that never become reality because the first step is too expensive.

If this project can remove some of that first barrier, then it will have been worth building.

And honestly…

“If this platform saves someone from spending three weeks writing USB firmware just to test an idea, then it has already justified its existence.”

TTGO T9 Audio – Everything

I have had those boards (V1.6) for over a decade, had fun plans for them, but never got around to doing anything with them !

This document will always be a work in progress, even after i finish whatever project I will be making, anything new that I find about this board or similar boards will end up here

The TTGO T9 Audio RGB_LED WM8978 is an

  • ESP32 : ESP32-WROVER 802.11 b/g/n + Bluetooth 4.1 LE module with 4MB Flash, 4MB PSRAM
  • audio chip (WM8978 stereo CODEC)
  • SD card slot and 18 RGB LEDs.
  • Gyroscope++: InvenSense MPU-9250 : 9-axis motion-tracking sensor IMU 9-DOF MPU-9250 9-Axis Attitude + Gyroscope + Accelerator + Magnetometer Sensor Module
  • Battery: The circuitry to charge and use a battery in UPS mode !
  • built-in microphone
  • 3.5mm audio jack

Now that I might have some free time soon, I decided to compile the resources here for my reference, and to see what fun project they might be good for !

1- Links

Unorganized links

new boards, AI Thinker … ESP32-A1S

New boards, LyraT

RAM disk on boot

I will come back and provide some context about why i need this later, for now, if you want your PC to take away some ram and make a RAM disk, you have two ways, I would go with the first

The easy way (tmpfs)

Start by creating a directory to mount the ram disk onto

sudo mkdir -p /hds/ram

Then just add a line like the following to the /etc/fstab file

tmpfs /hds/ram tmpfs defaults,size=80G 0 0
Or, the more elaborate
tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,size=80G,mode=0755 0 0

Now mount it
sudo mount -a (To avoid having to restart)

If you have a dual CPU setup, I recommend you check out NUMA tuning before playing with this

The other way (ramfs)

You will not see real world gains in speed, they are super marginal, and you lose a lot of features like swapping ! Also, it eats up all the ram in advance, ram that could have been used for caching
If you must, it is the same as above, but the line in fstab is the following instead

ramfs /hds/ram ramfs rw,noatime,nodev,nosuid,noexec 0 0

Notes:

1- “df -h” will report an 80 GB disk, even though they are not missing from ram, it is an upper limit, not a pre-alocated space

2- noatime doesn’t matter much, on a ram disk, it is a neglegible load, I add it anyways because none of my applications can make use of ti

3- noswap : swapping a ram disk is probably the worst idea ever ! so you may want to consider

tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,noswap,size=80G,mode=0755 0 0

4- NUMA tuning

Now, to keep all the ram on one CPU, while still allowing it to spill over to the ram from th other CPU when needed, you can pin the process to a CPU and make the ram of that CPU preferred !

Here is an example, if you intend to use the disk with MySQL, you would do as follows

1- Make sure the daemon is called mysql

systemctl status mysqld

2- Create an override file
sudo systemctl edit mysql

3- Add NUMA binding (Empt line means “Clear the existing startup command first”)
[Service]
ExecStart=
ExecStart=/usr/bin/numactl –cpunodebind=1 –preferred=1 /usr/sbin/mysqld

sudo systemctl daemon-reload

sudo systemctl restart mysql

ps aux | grep mysqld

An alternative to all the above would be to pin it to CPUs !

[Service]
CPUAffinity=16-31

The rest is just like the other method

Detecting Light and movement with Arduino

When it comes to detecting light and movement with microcontrollers, one has quite a bit of options, after explaining each one, I will compare them for you at the bottom of this pots

LDR Light Dependent Resistor

This is the simplest one, and it only costs a few cents

Phototransistor

A photo transistor is in my oppinion a great tool to use with microcontrollers, very fast response time (Slightly slower than a photodiode), and can be used with the digital pins, the reason is that it works exactly like a transistor, but instead of enabling the current by providing voltage to the base, the current is provided from light !

So, if you were to connect the Emitter to ground, and the Collector to the digital pin, they would get connected when light is detected, that is it

Photo interrupter

A photo interrupter detects the presence, absence, or movement of an object by sensing when a light beam between an emitter and a receiver is blocked.

This is basically something you would find in your inkjet printer ! or in a factory (Conveyor belt), or most commonly, on en elevator (Door opens when an object is in the way)

The transmitter and receiver work together either side by side or opposing each other, when they are side to side, a mirror reflects the light onto the receiver

If you are trying to detect a red light or a light of the wavelength close to that of the interrupter, odds are that you can use the receiver on its own without the LED (Transmitter), simply do not power it up !

photodiode

PIR (Movement) sensors

PIR Sensors such as the HC-SR501 can detect movement, but they requier more than 1 component, the sensor itself, the plastic cover for the sensor (Pir Lens Cover creates a FRESNEL LENS), and an IC that amplifies the signal and analyzes it !

Project cloud electric meter

The cloud electric meter is a project consisting of a 3 parts

1- A microcontroller and a current transformer (As of now, I am using the SCT-013)
2- A server to collect the data from the microcontrollers
3- A mobile phone app to display the data

The second and third (Server and application) are beyond the scope of what we are doing here, here, I will be examining all the options for a microcontroller and current transformer, With and without the cloud part.

1- The no cloud setup

The first example we will be using is the current transformer (SCT-013) with a nodeMCU ESP8266 that shows data about the current on a screen, this is the simplest setup, and is for people who are here to figure out how to connect their transformer, To do this, you will need a 16 x 2 screen, and an LCD I2C Interface Adapter.

1- Connecting the LCD to an ESP8266 (Tutorials for arduino and ESP32 are all over the internet)
2- Connecting the Current Transformer
3- The software

Connecting the LCD through I2C board

Similar tutorials are all over the internet, this one is here so that I can have a compatible setup between all the devices in the IoT project, the way those 2 boards (The LCD and I2C board) are very popular, and are connected in more or less the same way in all tutorials, but since you are here, might as well make it as simple and complete as possible.

LCD displays require a lot of connected digital pins to work, but this is easily solved with a very cheap LCD-I2C board that connects to my 1602 (16×2) LCD display (Or 2004 20 x 4 LCD modules) with its 16 pins on one end, and connects to your microcontroller (ESP8266, ESP32, Or Arduino, etc…) via 2 I2C pins (SDA/SCL)

The LCD I2C Interface Adapter board is based of a popular 8-bit, remote I/O expander for the I2C bus namely the pcf8574T / ABX919… A remote expander can function as an LCD driver, but it also works for many other purposes, but that is beyond the scope of the simple instructions presented here, here we are interested in driving an LCD screen

The I2C address of can be set by setting the available solder points for addresses in the range of 0x20 – 0x27.

One thing you may want to know is that the jumper at one side of the nameless I2C board is for the LED backlight ! it can be fed through a separate power supply (Remember to combine the ground pins).

In this example, I am using an ESP8266 on a NodeMCU board.

Power

The ESP8266 and the ESP32 are 5V tolerant on the data pins (Proof here), So, because the linear voltage regulator on the ESP8266 NodeMCU board does not have a heatsink, we will be connecting the screen directly to the 5V power source, why burdain the small regulator with the screen !

So, on my I2C board, I connect the GND and VCC to the external power supply (Don’t power the board via USB and connect to the VIN, this is not how it works, VIN is for voltage input, not for output)

So, on my board, the geekcreit doit esp12f devkit v3 (In arduino studio, it is compatible with NodeMCU 1.0 – ESP-12E Module)

The data pins are connected as follows
SDA – D2 – GPIO-04
SCL – D1 – SPIO-05

You are done with this, now, how to print to the screen !

the first step is to find the I2C address, my board provides addresses in the range of 0x20 – 0x27. without soldering anything, the address is probably 0x20, but if not, we can figure it out.

To figure out the address of your LCD display, use the following code

#include <Wire.h>
void setup() {
Wire.begin(4, 5); // SDA, SCL
Serial.begin(115200);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
for(address = 1; address < 127; address++ ) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16) Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
}
if (nDevices == 0) Serial.println("No I2C devices found\n");
else Serial.println("done\n");
delay(5000);
}

Roof screed job

The following all applies to a flat root cement slab that has slight ponding

You will need to apply the cement in 2 phases, 1- the slurry 2- the concrete mix

When i say by volume, what is meant is that 1 cup of cement gets x cups of aggregate, no weight involved

1- The bonding slurry

  • As thin as you can provided it is “Continuous” and “Worked into the surface”
  • thicker is bad not good
  • The concrete layer needs to be added IMMEDIATELY after applying the slurry, within lets say 10 minutes in warm weather
  • consistency should be thicker than emulsion paint

2- The concrete mix

The bare minimum height, for something that is not a foot path, and is not expected to hold any weight is 2.5CM ! cement cant be less than that, it will break and create problems later on !

Consistency = Thick enough to hold its shape

3- The proportions

1- Cement + SBR slurry

Equal amounts of all 3 by volume

1 SBR
1 Watter
1 Cement

The cement mix by volume…

1 cement
3 sand
1 stone dust
2–3 teaspoons per cup of cement, (5–8% of cement volume)

Things to watch out for

Substrate condition

  • Slab is sound (no loose flakes)
  • No dust when rubbed by hand
  • No oil, paint, curing compound, or algae
  • Cracks addressed (at least cleaned / chased)

Moisture state (SSD)

  • Surface is damp but not shiny
  • No standing water in depressions
  • Water does not bead up

Bonding slurry

  • Freshly mixed
  • Thin, paint-like
  • Fully covers area
  • Worked into pores
  • No puddles or ridges

Slurry Finger test

  • Sticky
  • Leaves residue on finger
  • Still dark

Screed mix consistency

  • Semi-dry
  • Holds shape when squeezed
  • No water sheen
  • Does not crumble

M271 thermostat

The lowdown: Before you go and get a thermostat, there is a part that is very often broken along with your broken thermostat, it is the casing (the plastic thing that holds the thermostat in place).

Again, this is my W211, and the process itself is very simple as you will see below, loosen the cold air duct in front of the engine to make room for the screws to be removed, remove a couple of screws, install, then put them back, that is all there is to it.

When i came to change my thermostat, i unscrewed the 2 screws that hold the plastic casing in place at the front of the engine, and before you know it, it dropped, i thought there would be pulling, but no, the spacer that holds the thermostat in place, and is part of the casing/pipe was broken from the word go

Before you try to pull the spacer (Plastic cylinder) from inside, you need to remove the o ring which is likely trapped between the spacer and the engine (Near the surface), once the o ring is out, the plastic cylinder will come right out.

Once you do, your thermostat might be busted, but in my case, the rubber seal was not sitting right, probably due to the broken spacer, and created a space between the thermostat and the spacer, hence the problem

Best compression algorithim for my sql file backups

SQL files are highly repetitive, I have been using bzip2 (pbzip2) for over 20 years, but is it really a sane choice in 2025 ?

We already know about gzip (even older than bzip2), it is super fast, but the compression is not great, so the options in question are “zstd” and “xz (LZMA2)” and “brotli”

zstd -19 -T12 myfile.bin (-19 for maximum compression (5 for low) T12 for 12 CPUs), original file is kept by default
unzstd myfile.bin.zst

xz -k -T0 -9 myfile.bin (Auto threads, high compression, -k for keeping original file)

Compressing a 200GB SQL file on an intel i7-4930K using 8/12 threads

zstd at compression level 19 (MAX) = 20.63% ( 40 GB)
xz at compression level 9 (Max) = 38GB

So, xz at max compression took much longer to finish, but resulted in a 2GBs smaller file….

zstd at compression level 15 seems to be the sweet spot, I will redo the experiments soon and bring in more precise results on what compression and how much time.

Fix Debian hum/buzz in speaker after a few seconds

On my system, whenever no sound comes out of the speakers for a bit, the speaker starts humming, the same sound that comes out of it when my PC is switched off

In my case, I am using Debian 13 with gnome

What is that sound

That sound is basically the speaker picking up the power line frequencies, and because it is an amplified speaker, it amplifies it, and makes it audible !

Why does it come out from my PC after some time

There are two audio drivers for linux, PulseAudio/ALSA and PipeWire, both supporting power saving mode, when no audio comes out of the speaker for some time, power saving mode kicks in, the sound chip (FKA the sound card) is disabled, so you get that sound exactly as if your computer was switched off !

How do i fix it ?

Disable power saving mode is the simplest method !

To disable it for this session, which works instantly, run the command

echo "0" | sudo tee /sys/module/snd_hda_intel/parameters/power_save

To make that change permanent (Later reboots)

sudo tee /etc/modprobe.d/snd-hda-intel.conf <<< "options snd_hda_intel power_save=0"