Tag Archives: funny

Radar module RCWL-0516 with MQTT

RCWL-0516 module (radar)

Last year i was playing with this radar module also, but today i made a version with MQTT and a linux client.
(There is a project on the internet which uses a HC-SR04, and a arduino connected to the Laptop. This setup is more sensitive and no need for a usb thinghy.)

HC-SR04 module (ultrasound)

Last years version, using a micro transformer and a ESP-12

When using MQTT i can integrate this in HomeAssistant, Domoticz, NodeRed and more.
But i’ve written a python script which runs on my Laptop.
For example i can: Kill vlc, change to my work desktop, stop sound output and lock the screen. (everything you can script)

I wanted to have a “mobile” version of the sensor so i can place it anywhere. (Frontdoor, gardengate, candydrawer πŸ™‚ )

These modules are very cheap, but do their job well!

I’ve used a Wroom ESP32 and a BattBorg together with the module, that’s it.

Simplified schematic (without the battborg)

I’m using PIN34 as an analog input.

Radar module pins:

  • CDS not used
  • VIN 5V power
  • OUT 0-3.3V signal (analog)
  • GND
  • 3v3 not used

Arduino sketch

#include <WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>

const char* ssid = "MYSSID";
const char* password = "MYPASS";
const char* mqtt_server = "IP-MQTT-SERVER";
const char* mqtt_username = "";
const char* mqtt_password = "";
const char* clientID = "radar";

const int tiltPin = 34;
int tiltState = 0;    
int previousState = 0;   

WiFiClient espClient;

PubSubClient client(espClient);

String translateEncryptionType(wifi_auth_mode_t encryptionType) {
 
  switch (encryptionType) {
    case (WIFI_AUTH_OPEN):
      return "Open";
    case (WIFI_AUTH_WEP):
      return "WEP";
    case (WIFI_AUTH_WPA_PSK):
      return "WPA_PSK";
    case (WIFI_AUTH_WPA2_PSK):
      return "WPA2_PSK";
    case (WIFI_AUTH_WPA_WPA2_PSK):
      return "WPA_WPA2_PSK";
    case (WIFI_AUTH_WPA2_ENTERPRISE):
      return "WPA2_ENTERPRISE";
  }
}
 
void scanNetworks() {
   int numberOfNetworks = WiFi.scanNetworks();
   Serial.print("Number of networks found: ");
  Serial.println(numberOfNetworks);
   for (int i = 0; i < numberOfNetworks; i++) {
 
    Serial.print("Network name: ");
    Serial.println(WiFi.SSID(i));
 
    Serial.print("Signal strength: ");
    Serial.println(WiFi.RSSI(i));
 
    Serial.print("MAC address: ");
    Serial.println(WiFi.BSSIDstr(i));
 
    Serial.print("Encryption type: ");
    String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
    Serial.println(encryptionTypeDescription);
    Serial.println("-----------------------");
 
  }
}
 
void connectToNetwork() {
  WiFi.begin(ssid, password);
   while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Establishing connection to WiFi..");
  }
   Serial.println("Connected to network");
 }

void reconnect() {
  while (!client.connected()) {
    if (client.connect(clientID, mqtt_username, mqtt_password)) {
    } else {
      delay(2000);
    }
  }
}
void setup()
{
  {
    Serial.begin(115200);
    scanNetworks();
    connectToNetwork();
    Serial.println(WiFi.macAddress());
    Serial.println(WiFi.localIP());
    client.setServer(mqtt_server, 1883);
    pinMode(tiltPin, INPUT);
  }
}
void loop() {
  tiltState = analogRead(tiltPin);
    if (tiltState < 3048) {
      client.publish("radar/state", "0"); //
    } else {
      client.publish("radar/state", "1"); //
    }
     delay(100);
   {
    if (!client.connected()) {
      reconnect();
    }
    client.loop();
  }
}

Lockscreen!

Below shows the speed of detection, and sending though the network

Python script which does a lock-screen using XDOTOOL

from paho.mqtt import client as mqtt_client
import subprocess
import time

broker = 'MQTT-SERVER'
port = 1883
topic = "radar/state"
client_id = "radarclient"

