Category Archives: Uncategorized

Build a wireless MQTT temperature and humidity sensor for your Home Assistant

Over the last months, I became more and more addicted to Home Assistant (Hass.io) and MQTT low cost wireless sensors. I was already familiar with several home and industrial automation systems that all come with a certain hardware (and price) and build upon a completely proprietary software stack. So long story short, I was searching for a good community-backed open source home automation system that is easy to set up and runs on my old Raspberry.

As home automation seems to be a broad area of interest I thought there should be hundreds of open source community projects out there. I was not as easy as I thought and there are not so many home automation projects out there. It seems as if the market is broadly dominated by large vendors that offer integrated solutions.

After some cumbersome fails I was finally able to find a real gem in the home automation area, which is called the Home Assistant, or short Hass.io. Home Assistant comes as a lightweight installation that perfectly fulfills following requirements:

  1. Its lightweight, low resource consuming
  2. Easy to set up
  3. Nice web interface, that also comes pretty well with my tablet and smartphone (no app required, responsive web UI is great on your mobile device too) See a live demo here.
  4. Lots of community components available (>1000), such as Alexa, IFTTT, Hue, Sonos, Cromecast, Webcam, and many more.
  5. Fully configurable through plaintext YAML files
  6. It comes with an integrated MQTT broker!
  7. Supports automation scripts, such as turn light on at sunset
  8. Best of all its written in Python and its open source

The first step towards building my own MQTT wireless weather station was to set up a Home Assistant instance on my old Linux laptop. If you already got Python3 running on your system, the set up process is pretty straight forward, just type:

python3 -m pip install homeassistant

After successful installation you just enter the .homeassistant configuration folder and adapt the .yaml configurations that control what your Home Assistant instance is showing and how elements are organized in Web UI.

The most important configuration files are configuration.yaml that contains the core configuration about sensors and components and groups.yaml that groups all your components into visual tabs within the UI. Within my installation i chose to use a default group, one for my living room and one for controlling my pool, as i is shown in the screenshot below:

As my screenshot already shows, my Home Assistant instance already contains some MQTT based sensors for continuously informing me about the temperature and humidity (outside, and in living room). You can put the sensor output into any of your configured tabs. The same sensor info can also be present in multiple tabs at the same time.

To add a new MQTT sensor into your core configuration file, simply add following sensor section into your core configuration.yaml file:

sensor:
  - platform: mqtt
    name: "Temperature"
    state_topic: "/home/outdoor/sensor1"
    value_template: "{{ value_json.temperature }}"
    unit_of_measurement: '°C'
  - platform: mqtt
    name: "Humidity"
    state_topic: "/home/outdoor/sensor1"
    value_template: "{{ value_json.humidity }}"
    unit_of_measurement: '%'

You can then show this newly added sensor value in any of your configured groups, as shown below:

default_view:
  name: Home
  view: yes
  entities:
    - sensor.airquality
    - sensor.temperature
    - sensor.humidity
    - sensor.yr_symbol
    - sun.sun
    - camera.mjpeg_camera
    - device_tracker.alice
    - device_tracker.bob
    - switch.robby
    - switch.lamp
indoor:
  name: Livingroom
  view: yes
  entities:
    - sensor.temperaturelivingroom
    - sensor.humiditylivingroom
    - media_player.livingroom
pool:
  name: Pool
  view: yes
  entities:
    - sensor.watertemperature
    - switch.poolcover
    - switch.poollight
    - switch.poolpump
    - switch.poolbot

Now its time to test if the sensor would show a value in case it receives an MQTT value through the configured MQTT topic. Therefore, Home Assistant offers a simple MQTT test message UI in which you can simulate any incoming MQTT message, as shown below. Just enter your MQTT topic and send a static value:

After a click on the ‘publish’ button those two values 30 and 70 will appear in your sensors for temperature and humidity. You can do that try-run for all of your MQTT bound sensors, which is a convenient feature for testing the server side functionality of your home automation.

Next step is to build a cheap temperature and humidity sensor that sends its measurements over WLAN to your Home Assistant MQTT broker. As base sensor board I decided to use an Esp32 microcontroller board that offers a cheap (~5 USD platform) with integrated WLAN stack and many digital and analog input pins. See below an image of the chosen Esp32 board:

The Esp32 board can easily be flashed over a USB cable and it runs with a standard Arduino bootloader. You can use your Arduino Studio to program your tiny Esp32 board. To measure the temperature and humidity, the combined digital DHT22 sensor was used, as shown below:

To connect the DHT22 sensor to your Esp32 board simply attach the Vin pin to the 3V pin of the Esp32 board, the Ground to any of the Ground pins and the signal pin to any of the Esp32 digital input pins.

