(Deutsch) Lost Places: Glaswerk Ilmenau, Teil 2, Neubau

Sorry, this entry is only available in Deutsch.

Posted in Foto | Leave a comment

Lost places: Glaswerk Ilmenau, Teil 1: Übersicht

Lost places ist eine Kategorie in der Fotografie, bei der “vom Menschen verlassene Orte” fotografisch in Szene gesetzt werden. Dabei wird dokumentiert, was ist. Es wird nichts verändert oder arrangiert.

Posted in Foto | 2 Comments

WiFi power plug with temperature sensor

Im ersten Teil habe ich vorgestellt, wie eine WLAN-Steckdose vom Amazon einfach mit einer eigenen Firmware umzuprogrammieren geht, dass sie per MQTT an die eigene Hausutomatisierung andockt und dabei die Hersteller-Cloud los wird. Ein schönes Feature dieses Steckdosentyps ist dabei ein herausgeführter freier Pin am Controller, den ich benutzen möchte, um daran einen digitalen Temperaturfühler anzuschließen. Die Steckdosen hatte ich unter dem Handelsnamen Arrinew erworben, aber inzwischen gibt es diese nicht mehr. Dafür ist der Typ unter einer Reihe anderer Handelsnahmen aufgetaucht: Expower, Horsky, Elegiant, Allomn, Mopoin… Wir werden sicher noch zahlreiche andere Namen sehen. Es gibt in China Hersteller, die den Cloud-Service zu diesen Steckdosen vermieten, so dass sich im Prinzip jeder kleienrer Händler ein paar hunderttausend der Dinger mit eigenen Namen ordern kann. Allerdings sollte man bei diesem Geschäftsmodell schon Bedenken bekommen, da die Dosen mit der Original Firmware nur zusammen mit der Cloud funktionieren. Packt der Zwischenhändler ein und bezahlt den Cloud-Serive nicht weiter, dass ist Schluß mit WLAN und Alexa und Co. Aber das braucht uns nicht weiter zu stören, wir spielen ja sowieso auf sowas immer erstmal eine eigene Firmware auf 🙂

DS18B20 Schaltkreis

Aber nun zur Sache: Wir benutzen einen Dallas DS18B20 (oder den etwas genaueren DS18S20, aber das ist eigentlich Perlen für die Säue, siehe unten). Diesen gibt es als Chip in bedrahteten TO-92 Gehäuse oder auch (sogar mehr oder weniger wasserdicht) eingebaut in einer Hülse mit Kabel bei reichelt oder AliExpress. Der Chip misst intern die Temperatur und stellt diese schon digital bereit. Er hat einen sogenannten 1-wire-Bus, er wird also über eine einzige Datenleitung angesprochen. Das ist also perfekt für uns. Im Prinzip kann man über diese eine Datenleitung auch mehrere Sensoren parallel schalten und per Software einzeln adressieren. Ich sehe dafür aber momentan hier keine sinnvolle Anwendung.

Bauformen des DS18B20 Temperatursensors, IC oder gekapselte Version mit Leitung

Der Sensor benötigt neben seiner Datenleitung auch noch eine Versorgungsspannung (zwischen 3 und +5V) und natürlich Ground. Das nachfolgende Bild zeigt, wie man den Beschaltung in der WLAN-Dose machen kann.

Da ich den Sensor an die besser belastbaren 5V angeschlossen habe, schalte ich zum Datenpin (3.3V-Pegel) noch einen Schutzwiderstand (ca. 470 Ohm) in Reihe.

Verdrahtung des Temperatursensors, rot=5V, gelb=Daten, weiß/grün=Masse

Die Sache mit der Luft-Temperaturmessung ist nicht so einfach, wie man gemein hin annimmt. Die Luft hat an unterschiedlichen Stellen im Raum messbar andere Temperaturen (vertikale Schichtung, Nähe zu Gegenständen mit anderer Temperatur, unterschiedliche Luftströmungen etc.). Es macht daher keinen Sinn, es mit der Genauigkeit übertreiben zu wollen. Na gut, auf 1K genau sollte man irgendwie anstreben. Wenn man es etwas präzise haben will, kommt man um einen der oben gezeigten drahtgebundenen gekapselten Fühler nicht herum. Diesen kann man an der interessierenden Messstelle hinbaumeln. Mir war das aber zu viel Trödel, die Dose mit einem solchen “Schwanz” zu versehen. So habe ich einen der TO-92-Gehäuse direkt in das Gehäuse, oder besser gesagt auf das Gehäuse gebaut.

Ungeeignete Position des Sensors, hier wird die Dose zu warm