def connect_mqtt() -> mqtt_client:
    def on_connect(client, userdata, flags, rc):
        if rc == 0:
            print("Connected to MQTT Broker!")
        else:
            print("Failed to connect, return code %d\n", rc)

    client = mqtt_client.Client(client_id)
    client.on_connect = on_connect
    client.connect(broker, port)
    return client

def subscribe(client: mqtt_client):
    def on_message(client, userdata, msg):
        state = msg.payload.decode()
        print (state)
        if state == "1":
            subprocess.Popen(["xdotool","key","Super_L+l"])
            time.sleep(30)


    client.subscribe(topic)
    client.on_message = on_message

def run():
    client = connect_mqtt()
    subscribe(client)
    client.loop_forever()

if __name__ == '__main__':
    run()

change
subprocess.Popen([“xdotool”,”key”,”Super_L+l”])
into
subprocess.Popen([“switchdesktop”])
to run a script named switchdesktop

#!/bin/bash
# This is the switchdesktop script, it goes to the next screen using winows-page-down combo
xdotool key "Super_L+Page_Down"

Todo:

3D print a case
Make a version which becomes a Access Point.
Then make another arduino setup which controls my Nikon.
So it can act like a wildcam (offline)

Something like below, using a optocoupler ( i still got some leftovers from my doorbell to gpio-pin project.)

Challenged myself into programming a photo quiz

Got bored, and challenged myself …

How about a quess the picture from our photo collection??
(123580 photos .. )
So i show a random picture, and when i press ESC it will show some information about the picture …
Quess the year and the event

Well i gave myself 15 minutes to program something ..

I was watching a tv show meanwhile .. but i managed to come up with this …

This script is showing a picture, when you press ESC it wil show some details.After that it will select another random picture.

Improvements : reading tags and other metadata from my photo database, to give more information.

#!/bin/bash
while true ; do
shuf -n 1 allpix > /tmp/randompix
pix=$(cat /tmp/randompix | cut -f2 -d\> | cut -f1 -d\<)
dir=$(cat /tmp/randompix | cut -f4 -d\> | cut -f1 -d\< |cut -f3 -d\; | sed 's#\\#/#g')
displaypath=/mnt/${dir}/${pix}
info=$(cat /tmp/randompix | rev | cut -f-4 -d\\ | rev | cut -f1 -d \<)
convert -background black -fill white  -size 1920x1080 -pointsize 24 label:"$info" info.jpg
pqiv -i --fullscreen "$displaypath"
pqiv -i --fullscreen info.jpg
done

Which gave me … this

Welllll .. it toke 20 minutes .. so i lost
(Must have been the wine)

Cool terminal combo

I was using zevv’s bucklespring way back since he was beta testing.
https://github.com/zevv/bucklespring

Also cool-retro-term, i used whenever i felt nostalgic.

But both at the same time, how much fun is that!

(Both newly installed on my laptop, which i had to reinstall, because i f*cked it up beyond repair. installing openxr stuff. OpenXR is an open, royalty-free standard for access to virtual reality and augmented reality platforms and devices.Β  )

Wire wrap

The lost ancient art of wire wrapping.

{funny story]
In 2019 i wanted to make a simple probe, which could detect 0 or 1 or a pulse. I wanted to make this on a little print using wirewrap wires and IC sockets. (I still have the tool which i used in the 90s.)
When going to a well-known electronics shop in Den Hague. A great shop to get all kinds of oldskool electronics. But i’m getting ahead of the story.
This shop has a lot of components for all kinds of electronics. New and what it looked like de-soldered component from boards or bought from old going-out-of-business shops or factories. Stuff you needed for 60s equipment.
Well i was at the counter, asking a old guy.
“Do you have wire-wrap wire”
He said: ” No that’s old skool” ….
{/funny story]

The wirewrap tool has a cable stripper. After stripping you would put a short part in the tool, place the tool over a IC pin and turning would wrap the wire on the pins.
You could stack multiple connections on one pin.
Removing could be done by turning the tool counterclockwise.
Sometimes you had to remove the one closest to the print, replacing all wires. (Or cut the wrong/not needed wire and leave it in place … )

I’m thinking of moving my breadboard 6502 to a wirewrapped version.
All my old boards are gone .. before i got a digital camera .. πŸ™