Following Arduino code snippet shows how to initialize the DHT22 sensor and how to read and report the sensor value through a MQTT message:

#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <DHT.h>
#include <DHT_U.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>

/* Globals used for business logic only */
#define MQTT_VERSION MQTT_VERSION_3_1_1
// MQTT: ID, server IP, port, username and password
const PROGMEM char* MQTT_CLIENT_ID = "sensor2_dht22_s";
const PROGMEM uint16_t MQTT_SERVER_PORT = 1883;
// MQTT: topic
const PROGMEM char* MQTT_SENSOR_TOPIC = "/home/house/sensor1";
// sleeping time
const PROGMEM uint16_t SLEEPING_TIME_IN_SECONDS = 60; // 10 minutes x 60 seconds
// DHT - D1/GPIO5
#define DHTPIN 5

#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
WiFiClient wifiClient;
PubSubClient client(wifiClient);

/* Business logic */
// function called to publish the temperature and the humidity
void publishData(float p_temperature, float p_humidity, float p_airquality) {
    // create a JSON object
    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& root = jsonBuffer.createObject();
    // INFO: the data must be converted into a string; a problem occurs when using floats...
    root["temperature"] = (String)p_temperature;
    root["humidity"] = (String)p_humidity;
    root["airquality"] = (String)p_airquality;
    root.prettyPrintTo(Serial);
    Serial.println("");
    /*
    {
    "temperature": "23.20" ,
    "humidity": "43.70"
    }
   */
    char data[200];
    root.printTo(data, root.measureLength() + 1);
    client.publish(MQTT_SENSOR_TOPIC, data, true);
    yield();
}

setup() {
    dht.begin();
    Serial.print("INFO: Connecting to ");
    WiFi.mode(WIFI_STA);
    WiFi.begin(cconfig.ssid, cconfig.pwd);
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.println("INFO: WiFi connected");
    Serial.println("INFO: IP address: ");
    Serial.println(WiFi.localIP());
    // init the MQTT connection
    client.setServer(cconfig.mqtt, MQTT_SERVER_PORT);
}

 

void loop() {
    dht.begin();

    if (WiFi.status() != WL_CONNECTED) {
        WiFi.mode(WIFI_STA);
        WiFi.begin(cconfig.ssid, cconfig.pwd);
         
        // Reading temperature or humidity takes about 250 milliseconds!
        // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
        float h = dht.readHumidity();
        // Read temperature as Celsius (the default)
        float t = dht.readTemperature();
         
        if (isnan(h) ||isnan(t)) {
            Serial.println("ERROR: Failed to read from DHT sensor!");
        }
        else {
            publishData(t, h, aq);
        }
        delay(5000);
    }
}

Download the full source code at Github.

After connecting, flashing and running our tiny 15 USD wireless sensor we will continuously receive updates of actual temperature and humidity measurements. Those measurements are shown within your Home Assistant views. A very nice feature of Home Assistant is also that it stores historic measurements and that you can get a chart of past trends by a single click into the UI, as shown below:

Overall, Home Assistant is the perfect open source platform for your own home automation projects, no matter if you run it on your old laptop or on a tiny Raspberry Pi. It offers all the flexibility in terms of attaching any kind of MQTT sensor or message provider and is a great platform for playing around with your electronics hardware and it has a cool Web UI too!

Teach your Kids to code: Build your own OttoDIY robot

Coding is the lingua franca for all citizen in a modern technological society. By adapting any programming language your kids can learn very important skills, such as abstraction of a problem, defining and structuring a solution and to use a sequence of simple steps to fulfill complex tasks. Beside all the educational benefits of learning to use a programming language it is a lot of fun to see and experience your own programs while performing their autonomous tasks.

Another important skill within the actual technological society is to understand and control robotic hardware or electronics in general.

Nothing is more exiting for your kids as if something moves, makes a sound or blinks a lot of lights. Believe me when I say that kids are native robot and automation enthusiasts!

That said, I was really exited as I read about a vivid community of electronics and programming experts that shared the same idea of building the open educational robotics platform OttoDIY. OttoDIY offers all necessary resources, such as electronics, servos, sensors along with 3D printing models of the robot’s body parts to quickly jump into the world of electronics and robotic motion.

The OttoDIY community does share all information that is necessary to quickly print your own Otto robot and assemble the electronics.

Fortunately, the company I work for (kudos to Dynatrace) strongly supports innovation and coding for kids. Therefore, I had the chance to print our own Otto robot within the Dynatrace lab and I was astonished how easy it is to reproduce the body parts offered on thingiverse. See some impressions of the printing process below:

OttoDIY print UltimakerOttoDIY print Ultimaker

