All posts by flo

Hunting Network Speed

I’ve had a consumer UPC internet connection for years now. The product should deliver 75Mbit/s download and 7.5 Mbit/s upload speed.

I am monitoring the performance of my bandwidth automatically. So when UPC forced a modem ‘upgrade’ on me, I immediately knew that the performance of my connection dwindled. That was at the end of January 2018. A, until then, somewhat decent bandwidth of an average of 71 Mbit/s came down to about 40 Mbit/s.

The old cable modem was a modem only device. It was black and wall-mountable. The new modem is a white designer piece and offers full router and WiFi capabliliy. It is not wall mountable and that is slightly impractical. But I am using this WiFi capable cable modem as modem only. There is a setting that allows simple modem use, which disables all WiFi and smart-router features. I’ve my own router behind it.

The performance issues are clearly visible, after the modem has been switched at the end of January 2018

The graph clearly shows the drop in performance after the modem ‘upgrade’. One can only speculate what the reason for a little recovery in July is. In July of 2018 the performance came back – which could be due to less usage in the network, as it coincides with school holidays. I do have no proof for that though.

The speed drop is nicely seen in a heat map that plots speed by hour of the day over months.

As the speed did not improve, even after hours spent with the hotline, and multiple resets and even an active cooling attempt – I opted for another modem switch. Same type of modem – but I switched everything: modem, power supply, cables etc. This was at the beginning of December 2018.

It had no effect.

Not even actively cooling the modem did help.

To make things worse, the modem worked fine for about 12-18 hours after a power cycle. So the hotline would tell me to power-cycle the modem and connect my laptop directly to it, to test for speed. Of course it worked fine then:

classic manual power cycle at the start at 12:00, after that a stable connection for 16 hours, then an instable connection. Another manual power cycle the next day at 19:00. The firmware upgrade happened at March 25th at 12:00.

I kept mentioning the issue to a friend, who has connections to T-Mobile (UPC). He mentioned that it might not be a hardware but a firmware problem. Why the support hotline didn’t know that I will never know. I opted for a firmware update of the modem – and voilà – the connection is where it should be:

Download and upload-speed from January 2018 to Beginning of April 2019
Heatmap of Downloadspeed from January 2018 to Beginning of April 2019

It seems UPC has been distributing modems with (ancient) firmware (April 2017), that don’t fit their infrastructure any more. And instead of pushing a new working firmware to new modems, they swap brand new modems and keep customer satisfaction artificially low.

I’m happy the issue is solved now. But I’d rather spend less time debugging issues that my provider should fix on it’s own. I can’t wait for legislation that would allow customers to run their own modems!

You can find my data analysis for this blog post here (2017-09 to 2018-08) and here (2018-01 to 2019-04).

Ikea DIY Smart Smoke Detector…

Recently I confirmed that a smoke detector can be useful. I forgot a sauce on the stove and it burnt. I left the flat and luckily heard the smoke alarm from outside!

So, to be safer in the future I wanted to make a network-connected smoke detector that reports to my home-assistant instance. From there it can notify me via SMS or flash lights or sound an alarm.

By chance I found a smoke detector at IKEA. I needed to see if it can be hacked.

Ikea Smoke Detector

Test pin 4 can be used to solder the trigger to.

Good news! It can! 🙂
It turns out the micro controller that is used (CS2105G0-S12) offers a nice pin (Pin 7 – I/O) to be used for external electronics. Conveniently the PCB has a test pad (T4) that one can solder to.

On the interwebs™ I found a design that uses the internal battery of a smoke detector to power an ESP8266. I modified the layout to work for a Wemos D1 mini. Switching the transistor to a Mosfet, allowing more current to pass, was the fix.

The layout shows how the Wemos D1 mini is powered. It runs MicroPython, only when the alarm goes off. An alarm must be active for about 20-30 seconds for a message to go through. The wifi module connects to a local wifi network and sends a MQTT message to a pre-defined channel.

circuit design

The I/O-Pin 7 of the smoke detector is high at 9V when smoke is detected. The Mosfet will be switched on and the battery now powers the D1 mini as well, allowing notifications via network. The ESP8266 on the board is flashed with MicroPython. The script connects to the local wifi and notifies home-assistant via MQTT that smoke is detected. Home-Assistant does the rest.

The source of the script can be found here on gitlab or on github.

Wordclock…

I made a Wordclock with MicroPython and an ESP8266, and one with a Raspberry Pi and Python.

I gave a talk at Grazer Linuxtage about the build process. You can see the talk on CCC’s media website or on YouTube.