Und hier lauerte eine böse Falle. Ursprünglich habe ich den Sensor am Rand auf Höhe des leuchtenden Tasters positioniert. Darunter befindet sich aber Elektronik, die das Gehäuse deutlich erwärmt. Dieser Sensor zeigte dann auch meist über 30°C, was dann doch bei 22° Raumtemperatur etwas unangemessen ist. Eine Verlegung des Sensors auf die Elektronik-abgewande Seite der Steckdose behebt das dann. Hier zeigt der Sensor auf etwa 0.5K die Raumtemperatur, die auch ein anderer im Raum positionerter Sensor zeigt. Das macht Sinn.

Mögliche Position des Sensors

Wer brauchts? Erstmal ist es immer schön, eine Raumtemperatur in der Home-Automatisierung angezeigt zu bekommen. Vor allem Sinn macht das aber, wenn die Steckdose einen Lüfter, Raumheizkörper oder ähnliches schaltet, weil man hier sowieso die Raumtemperatur kontrollieren oder zumindest im Blick haben möchte.

Wer brauchts? Erstmal ist es immer schön, eine Raumtemperatur in der Home-Automatisierung angezeigt zu bekommen. Vor allem Sinn macht das aber, wenn die Steckdose einen Lüfter, Raumheizkörper oder ähnliches schaltet, weil man hier sowieso die Raumtemperatur kontrollieren oder zumindest im Blick haben möchte.

Posted in home automation | Tagged , | Leave a comment

Arrinew / SWA1 WiFi power switch

With home automation more early than later this cheap WiFi power switches come into the game. I use (and build up continuously) a home automation system based on Home assistant (hass) and was looking for a possibility to switch on and off two lamps for plants (yes, also for my Chili plantage 😉 ).

This Wifi switches usually connect to their producers cloud service. All commands go first from the house over the internet to the server and than back over the internet to the switch. This is an easy to establish but very ugly thing. First, nobody else has any right to know, what in my house is controled and second, if the Internet connection or the producers server is down, the system doesn’t work. And beleave me, this is more often the case as someone may assume.

But fortunately nearly all WiFi power switches use the same chip and they can usually programed with an own or alternative firmware so they never have to see their cloud service in their whole life. So, my own home automation system takes over the role of the producers cloud.

At the German Amazon site I found a cheap pair of such WiFi power switches which are sold unter the label “Arrinew”. I think, their may be sold also under various other labels. Therefore, more unique is the model “SWA1” and the label on the internal PCB board 101-SWA1351-361

This power switches have realy a good mechanical quality. Also the electronics inside looks very significant. Unbeleaveable what they sell for under 10,-€/piece.

Who want’s to read further should know what an ESP8266 is and also MQTT should be a known concept.

The objective of this article is to replace the firmware of the power switch with an own program to integrate it into my own hosted home automation system. There are principially two ways: Use of one of the free operating systems for ESP-family (Takoma, EasyESP) or write an own software with the Arduino libraries and environment. Because I want learn a little bit, I like transparency and doesn’t like to struggle with various problems of the ESP-operating systems and finaly because I found a good example for such a firmware, I choose the second way and set up an own firmware.

The Arrinew power switches are prepared to be programmed in such a way that the required contacts are internally available. But they are not proper labeled and the ESP-chip is covered by a metal plate, so that the contacts cannot be followed visually or a continuitiy check. Luckily by googling the PCB board label I found this page where somebody has done great work by hacking these information.

An interesting detail is further that there is also an unused GPIO-pin available. Because there are never enough temperature sensors spreaded in the house this pin asks for beeing used to connect a digital one wire temperatur sensor. But this is a topic for another post.

As mentioned, the program for the power switch I have also stolen from Matt and have it a little bit modified. Now, it looks so:


// Flash mode: DOUT
// Flash Frequency: 40MHz
// Flash Size: 1MB (512kB SPIFFS)
// Reset method: None
// Crystal Frequency: 26MHz
// CPU frequency: 160MHz
// Upload speed: 921600

// Button: GPIO13
// Blue LED: GPIO4
// Red LED + Relay: GPIO5
// Extra Pin: GPIO14, used foor one-wire temperaure sensor

#include <ESP8266WiFiMulti.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
#include <DebouncedInput.h>
#include <OneWire.h>
#include <DallasTemperature.h>


ESP8266WiFiMulti wifiMulti;
WiFiClient espClient;
PubSubClient client(espClient);

#define ONE_WIRE_BUS 14  // DS18B20 pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);


bool powerState = false;
unsigned long previousMillis=0;

#define NAME "name for OTA"
#define OTAPW "password for OTA updates"
#define BROKERUSER "MQTT broker user"
#define BROKERPASS "MQTT broker password"

// define here your MQTT topics
#define SUBTOPIC "/powerplugs/switch02/command"
#define PUBTOPIC "/powerplugs/switch02/status"
#define TEMPTOPIC "/powerplugs/switch02/temp"