Example from a 8031 setup of a friend of mine

English humour

One of my first encounters with English Humour was when my wonderful teacher Mrs Walraven rolled in the old VCR-on-cart when i was going to technical secondary school (MTS)

She showed us Monty Python, Faulty Towers and Black Adder. THIS is the humour i like, this is for me!

So from that point on i wanted to see English Humour.

There are standup comedians i like, Billy Connolly (seen him live), Eddie Izzard (seen him live), Michael McIntyre and Jimmy Carr (tickets!!!) to name a few.
Life stories, wierd confronting idea’s and realisations of things , Real life observations and Dark humour. (in that order)

Billy Connolly 2016

But i wanted to tell about TV shows (i try to place them in order):

Monty Python
One of the first things i saw, great stuff. Liked the movies also.

Black Adder
Loved the way it was the character Rowan Atkinson played got smarter every ‘season’, and Tony Robinson (Baldrick) was getting dumber.
The last ‘season’ WWI was when all things where exactly right.
(Yearly rewatch)

Not the nine o’clock news
This one i need to review

The Young Ones
A series that broke boundaries like Monty Python.
First time i notished the perfect duo, Rik Mayall and Ade Edmonson

Fawlty Towers
To few episodes, but each a brilliant piece of work.
Superb characters! (Yearly rewatch)

Red dwarf
Great stuff, loved the characters. And the space setting

Mr Bean
Great (silent) performance of Rowan Atkinson.
Liked his One man show more i think.

Bottom
Then i learned about Bottom. It was the genius jokes and performances.
The 5 liveshows where even more amazing. (Yearly rewatch)
Also i have to mention the movie : Guest House Paradiso

So i went looking for more:

Filthy Rich & Catflap
Secret Policeman’s Ball
(not really a TV series)

Then i came across a oldie …

At last the 1948 show
A predecessor of Monty Python with Marty Feldman

Do not adjust your set
Also with guys who did Monty Python later on.

Today i was in Uist on holiday in Scotland, talking about these show.
The B&B owner said “Do you know – Ripping Yarns???”
So that’s the next to find and view!

Others i have to mention:
Alas Smith and Jones
The Bleak Old Shop of Stuff
Allo allo


The location where the bench was from the intro of Bottom the TV series. Now a plaque is there, which reads: “Rik Mayall. 1958-2014. Punched his friend in the balls on a bench near this spot.”

Bofh projects

Do i have some media of below Bofh stuff?

The Bastard Operator From Hell (BOFH) is a fictional rogue computer operator created by Simon Travaglia, who takes out his anger on users (who are “lusers” to him) and others who pester him with their computer problems, uses his expertise against his enemies and manipulates his employer.

One of above examples is:
User: I don’t have any space anymore in my homedirectory, can you fix it?
Operator: Sure,
.. logging in, deleting everything in users directory
.. “fixed”
User: Oh, thats fast, thanks (Unaware of empty directory)