The slides can be found here: https://flowolf.github.io/glt18-talk.

At some point I’m planning on releasing the source code and the vector files for the Wordclock face. Have still some cleaning up to do. In the mean time: there are several word clock projects out there that use a Raspberry Pi and Python; just search for them.

cheap Chinese Z-Wave Sensors and Home Assistant…

cheap z-wave door sensor
cheap z-wave door sensor
I was looking for sensors that allow to monitor the status of a door. Typically those are magnet triggered switches that send some sort of signal when the magnet moves away and comes back. I wanted something based on Z-Wave. I’ve already light switch relays that are running on Z-Wave and am very happy with them. Z-Wave is on the pricier end of RF-devices. 433Mhz switches would be much cheaper, but Z-Wave offers nicer handling and hopefully more reliability.

Many of these sensors come in at around 40€. That is quite pricy so I opted for the cheap chinese solution at around 13.5€ per piece. You just have to be patient: 4+ weeks delivery time.

Setup into Home Assistant was straight forward. Add the device to the Z-Wave network via the web interface, rename it to mydoor… but then… How does the device report ‘door open’? The binary sensor that showed up, did nothing.

After some fiddling and searching I found that the sensor.mydoor_access_control changes it’s state rather unspectacularly from 23 to 22. It’s so inconspicuous that I didn’t notice the change the first few times I kept looking for changes.

Perfect! there is something we can use to integrate it to Home Assistant for automation and other stuff. Luckily there are templates that allow us to turn this into a binary sensor which is more useful in automations.
Add this to your configuration.yml:

1
2
3
4
5
6
7
8
9
10
11
12
binary_sensor:
  platform: template
  sensors:
    door1:
      device_class: opening
      friendly_name: 'Haustür'
      value_template: >-
        {%- if is_state("sensor.mydoor_access_control", "22") -%}
          True
        {%- else -%}
          False
        {%- endif -%}

this can then be integrated into an automation like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
automation:
  alias: "coming home"
  hide_entity: False
  trigger:
    platform: state
    entity_id: binary_sensor.door1
    from: 'off'
    to: 'on'
  condition:
    condition: sun
    after: sunset
  action:
    - service: homeassistant.turn_on
      entity_id:
        - switch.main_light

that’s it. hope this helps.

thanks to @Tinkerer from the Home Assistant chat group for the help.

Home Automation with Python…

I gave a talk at Grazer Linuxtage 2017. It’s about Home Automation and how you can use Python to realize it.

The talk covers a simple example of a DIY sensor that runs MicroPython. Finally I give a short introduction to Home Assistant, a Python Home Automation Hub, that allows you to integrate with hundreds of devices. Home Assistant offers integrations to light switches, smart lights (Hue, Trådfri, Lightify,…), door sensors, heat control units, and many others.

There is a video of my talk on my Youtube channel:

DIY MQTT smart plug with MicroPython…

I’ve been playing around with MicroPython and Home Assistant. MicroPython is a ‘bare-metal’-Python flavor that you can use to program ICs. Home Assistant is a home automation and home control software written in Python 3. It can be hosted on a Raspberry Pi. It enables you to connect a vast amount of different devices: lights, switches, sensors, locks etc.

This is a raw guide on how to make your own smart plug and connecting it to MQTT which is then connected to Home Assistant.

You will need a relay board (single relay), a NodeMCU board, a power adapter for 5V, a case, a button, some wire and a 1k resistor.

Connect the devices according to this schema (WARNING: Don’t do this if you’re not comfortable handling mains power!). Don’t forget earthing (it’s not on the diagram):
circuit diagram

Flash the MicroPython firmware to the NodeMCU board. Put the ‘relay_mqtt.py‘ file on it as main.py. That way it will be run when the device boots up. Adjust the code to connect to your network and MQTT server first.

You can download the code here.

My device looks like this:

See the Home Assistant documentation for how to integrate the MQTT part with Home Assistant.

The nice thing is: you can press the button to switch the device. The status of the device will update via MQTT and Home Assistant gets a correct status update. You can of course switch the device from within Home Assistant as well.

Happy hacking!

Jabber via TOR…

The torproject just released ‘Tor Messenger‘. It’s an instant messaging application that allows you to communicate via XMPP (jabber) over the Tor network. It is based on Instantbird.

It is important to know that the client will mask from where you are connecting, but it will NOT mask who you are! This is due to the fact that your alias at the jabber server was probably created beforehand. And even if you create the alias with Tor Messenger, your connections to other users make it possible to identify you.

If you want to chat REALLY Continue reading Jabber via TOR…