You know, in a typical year after retirement, I noticed that I have been working on some repair or pet project at the rate of 1 or 2 per month. I don’t like to explain all of them, otherwise this blog will be just that – my repair/project blog. But once in a while I feel like I should write about these small projects. Otherwise many keep wondering what I do after retirement and how I am able to spend time. Generally I just tell these folks that I am busy with my family especially my daughter since she does not attend school (unschooled). After hearing this, most stop asking any more questions. It is not that I am working on any top secret projects. Just that these small project don’t qualify as something to write or talk about them.

In this blog, I write about pretty much all big projects that I work on. On some rare occasions I can’t write about a project that I worked on for someone and because it is their idea. I never asked them if I can write about it, but may be they would be ok. I want to reiterate here again that I didn’t charge any one of them for the time and effort that I put in their project. I have to highlight that aspect every time because someone or the other would ask me if I am earning any side income from my projects after retirement :). I don’t have any active income, just my passive income from my investments. As I understand, people are generally skeptical when I say that I am retired without any income except for my investments.

Anyway, getting back to the point, I normally would not even bother with repairing as many things as I do now if I was still working. It is cheaper and faster to just replace what is broken. But given that I have so much time at hand, I feel like I have to repair everything. I have always been interested in knowing how things work. The curiosity makes me break many things to learn how they work. In the past however, I was quite busy ever since my 10th grade up until recently. So the passion just stayed in the back burner. I restarted it now.

With that intro, let me tell you about a story that happened recently which would normally not turn into a project if not for the free time I have. Basically I have a small USB fan that I turn on to cool my media center PC when I feel it is running hot. It stopped working a few days ago. Normally I would just buy a new one because these are super cheap at Rs. 300 or so on amazon. Yet, I decided to fix it for a couple of reasons – 1. I have time and I enjoy fixing things. 2. I don’t want to create more e-waste (sustainable living, yada yada, you get it right?). Anyway, if you have not seen one of these fans, it looks like this

The fan simply works via USB. You connect it to a USB port on a laptop, PC or charger and the fan starts. I have a couple of these fans but one of the fan stopped spinning recently. I decided to find the issue and opened it up. I checked the output to the fan near the terminals that directly connect to it and I can see a voltage there. Yet it was not spinning. Since it is a DC motor and not a BLDC (brushless DC motor), I unsoldered the motor wires and gave a 5V supply directly to the terminals and still no luck. So I know something is wrong with the motor.

Then I removed the motor from the casing and opened the motor itself. Initially I could not figure out how to open the motor, but as usual, youtube to the rescue and I found a video of someone showing how to open the motor. The video not only explained opening the motor, but also how to fix it. Just as the video mentioned, the brushes are not touching the commutator properly.

I adjusted the brushes and closed the DC motor and put back everything. The fan now works! Normally this is where the project should end. But then I got another idea. I connect the fan when the CPU temperature or hard disk temperature on the media center is high. I do this by logging into my media center PC and checking the temperatures. During summer I generally connect the fan all the time during the day. I felt this is very cumbersome. Why should I check the temperatures and manually connect the fan? It should be automatic. So I decided to add a relay to the fan terminals and control the relay from my media center PC when it gets hot.

Basically I wrote a small script that will check the CPU and hard disk temperatures every 5 seconds and turns on the fan by sending a curl command to my home automation system which controls the relay that turns on the small fan. I know, all that sounds pretty confusing, but unless I show you my setup it will be difficult to understand and I don’t want to make a video of my setup. So just imagine for a minute :). Anyway, this is one of those small projects and that is how I wasted 5 days in retirement, instead of spending some Rs. 300 to buy a replacement. Strange I know. In case you are interested in the script, I am copy pasting it below:


import subprocess
import time
import datetime

def get_cpu_temp(id):
  output =['cat', '/sys/devices/virtual/thermal/thermal_zone%d/temp' % id], capture_output=True, text=True).stdout
  temp = int(output)
  return int(temp / 1000);

def get_hdd_temp(id):
  cmd = "(/opt/sbin/smartctl -d sat -A /dev/%s) | grep Temperature_Celsius | awk '{print $10}'" % id
  output =[cmd], capture_output=True, text=True, shell=True).stdout
  if len(output) == 0:
    return 0
    return int(output)

def switch_fan(state, reason):
  cmd = 'curl -X POST ""' % (state, reason.replace(' ', '%20'))[cmd], capture_output=True, shell=True)

def log_state(state_str):
  global last_log_time
  timestamp ="%Y-%m-%d %H:%M:%S")
  print('%s   %s (%s)' % (timestamp, state_str, reason), flush=True)
  last_log_time = time.time()

min_cpu = 55
max_cpu = 65
min_hdd = 48
max_hdd = 50
state = 0
old_state = -1
log_interval_seconds = 60

print('min cpu: %d\nmax cpu: %d\nmin hdd: %d\nmax hdd: %d\n' % (min_cpu, max_cpu, min_hdd, max_hdd))

while True:
  cpu0_temp = get_cpu_temp(0)
  cpu1_temp = get_cpu_temp(1)
  hdd1_temp = get_hdd_temp('sda')
  hdd2_temp = get_hdd_temp('sdb')
  hdd3_temp = get_hdd_temp('sdc')
  hdd4_temp = get_hdd_temp('sdd')

  reason = 'cpu:%dC %dC   hdd:%dC %dC %dC %dC' % (cpu0_temp, cpu1_temp, hdd1_temp, hdd2_temp, hdd3_temp, hdd4_temp)

  if cpu0_temp >= max_cpu or cpu1_temp >= max_cpu or hdd1_temp >= max_hdd or hdd2_temp >= max_hdd or hdd3_temp >= max_hdd or hdd4_temp >= max_hdd:
    state = 1
    switch_fan('on', reason)
  elif cpu0_temp <= min_cpu and cpu1_temp <= min_cpu and hdd1_temp <= min_hdd and hdd2_temp <= min_hdd and hdd3_temp <= min_hdd and hdd4_temp <= min_hdd:
    state = 0
    switch_fan('off', reason)

  if state != old_state:
    if state == 1:
      state_str = 'Fan on   '
    elif state == 0:
      state_str = 'Fan off  '
      state_str = 'Unknown  '
    old_state = state

  if time.time() - last_log_time > log_interval_seconds:
    log_state('         ')