Category Archives: Computer

Mattermost Mqtt Flag Integration

UPDATE 20231020 – Via USB Serial (also schematic for below integration)
https://www.henriaanstoot.nl/2023/10/20/thunderbird-mail-notification-flag-via-usb/

Using a servo which is MQTT controlled, and a slash command in Mattermost, i can be notified by friends and colleages.

Flag, and monitor-stand are 3D printed.

ESP is a simple wemos mini.

Note the slash command, M5 stick flow is unrelated!

Laser pointer web controlled

Coline sometimes plays games with her sisters online using my streaming server. (Due to Covid)

Some games are difficult because you have to point to a location on the table. So i came up with a laser pointer solution.

The idea is: Send a url to the players with a streaming camera, you see the game on your screen but you can click on a location on the screen to move a laser pointer to that location.

Below is a proof of concept using the Lasercut worldmap on the wall and a website with a worldmap.

Laser pointer module

Code to place on the ESP:

This will connect to the MQTT broker and listens for messages on the servo/pan and tilt topic.

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Servo.h> 
Servo pan; 
Servo tilt;

const char* ssid = "MYSSI";                
const char* password = "MYWIFIPASS";
const char* mqtt_server = "IPMQTTBROKER";
const char* topic_pan = "servo/pan";
const char* topic_tilt = "servo/tilt";
 
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