Otto’s brain arrived some weeks later and we immediately started to assemble the complete OttoDIY robot. With the assembly instructions given by Camilo Parra Palacio it was pretty easy to set the complete bot up and get it running within an hour.

One important hint here is to first check if the shipped servos do exactly fit into the dedicated sockets within your 3D print. Otherwise, you have to disassemble the complete bot again and rasp some more space.

After we assembled the complete OttoDIY bot, we downloaded the mBlock coding environment that was specifically built for kids and children. mBlock is a combination of Scratch and Arduino that allows kids to play around with physical computing and program first hardware and bots by simply using a structured visual block programming language, as it is shown below:

After some practice we finally were able to teach our Otto robot some quite cool dance moves, see below:

 

TabShop free Android Point of Sale system adds User Management

The new TabShop v142 now adds a long awaited feature to manage users such as normal cashier users and admin users who can change settings and product stock. Invoices as well as invoice prints now also show the active user which enables specific user related reports on income and revenue. Invoice CSV export as well as invoice sync with Google Spreadsheet now also shows the table and user who checked out an invoice.

Integrate remote maintenance VNC capabilities into your industrial panel

Integrating a lightweight and native Windows CE VNC server library into your embedded industrial panel easily adds remote maintenance and support functionality to your own software and embedded appliance products. By integrating MobileVNC embedded native VNC library into your own software solutions publishers of industrial panel products that are based on Windows CE save a lot of money and development time. Just integrate the simple to use WindowsCE server library by adding a native and very small footprint ARM, x86 or MIPS library and start using VNC server functionality directly within your product. You can get detailed information about the Windows CE server product here: MobileVNC.

Maker Faire visits Vienna

Maker Faire Vienna Austria LogoI was very exited to hear that the legendary Maker Faire will visit Vienna (see Maker Faire Vienna) and therefore Austria in 2016 for the very first time! Since its very beginning in 2006 Maker Faires all over the world stand for family centric festivals with a strong focus on delivering Do-it-Yourself skills to kids and adults. Its founding Make magazine represents a must-read literature for every tech loving and teaching dad (or mum). Every Maker Faire worldwide is a perfect place to meet fascinating people and their unique projects and to take part in tutorials to learn new skills and to open your mind for new ideas. Personally, I was always fascinated by the Make magazine and its community as it delivers the most positive and creative spirit cross all generations of people with the goal to open the minds to create and inspire new ideas. Make spirit not only covers areas such as electronics, coding, manufacturing but spans a much wider audience to design or art. So i am very curios how the start of the first Maker Faire in Austria will work out, but i am sure we will have a great time on 16. – 17. April 2016 in Vienna!

ruxit – Intelligent Application Performance Monitoring (APM)

Recently, dynatrace the leading technology company for reliable Application Performance Monitoring (APM) and Real User Monitoring (RUM), published their next generation SaaS based application and server performance monitoring tool ruxit. ruxit integrates state-of-the art intelligent correlation algorithms, combined with a deep understanding about the underlying software technologies, in order to detect software performance problems and their root causes. Instead of annoying and spamming the DevOps operator with a large amount of alerts and error notifications, ruxit focuses on the reduction of noise within alerting and on the intelligent interpretation of application and service performance problems. Therefore ruxit offers a must-have performance monitoring solution for service operators and DevOps. ruxit also offers a handy mobile app for receiving a filtered set of already evaluated application performance alerts on your smartphone or tablet.

ruxit application performance monitoring

 

Automate the Documentation of your Source Code

doc_finishThe SCCH research focus Software Analytics and Evolution published a nice online demonstration service today that shows the power of static analysis and automated documentation of source code. The web service allows users to submit their own programming code in order to extract mathematic formulas and structure as graphs. This online service simplifies the automated generation of source code documentation and extraction of domain knowledge for technical programms. SCCH Software Analytics and Evolution demonstrates the latest research result in the area of Software Analysis as the automated extraction of knowledge from source code as well as the dynamic query of architecture and program structure by using graph databases.

TabShop Android Point of Sale adds Bitcoin Support

image source: (http://en.wikipedia.org/wiki/Bitcoin#mediaviewer/File:Bitcoin_paper_wallet_generated_at_bitaddress.jpg)

The newest release of the Android Point of Sale App TabShop now supports the checkout by using Bitcoin QR codes. TabShop therefore automatically calculates the invoice total’s actual exchange rate in Bitcoins and generates a Bitcoin payment QR code. Bitcoin seems to be a nice addition to the ever improving domain of mobile and independent payment methods. In combination with the Android Bitcoin Wallet TabShop offers a handy Point of Sales solution for all Bitcoin enthusiasts!