#define POWERPIN 5
#define BUTTONPIN 13
#define LEDPIN 4
#define TEMP_INTERVALL 10000  // temperature is measured every 10s

DebouncedInput button(BUTTONPIN, 10, true);

void callback(char *topic, byte *payload, unsigned int length) {
    if (!strcmp(topic, SUBTOPIC)) {
        if (!strncmp((char *)payload, "on", length)) {
            digitalWrite(POWERPIN, HIGH);
            powerState = true;
            client.publish(PUBTOPIC, "on", true);
        } else if (!strncmp((char *)payload, "off", length)) {
            digitalWrite(POWERPIN, LOW);
            powerState = false;
            client.publish(PUBTOPIC, "off", true);
        }
    }
}

void setup() {
    button.begin();

    WiFi.mode(WIFI_STA);

    pinMode(POWERPIN, OUTPUT);
    pinMode(LEDPIN, OUTPUT);
    digitalWrite(POWERPIN, LOW);
    digitalWrite(LEDPIN, LOW);

    client.setServer("IP of your MQTT broker", 1883);
    client.setCallback(callback);

    // Add more of these for access to more APs.
    wifiMulti.addAP("WiFi name", "WiFi password");

    ArduinoOTA.setHostname(NAME);
    ArduinoOTA.setPassword(OTAPW);
    ArduinoOTA.begin();

    DS18B20.begin();
}

void loop() 
{
    static uint32_t ts = millis();
    ArduinoOTA.handle();
    client.loop();

    if (wifiMulti.run() != WL_CONNECTED) {
        delay(100);
    } else {
        if (!client.connected()) {
            delay(100);
            if (client.connect(NAME, BROKERUSER, BROKERPASS)) {
                client.subscribe(SUBTOPIC);
            }
        } else {
            if (millis() - ts >= 5000) {
                ts = millis();
                client.publish(PUBTOPIC, powerState ? "on" : "off", true);
            }
        }
    }

    if (button.changedTo(LOW)) {
        powerState = !powerState;
        digitalWrite(POWERPIN, powerState);
        if (client.connected()) {
            client.publish(PUBTOPIC, powerState ? "on" : "off", true);
        }
    }

    digitalWrite(LEDPIN, !client.connected());

  unsigned long currentMillis = millis();
 
  // if you don't use the temperature sensor, comment out the following block
  if(client.connected() && (currentMillis - previousMillis) > TEMP_INTERVALL){
    char h[20];
    float temp;
    DS18B20.requestTemperatures(); 
    temp = DS18B20.getTempCByIndex(0);
    sprintf(h,"%.1f",temp);
    client.publish(TEMPTOPIC,h,true);
    previousMillis=currentMillis;
  }

}

To compile and program this software the Arduino-IDE can be used. There are countless instructions and tutorials. Thanks of the used libraries the code is fairly short.

The following things are worth to be to be mentioned:
Folgende Sachen sind mir aufgefallen:

  • There are two LEDs available. The blue LED is on if the power switch has a connection to the MQTT broker (WiFi works, MQTT broker is available). This is also a good indicator, if the home automation runs. the second LED is red an is on if the power of the plug is switched on.
  • The Arduino library has at least in some conditions problems to resolve local hostnames (from the Fritzbox router) . I had to enter the IP-number of the MQTT broker instead their hostname.
  • The WiFi-Name it case sensitiv
  • The power switch needs as MPTT payload “on” and “off”. But this can be changed in the source code.
Posted in home automation | Tagged , , | 1 Comment

Nightly visitors in the garden

For some month we have observed that one time a week someone opens the heavy cover of our composter, in which we deposit our organic kitchen waste. The cover is not so lightwight and it realy needs some power to open it. The visitor must be much stronger than a cat.

The grey box is the composter of this story

Long time we thought, we know the lad. One time on a late evening in winter our neighbor entered his kitchen balcony and someone hissed beside him. A racoon ()yes, they are new in the area) has eaten bird feed and didn’t enjoy the disturbing. Clear, the racoon eats also our organic kitchen waste. Or?

Now, my brother in law lents me a wild camera, and yes, this should be a handy tool to monitor our visitor.

OK, that isn’t a racoon. Looks like a fox like our kitchen waste. (I think in this video he took a piece of bread)

Foxes in the vegetable garden are not so a nice thing. Some of them carries fox-tapeworms what we definitely don’t want in our vegetables. So we decide to make visits less attractive by putting heavy stones at the composter cover (see the pic above).

As it can be seen, the fox don’t like the idea with the stomes and give up.

two days he thought about the problem. Then he came back:

Foxes are very clever animals (or pets in this case 😉 )

But, it seems too annoying. That was the last time we saw him on the box. One time he came back hunting a bird. The wild camera has taken no further video from him.

Posted in Allgemein | Comments Off on Nightly visitors in the garden