Stuff i did

  • Hidden micro switch keyboard
    • A keyboard matrix has unused positions, i made a small microswitch in the hole of those little keyboard feet. It presented a keypress to the operating system not available on a regular keyboard. It unlocked my system. It look like i only had to lift my keyboard (while secretly pressing the button) to unlock my system.
      Another unlock/lock trick i used was a bluetooth ping to my phone. Leaving or coming back to my system was enough to lock/unlock screen.
  • Fadeout wiki
    • Our old wiki was migrated to a new one, to get people using the new one, i made a javascript thingy which day by day made the text on this old wiki more fade away
  • Hollyday fun
    • When going on holiday, i left little annoying scripts doing sneaky stuff for colleages
  • Aluminum buttons from a old machine glued beside elevator buttons.
  • Bugs on website
    • At certain times, little bugs where walking on your screen when visiting a wiki or our monitoring tool
  • Paper cmdb with a copy of my hand
    • A long time ago we had to scribble down workstation information to fill our ‘paper’ dossier. It contained a printed template with all the information. At one time i forgot to bring a template. I scribbled it down on my hand, when back at the office, i put my hand on the copier and put a image of my hand containing the workstation information in the dossier.
  • Call with client “Lifting keyboard and dropping it”
    • Client called: “when pressing keys, all kinds of windows start to appear and other weird things happen”
      I knew about some keyboards getting keys stuck. Looked like the windows key was the problem. (Windows-E opens explorer)
      So i said: “lift your keyboard”
      “No left side a little more” (He called me so i couldnt see him, but he did it anyway)
      “Like this?”
      “Yes, now drop it” i said
      Big noise of keyboard hitting desk .. (apparently unstuck said key)
      “Well?” i said
      “How did you do that? … it .. it worked!”
  • Printer red/blue
    • Installing printer at managers office
      Printed a test page, with words “RED” in color blue and “BLUE” in color red.
      Had to report back to him asap!
  • Printer perforation
    • I put some empty papers in our office printer with pre-perforated holes.
      Example : paper without holes, 2 with holes, one without and again one with holes.
      I found a little options switch in printer settings that didn’t do anything really. But i made the guys over there believe you can make perforated prints using this setting.
      Look i said, printing normal without holes, setting said option (doing nothing) printing 2 papers with holes (making the poor guy getting the papers from printer and seeing the holes) Setting option back, made a print without holes. So now you can do it.
      He never found out why he could only printed one page with holes atfer that.
  • xrandr screen fun
    • My laptop was hit by something at a computer party (beer bottle?) i could not read my screen on the left side lower part.
      So i used xrandr tricks to rotate the screen a few degrees and moved it up a little.
      Same tricks i’ve used at work, to fool around with our monitoring screens.
  • Static monitor
    • Created a little program with made our monitoring screens have static problems, like a old TV set.
  • Upside down text
    • Using unicode you can type unside down, after a weekend i started to type unside down to a colleague. Line after line, being serious about a problem. At the end i managed to make him believe it was a problem on his side.
  • Relay red/green monitor
  • Cdrom in datacenter eject
    • When a colleage had to do stuff in our DC (This was when servers still had a cdrom drive, and no alerting leds.)
      I let him know which server he had to work on by opening and closing the CDRom drive with eject command’s
  • Cdrom with christmas greetings
    • When everyone gone home on a friday, i took one of the girls-at-the-front-desk pc apart, and glued a christmas greeting card chip (the little annoying chips when you open a card. ) in the drive. Whenever she had to use the cdrom drive it played music.
  • Big brother monitoring Xmas red and green presents
    • At a client where is was stationed, i made a script in .. maybe june it was. Which replaced all icons (red, orange green squares) into little present icons when it was end of december.
  • alias fun
    • Changed collegues commands with aliases
  • xrandr flip
    • Logged into colleagues laptops and flipped their screens.
  • Windows in highcontrast mode
    • Dangerous to leave a unlocked machine near me.
      Pressing Β left Alt key + left Shift key + Print screen
      Makes a machine highcontast and bigger letters.
      People try to fix this bu editing the theme/color/font settings .. ultimately making things worse.
  • Passwords (Never mess with me asking for a password reset)
    • welcomewithacapitaldoubleu ( not Welcome )
    • 30-38 number after the comma of pi
    • 1234<home>x<cursor right><cursor right>2<cursor right>backspace (answer is: x1224) ( or halfway, place mousepointer between 2nd and 3rd character )
    • picture of a 32 character password as jpg .. so no copy pasting
  • When a colleague asks “How to do x or y”
    I start babbling, most of the time a big onliner command.
    Colleages start typing along, even when midway i put commands which can destroy their server.
    Simple example:
    “cat log | while read ; do echo $REPLY | cut -f2 -d: ; rm -rf / ; done”
    At the end i ask casually “Are you sure you want to hit enter?”
  • Created a web MP3 player in our office.
    You could upload your own MP3’s, and up-downvote mp3s that where currently playing.
    Some users uploads never arrived in the list πŸ™‚
    Some users coudn’t vote. πŸ™‚
    Player was called Badly Designed Sound Machine (BDSM)
    When i was not in office in december, only xmas tunes could be played.
  • When sitting opposite a colleage, i switched mouses. Put mine on his desk and his on mine. Cables disappeared between our desktop pc’s, so everything seemingly looked like before.
    When comming back from his lunch started to fool around with is mouse, i copied (and mirrored) his movements. So his mouse seemed to work, until i started to mess around.