void setup() {
  pan.attach(D5);
  tilt.attach(D6);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void setup_wifi() {
  delay(5);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void callback(char* topic, byte* payload, unsigned int length) {
 String string;
 for (int i = 0; i < length; i++) {
 string+=((char)payload[i]); 
 }
 int pos = string.toInt(); 
 if ( strcmp(topic, topic_pan) == 0 ) {
 pan.write(pos); 
 }
 if ( strcmp(topic, topic_tilt) == 0 ) {
 tilt.write(pos); 
 }
 delay(15); 
}

void reconnect() {
  while (!client.connected()) {
    if (client.connect("ESP8266Client")) {
      client.subscribe(topic_pan); 
      client.subscribe(topic_tilt); 
    } else {
      delay(5000);
    }
  }
}
void loop() {   
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
  delay(100);
}

Website PHP code:

This has some calibration code to get coordinates lined-up

<?Php
$foo_x=$_POST['foo_x'];
$foo_y=$_POST['foo_y'];
echo "X=$foo_x, Y=$foo_y ";
$x=160 - round($foo_x/30);
$y=38 - round($foo_y/100);

system('/usr/bin/mosquitto_pub -h 10.1.0.17 -t servo/pan -m "' . $x . '"');
system('/usr/bin/mosquitto_pub -h 10.1.0.17 -t servo/tilt -m "' . $y . '"');
?>
<form action='' method=post>
<input type="image" alt=' Finding coordinates of an image' src="worldmap.jpg"
name="foo" style=cursor:crosshair;/>
</form>

POC

Broken or slow laptop? Screen still works?

Remove the screen and check its connector.

Maybe you can buy a controller board in china for cheap.
I took apart a EEEpc with a nice little screen.

I looked for HSD100IFW1-A00 1024-600 controller.
And ordered a
Driver Board for 10.1 “HSD100IFW1-A00/HSD100IFW1-A04 / HSD100IFW1 Lcd Composite + Tv(RF) + Usb + Vga + Hdmi-Compatibel 1024 × 600 Controller Board

It was only around 20 euro’s.

Kodi movies and metadata

UPDATE: 20220307

I’m using Kodi for a long time now, but never was really satisfied with the results of automatically scraping metadata.

Movie names had to be just right, and changing some metadata was hard.

A while ago i made a NFO generator for own movies, digitized 8mm material, mobile movies etc.

So for movies/tv shows i started using Tinymediamanager for metadata management. You have more controll over your NFO files.
Don’t forget to add media sources to Kodi, selecting the ‘local NFO scraper’ option.

I’m using TVDB scraper in TMM, and trakt to mark seen.
But that way i’m missing IMDB top 250.

Fix:

  • Scrape metadata for selected movies
  • Choose IMDB as the Metadata scraper
  • Remember to DESELECT ALL metadata options with the exceptions of Rating , to keep your existing metadata.
TinyMediaManager Scraper page

UPDATE:
Problems with premiered date/release date showing up as movie date in kodi? Here is my fix.

find . -type f -name '*.nfo' -print -exec sed -i -e '/<premiered>/d' {} \;

Rubber duck debugging, Pair Programming and more

Why “rubber ducking’’? While an undergraduate at Imperial College in London, Dave did a lot of work with a research assistant named Greg Pugh, one of the best developers Dave has known. For several months Greg carried around a small yellow rubber duck, which he’d place on his terminal while coding. ( From “The Pragmatic programmer” page 95)

Why rubber ducking?

A very simple but particularly useful technique for finding the cause of a problem is simply to explain it to someone else or even a object. Explain out loud (or in your mind to the duck) what each line of code is doing.
Often while doing so, you will see the problem.

Why Pair Programming?

It is no secret, i like working on a problem alone. Let me do my ‘thing’. But i like the idea of Pair Programming, why?

  • Differences in thinking, gives alternative solutions
  • 4 eyes principle, typo’s will be seen
  • When working with a novice:
    • Teaches the new guy
    • Give the other space to ask stupid questions, maybe they are NOT!
  • The knowledge of the new code is now known to > 1 person!

Wacom tablet doesn’t behave

Changed some code controlling my wacom drawing tablet.
I use this one to draw Art, diagrams and touch up photo’s.

When using multiple screens, i had the problem it would stretch the draw area over multiple screens, streching the ratio. Or it took the work screen to work on.

#!/bin/bash
# using xinput here, check post about two mouses/keyboards on one machine

# Use xrandr to check names check 
MONITOR="DP-1"
PAD_NAME='Wacom BambooFun 6x8 Pad pad'

#undo
xsetwacom --set "$PAD_NAME" Button 1 "key +ctrl +z -z -ctrl" 
xsetwacom --set "$PAD_NAME" Button 2 "key e"
xsetwacom --set "$PAD_NAME" Button 3 "key h"

ID_STYLUS=`xinput | grep "Pen stylus" | cut -f 2 | cut -c 4-5`
xinput map-to-output $ID_STYLUS $MONITOR
ID_STYLUS_2=`xinput | grep "Pen eraser" | cut -f 2 | cut -c 4-5`
xinput map-to-output $ID_STYLUS_2 $MONITOR

exit 0

Most of the times i use Krita and Gimp.

Mikrotik

Switches and access-points

Today i got my RB4011 ! Wooot!

Total tally

  • MikroTik CRS305-1G-4S+IN – Lab
  • MikroTik RB2011UiAS-RM – Office
  • MikroTik hAP AC2 – Studio
  • MikroTik CRS109-8G-1S-2HnD-IN – Attic
  • MikroTik RB4011iGS+5HacQ2HnD-IN – Livingroom
  • NEW (2022-04-02) crs125-24g-1s-in (2022-04-02)

To replace .. 4 SLM2008 and a TPLink switch 🙂

How much fun is this! .. A display on a switch!

I’ll be posting something about connecting an arduino to the serial console using a tcp server later.

Mikrotiks are all you can eat .. And there is a lot of functionality. One of the main features (besides being switches and routers)

  • Openvpn server
  • DIY display connect
  • Proxy
  • Today Vincent mentioned Mqtt plugin (2022-apr-6)
  • https://help.mikrotik.com/docs/display/ROS/Packet+Sniffer sounds interesting also

Installing extra packages

  • Download correct package zip from ( https://mikrotik.com/download )
  • Extract and use file upload
  • Reboot your mikrotik

Mikrotik Guest Network

I’ve got several AccessPoints in my network.
Using a roaming setup, clients can connect to strongest AP.

For our Folkband i’ve setup same.
With the exception of those clients only being able to connect to the Internet, and not the rest of my Network

  • Virtual Access Point
  • Own subnet
  • dhcp server only for this access point
  • NAT and Firewall rules for access limitation
/interface bridge 
add name=bridgeguest
/interface wireless security-profiles 
add authentication-types=wpa2-psk eap-methods="" management-protection=allowed mode=dynamic-keys name=guest supplicant-identity=MikroTikHAP wpa2-pre-shared-key=guestkey
/interface wireless
add disabled=no mac-address=MACADDRESS master-interface=wlan1 name=guest security-profile=guest ssid=guest station-roaming=enabled wds-default-bridge=bridge wps-mode=disabled
/ip pool
add name=guest ranges=10.5.0.2-10.5.0.250
/ip dhcp-server
add address-pool=guest disabled=no interface=bridgeguest name=dhcpserverguest
/interface bridge port
add bridge=bridgenb interface=guest
/ip address
add address=10.1.0.5/24 comment=defconf interface=ether2 network=10.1.0.0
add address=10.5.0.1/24 interface=bridgeguest network=10.5.0.0
/ip dhcp-client
/ip dhcp-server network
add address=10.5.0.0/24 dns-server=1.1.1.1 gateway=10.5.0.1
/ip dns static
add address=10.1.0.5 name=router.lan type=A
/ip firewall filter
add action=drop chain=input dst-address=10.1.0.5 dst-port=22,80,443,8291,21,23 protocol=tcp src-address=10.5.0.1-10.5.0.254
add action=drop chain=input dst-address=MYNETWORKSHERE/16 src-address=10.5.0.2-10.5.0.250
add action=drop chain=forward dst-address=MYNETWORKSHERE/16 src-address=10.5.0.2-10.5.0.250
add action=drop chain=forward dst-address=MYNETWORKSHERE/16 src-address=10.5.0.2-10.5.0.250
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
add action=accept chain=srcnat src-address=10.5.0.0/24

DDC i2c monitor control

I wanted to control the input of my monitors, these are my findings.

DDC – Display Data Channel
I2C – (Inter-Integrated Circuit, eye-squared-C), alternatively known as IIC, is a synchronous, multi-master/multi-slave (controller/target) bus

Getting monitor information with the ddccontrol -p command

##### PART OF THE OUTPUT #####
Detected monitors :
 - Device: dev:/dev/i2c-9
   DDC/CI supported: Yes
   Monitor Name: VESA standard monitor
   Input type: Digital
  (Automatically selected)
 - Device: dev:/dev/i2c-7
   DDC/CI supported: Yes
   Monitor Name: VESA standard monitor
   Input type: Digital
 - Device: dev:/dev/i2c-6
   DDC/CI supported: Yes
   Monitor Name: VESA standard monitor
   Input type: Digital
Reading EDID and initializing DDC/CI at bus dev:/dev/i2c-9...
I/O warning : failed to load external entity "/usr/share/ddccontrol-db/monitor/AOC2490.xml"

Switching inputs

ddcutil -b 7 setvcp 0x60 0x11 # 7 is Second monitor (starts with 6), 0x60 is the input register (see below) and 0x11 is HDMI
ddcutil -b 6 setvcp 0x60 0x0f # First monitor DP (Displaylink)

alternative command

ddccontrol -r 0x60 -w 15 dev:/dev/i2c-7

List the control registers

ddccontrol -d dev:/dev/i2c-6
ddccontrol version 0.6.0
Copyright 2004-2005 Oleg I. Vdovikin (oleg@cs.msu.su)
Copyright 2004-2006 Nicolas Boichat (nicolas@boichat.ch)
This program comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of this program under the terms of the GNU General Public License.

Reading EDID and initializing DDC/CI at bus dev:/dev/i2c-6...
I/O warning : failed to load external entity "/usr/share/ddccontrol-db/monitor/AOC2490.xml"
Document not parsed successfully.

EDID readings:
	Plug and Play ID: AOC2490 [VESA standard monitor]
	Input type: Analog
=============================== WARNING ===============================
There is no support for your monitor in the database, but ddccontrol is
using a basic generic profile. Many controls will not be supported, and
some controls may not work as expected.
Please update ddccontrol-db, or, if you are already using the latest
version, please send the output of the following command to
ddccontrol-users@lists.sourceforge.net:

LANG= LC_ALL= ddccontrol -p -c -d

Thank you.
=============================== WARNING ===============================

Controls (valid/current/max) [Description - Value name]:
Control 0x02: +/1/2 C [New Control Value - No changes]
Control 0x04: +/0/1 C [Restore Factory Defaults]
Control 0x05: +/0/1 C [Restore Brightness and Contrast]
Control 0x08: +/0/1 C [Restore Factory Default Color]
Control 0x10: +/90/100 C [Brightness]
Control 0x12: +/50/100 C [Contrast]
Control 0x14: +/5/13 C [???]
Control 0x16: +/50/100 C [Red maximum level]
Control 0x18: +/50/100 C [Green maximum level]
Control 0x1a: +/50/100 C [Blue maximum level]
Control 0x60: +/772/4 C [Input Source Select (Main)]
Control 0x62: +/17/100 C [Audio Speaker Volume Adjust]
Control 0x6c: +/50/100 C [Red minimum level]
Control 0x6e: +/50/100 C [Green minimum level]
Control 0x70: +/50/100 C [Blue minimum level]
Control 0xac: +/6750/65535   [???]
Control 0xae: +/6000/65535   [???]
Control 0xb2: +/1/8   [???]
Control 0xb6: +/3/8 C [???]
Control 0xc8: +/5/65302 C [???]
Control 0xc9: +/8/65535 C [???]
Control 0xcc: +/4/255   [???]
Control 0xd6: +/1/4 C [DPMS Control - On]
Control 0xdf: +/513/65535 C [???]
Control 0xfe: +/4/255   [???]

Setting volume (reg 0x62) of monitor 2

ddcutil -b 7 setvcp 0x62 0x01

AOC monitor PROBLEM

You can’t switch from an input which is not active!
So my workstation is connected via DP, and i can switch to HDMI.
Now i HAVE TO use the hdmi to switch back to DP.
A solution could be to ssh into the machine connected with HDMI (passwordless login) and switch back to DP.
I made a mqtt button sending a topic that was read by the two machines using the mqtt python program elsewhere on this site.
(Rotary Mqtt Volume control)

gddccontrol