Cold Water

Dev

Wir bauen uns einen Feinstaubsensor

Das Projekt luftdaten.info bietet eine Bauanleitung für einen Feinstaubsensor an. Er ist günstig und auch mit wenig Elektronikkenntnissen leicht zusammenzubauen. Die Bauteile gibt es in verschiedenen Elektronikläden und mittlerweile sogar bei Amazon.

Der originale Bausatz benutzt zwei Kunststoffrohre als Gehäuse. Die sind preiswert und in jedem Baumarkt leicht zu bekommen, sehen allerdings nicht besonders ansprechend aus. Ich wählte stattdessen eine handelsübliche UV- und wetterfeste Außen-Abzweigdose als Gehäuse. Ein selbst konstruierter Rahmen aus dem 3D-Drucker wird dort hineingesetzt und die Elektronik darauf montiert.

Der Rahmen bringt bereits einen Windkanal für die angesaugte Luft mit, so dass im Gegensatz zur Originalanleitung kein Schlauch notwendig ist. Gitter vor den Luftöffnungen verhindern, dass Insekten in das Gehäuse kriechen können. Im Gegensatz zu manch anderer gedruckter Lösung ist der Feinstaubsensor außerdem wie vom Hersteller vorgeschrieben ausgerichtet und die Einsaugöffnung vor Licht geschützt.

Im Gegensatz zur Originalanleitung kommt man hier allerdings nicht darum herum, den Lötkolben in die Hand zu nehmen.

Continue reading...
Errors in GitLab SonarQube plugin

The sonar-gitlab-plugin is an useful plugin to connect SonarQube with GitLab. After pushing, the branch is inspected by SonarQube, and code smells are immediately commented in the commit.

Unfortunately, the error messages of that plugin are a little difficult to understand. It took me a while to collect this little cookbook of error fixes.

  • Unable found project for null project name
    In SonarQube, as Administrator, select the project. Then in Administration ⭢ General Settings ⭢ GitLab, enter the project ID of your project and save it. The project ID is the group name in GitLab, followed by a slash and the name of the project, e.g. shred/timemachine.

  • Unable found project for mygroup/myproject
    In SonarQube, check that the project ID is correct and there are no spelling mistakes. In GitLab, make sure that SonarQube's GitLab user is actually a member of the project, and that the user has Developer rights. I hit a strange bug in GitLab here. The SonarQube user was a member of the project, but still this error occured. When logging in as the SonarQube user, the project was not on the roll of projects. Removing and adding Developer rights to the user didn't help. The only thing that finally worked was to add the SonarQube user to a different project, even if just for a moment. It seems to be a caching problem in GitLab.

  • Multiple found projects for mygroup/myproject
    You should never see this error, but if you do, be more specific with the projectID.

Alter USB-Scanner mag keinen Strom sparen

Wieder einmal hatte ich Probleme mit meinem altgedienten Canon LiDE 20-Scanner. Diesmal wurde er zwar per USB erkannt, aber wenn ich etwas scannen wollte, erhielt ich nur Fehlermeldungen oder schwarze Seiten.

Der Grund liegt in den USB-Stromsparmaßnahmen moderner Linux-Kernel. Alte USB-Geräte haben ihre Probleme damit, einfach zwischendurch den Saft abgedreht zu bekommen.

Zum Glück kann man es bei Fedora leicht ausschalten:

echo -1 >/sys/module/usbcore/parameters/autosuspend

Der USB auto suspend ist dann für alle USB-Geräte abgeschaltet, die von jetzt an angeschlossen werden, also sollte man seinen Scanner erst danach einstecken. Beim nächsten Reboot ist der Effekt auch schon wieder vorbei.

Stream trouble

I just had a stream of objects I wanted to sort and convert to a list. Optionally it should also be limited to a maximum number of entries. Piece of cake with Java 8:

Stream<T> stream = collection.stream().sorted(comparator);
if (max >= 0) {
  stream.limit(max);
}
List<T> result = stream.collect(Collectors.toList());

Or so I thought... The code above throws an IllegalStateException at runtime, stating that the "stream has already been operated upon or closed".

The cause should be obvious. However it took me a while to find it, so I am posting it in case other people (possibly you when you came here via search engine) get stuck at the same place. Stream operations are very likely to return a different Stream object. The limit() method is such an example. In my code above, limit() operates on the stream and returns a limited stream. However I just throw away the returned stream and invoke collect() on the original stream, which was now already operated upon.

The solution is simple:

if (max >= 0) {
  stream = stream.limit(max);
}
Setting up TP-Link TL-SG108E with Linux

UPDATE: It seems that starting with hardware version 2, these switches have an actual web interface. Too sad my ones are version 1. 😢

Frankly, I didn't expect it and I was somewhat disappointed when I found out that the TP-Link TL-SG108E Easy Smart Switch (and its little brother TL-SG105E) cannot be configured via web browser. And I was even more disappointed when I found out that, even though Linux and MacOS were listed on the retail box, the configuration tool Easy Smart Configuration Utility runs on Windows only. And they mean it! When started in a Windows VM, the utility does not see any switches.

So the devices are rather cheap for a smart switch, but they still come with a price: no web interface.

However, thanks to some help in the interwebs, I was finally able to run the Configuration Utility on Fedora Linux. It's not that easy, though.

Continue reading...