Let your plant twitter if it needs to be watered

You often forget to water your plants? We already created a guide how to make sure you will be informed to water your plant when you’re coming home. But let’s try something that is a bit crazier! Wouldn’t it be cool if your plant would have it’s own Twitter account and tell you what to do?

What you need

  • one or more Mi Flora Plant sensors
  • a Raspberry Pi or PC running Home Assistant
  • a Twitter account

Installing the software

The base configuration of the Mi Plant sensor has been documented in our first flower sensor article.

Configuring the Twitter integration

If you have already a twitter account, go to apps.twitter.com and create a new App. You need to input some data and then you will get the consumer key/secret and you can create an access token.

Now, configure a notifier in your configuration.yaml file as follows:

  name: pflanzentwitter
  platform: twitter
  consumer_key: xxxxxxxxx
  consumer_secret: xxxxxxxx
  access_token: xxxxxxxx
  access_token_secret: xxxxxxx

Just copy the tokens from the developer web site into the configuration.

Create some twitter rules

Now, it your turn to find some cool post for your plant. Here is an example that I use. I’ve create a seperate automations.yaml file, that will be included in the main configuration:

- alias: Basil - sunny
    platform: numeric_state
    entity_id: sensor.basilikum_light_intensity
    above: 9800
    service: notify.pflanzentwitter
      message: "Basil: Nice sunny day today \U0001f60e"

- alias: Basil - dark
    platform: numeric_state
    entity_id: sensor.basilikum_light_intensity
    below: 100
    service: notify.pflanzentwitter
      message: "Basil: It's getting dark outside, good night! \U0001f303"

- alias: Basil - first light
    platform: numeric_state
    entity_id: sensor.basilikum_light_intensity
    above: 100
    service: notify.pflanzentwitter
      message: "Basil: Good morning! \U0001f305"

- alias: Basil - above 30 degree
    platform: numeric_state
    entity_id: sensor.basilikum_temperature
    above: 30
    service: notify.pflanzentwitter
      message: "Basil: Hot day today, it's over 30 degree celsius now. \U0001f321"

- alias: Basil - water warning 2
    platform: numeric_state
    entity_id: sensor.basilikum_moisture
    below: 25
    service: notify.pflanzentwitter
      # Cactus emoticon
      message: "Basil: What about some water for me? \U0001f335"

- alias: Basil - water warning 3
    platform: numeric_state
    entity_id: sensor.basilikum_moisture
    below: 20
    service: notify.pflanzentwitter
      # Skull emoticon
      message: "Basil: Water me or I will die of thirst. \U0001f480"

- alias: Basil - water warning 4
    platform: numeric_state
    entity_id: sensor.basilikum_moisture
    below: 10
    service: notify.pflanzentwitter
      # Skull emoticon
      message: "Basil: Help! Water! \U0001f480\U0001f480\U0001f480"

- alias: Basil - enough water
    platform: numeric_state
    entity_id: sensor.basilikum_moisture
    above: 50
    service: notify.pflanzentwitter
      message: "Basil: I'm feeling better, thank you for the water. \U0001f3a0"

You might ask yourself, what those crazy \U000xxxx numbers are? These are just emoticons. Have a look here for their unicode character codes.

Monitor your plants with Home Assistant

I love to have a lot of plants in my apartment, but unfortunately I sometimes forget to water them. So why not using modern technology to make sure, I don’t ever forget it again.

What you need

  • A Raspberry Pi or a Linux-PC with a supported Bluetooth LE interface.
  • Bluez
  • Mi Plant flower sensor for every plant
  • Home assistant


Home assistant

First you should install Home Assistant and make sure everything works well. Home assistant provides good documentation how to setup the platform.

Bluetooth software

The Linux bluetooth software might not yet be installed on your system.

Check communication with the plant sensor

The easiest way to make sure your PC can read data from the sensor is using the hcitool command line tool.

hcitool lescan
LE Scan ...
XX:XX:XX:XX:XX:XX (unknown)
XX:XX:XX:XX:XX:XX Flower mate

It might list a lot of other devices. Just make sure, it can also see the “Flower mate” device. If you can’t see this device, the distance between the flower sensor and your PC might be too large. Try moving the plant near your PC and check if it works then.

Integrate polling into Home Assistant

First, you need to poll the data from the sensor in Home Assistant:

  platform: miflora
  mac: xx:xx:xx:xx:xx:xx
  name: Flower 1
  force_update: false
   - moisture
   - light
   - temperature
   - conductivity

As the MAC address, you need to use the address that is shown in the hcitool lescan output.

Notify yourself when you come home

It doesn’t make much sense to send you a notification during the day that you should water the flowers. You might have forgotten it already when you come home. So let’s just send a notification when you come home.

Setup presence detection

Home Assistant documentation how to do this. There are a lot of different device trackers. Have a look and decide what works best for you.

Setup notifications

The next step is sending a notification to you. For this guide I use Pushetta, but Home Assistant provides a large number of notification mechanisms. Have a look at them and select the one that fits best for you.

An example notifier configuration might look like this:

  name: pushetta
  platform: pushetta
  channel_name: mychannel
  api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Define the automation

Now comes the new rule:

  alias: Alarm me to water plants
    platform: state
    entity_id: device_tracker.myname
    from: 'not_home'
    to: 'home'
    condition: numeric_state
    entity_id: sensor.flower1_moisture
    below: 20
    service: notify.pushetta
      message: 'Water Flower 1!'

What does this do? First it checks it check, if you came from (device tracker changes from not_home to home) and check then if the moisture is below a well-defined threshold. The value might be a bit different for your plant, you need to adjust this. If the moisture is too low, it sends a notification via Pushetta.

You can combine multiple plants in the condition statement or create an automation for every single plant. I personally prefer the latter as I then know exactly which plant I should water.

Long-term monitoring

It often helps to have long-term data available to optimize not only watering, but also fertilize in the right intervals. While you can store the whole history within Home assistant, it isn’t really optimized for this use case. Therefore I recommend to use InfluxDB for this. This is a time-series database specifically designed to store sensor data over a long period. To visualize the data, I use Grafana. With this, you can create nice reports like this:

Monitor CO2 levels in your house

When breathing, humans and animals increase the concentration if CO2 in the exhaled air. This is a normal biological process. In the outside this is not a problem as plants consume the additional CO2 (I’m not talking about the long-term effects of increasing CO2 concentration by burning fossil fuels).
However in closed living rooms without enough ventilation, CO2 levels can increase quite a lot. Especially modern buildings without a well-designed ventilation system can be a bit problematic. Therefore, monitoring CO2 levels in living rooms is a good idea as it gives you a good indication when you should increase the ventilation (e.g. by opening the windows for some time).

While outside CO2 levels are normally between 250 and 350ppm (parts per million), inside levels can be up to multiple 1000 ppm. You can see here that CO2 levels above 1000ppm can lead to drowsiness, poor concentration, loss of attention or increased heart rate.

An easy method to monitor CO2 levels are nondispersive infrared sensors. If you want to use a PC or Raspberry Pi a sensor with a serial interface is a good choice. The MH-Z19 features a serial interface and 3.3V power supply and IO levels. This makes is easy to connect it directly to a Raspberry Pi or to a PC (using an USB/serial converter).

Looking at the sensor from the bottom, you will see the following pins:


The pins have a 2.54mm (0.1″) pitch, that makes it easy to solder a simple one-row pin header like this:


After this, you can connect the sensor with jumper cables:


Connecting to a Raspberry Pi

You can connect the sensor directly to the 40-pin GPIO interface:

Function Pin MH-Z19 Pin RPI
VCC 6 1
GND 7 6
RX 2 8
TX 3 10

Connecting to a PC

To connect the sensor to a PC or Mac, you need an USBserial converter like this:


These converters have different pinout. Check the board that you’re using and connect VCC to 3.3V, TX to RX, RX to TX and GND to GND.


While it is quite easy to read out data from this sensor with your own software, you don’t have to be a programmer to use it.
The easiest way to use it is Home Assistant. We’ve created a small module for this sensor that you only have to activate in the configuration:

sensor 3:
  platform: mhz19
  serial_device: /dev/serial0

If you want to write your own program, you can use our pmsensor library that now also supports this CO2 sensor.

Environment measurements with the ESP8266

If you want to measure just a few environment value and send them to a central server, the ESP8266 is a great platform. And it is even cooler when I tell you that you can do it without even programming. Check out the ESP Easy firmware. This firmware allows to configure sensors and actuators connected to the ESP8266 without the need to write your own program. You can just configure the sensors in the web interface:ESPEasy1


Low costs temperature & humidity sensors

The first thing you usually start when you implement environment measurements is temperature and humidity. These are not only important for the personal comfort, but also easy to measure. Most people use DHT sensors for this. They are cheap and easy to connect to an Arduino, ESP8266 or Raspberry Pi. There are also tons of software snippets and libraries around, which makes integration very easy. How do they differ? Are there alternatives?


This sensor is the smallest of the 3 DHT versions. It has a blue color and it is the smallest of the 3. It is also the cheapest. Humidity and temperature resolutions is only full degree/%.
It can be directly soldered onto a PCB or simply plugged into a breadboard, which makes it great for initial prototypes.


This one looks similar to the DHT11, but is larger and white. Its resolution is 0.1°/0.1%. It also can be directly soldered onto a PCB or plugged into a breadboard.

AM2301 (DHT21)

This is the largest version. It comes with cables. This makes solder-free prototyping a bit challenging, but if you already have soldering equipment, this shouldn’t be an issue. The bulky design and cables makes it a good choice for bigger designs. It is especially useful if your circuit uses a lot of energy and heats up its environment.


How accurate are these sensors? As the DHT11 has only 1°/1% resolution, you might expect a lower accuracy. However, don’t mistake resolution for accuracy. We could also read the data sheets. However, I recommend checking out Robert’s page. He did a lot of measurements and found out that the DHT11’s performance is similar to the DHT22.
However, I would still recommend the AM2301 or DHT22 for another reason. While the absolute accuracy might not be perfect, the increases resolution still is helpful. There isn’t a lot of visible noise on the measurement. This helps you to understand trends a bit better. Especially in modern buildings, temperature changes very slowly. Even if you turn off the heating, it might take hours until the temperature is down by a single degree. With a 0.1% temperature resolution you see these trends much better than with 1%.

Have a look at these measurements:
It is easy to see there there is a slight downward trend in the 0.1% sensor data (green line), but it is hard to figure out if there is any trend in the 1% sensor data (orange line).


I’ve read some remarks on the internet about defective sensors. For a long time I never had issues, but when I moved a prototype on a breadboard to another room, the measurements looked like this:
Screenshot 2016-08-01 09.58.35
This is clearly not correct. The new measurements show so much noise that they are basically useless. It seems that the sensor had been damaged somehow. I’m not sure, if the reason was ESD or anything else happened.


I would not recommend the DHT11 for any real-world measurements in home automation as the 1°/1% resolution is problematic. Depending on your use case, choose between the DHT21 and DHT22. Make sure you mount the sensor away from any part that dissipates heat. Otherwise your measurements will be completely wrong!

Connecting a particulate matter sensor to your PC or Mac

I’ve written before about what particulate matter sensors are and how they work. Many of these sensors come with a tiny 8-pin connector. With some luck, you even find an English data sheet. But you might just end up with a Chinese one. It might look like this:


Luckily, most signals have english names:


Ok, that’s all we need to know to connect this thing to a PC. You can see that the supply voltage is 5V and the I/O voltage is 3.3V. That’s perfect for most use cases. You also see that there is some kind of serial interface RX/TX and a SET and RESET input.

What do you need? The only thing you need is a USB to Serial (TTL) adapter. The come in different variants and might look like this:

usbser1 usbser2


Before buying check 2 things: The adapter should offer 5V AND 3.3V power outputs (for this project we only need 5V, but you might need the 3.3V for other projects) and have a DTR output (we will use this to turn the sensor on and off).

Now connect the sensor to the adapter as follows:

 VCC pin 1  5V
 GND pin 2 GND
 TX pin 4  RX
 RESET  pin 6  DTR

Note that the pin numbers are for the specific sensor shown above. Check the data sheet of your sensor, the pins might be different!

Why isn’t RX not connected? All the dust sensors I’ve seen do not use this signal at all. If it isn’t used, there is no need to connect it (but you can do if you like).

Finally this will look like this:


You can now connect this to you PC or Mac and read data from the sensor. We will show in another article how to do this.

Measuring air quality

When people think about comfort in their apartment, most people think first about temperature. But another important factor is air quality. I don’t have to tell you that smells from cooking aren’t always the best. There are much more particles in the air that impact the quality. These particles are generally named “Particulate matter”. The EPA defines PM as follows:

“Particulate matter, or PM, is the term for particles found in the air, including dust, dirt, soot, smoke, and liquid droplets. Particles can be suspended in the air for long periods of time. Some particles are large or dark enough to be seen as soot or smoke. Others are so small that individually they can only be detected with an electron microscope. ”

Today, most measurements you find are PM2.5 measurements. This measures particles smaller than 2.5µm. Roughly one out of every three people in the United States is at a higher risk of experiencing PM2.5 related health effects.

Do you know the PM2.5 values in your living environment? Most likely not, but it is relatively easy and cheap to do do these measurements today. While calibrated sensors is still very expensive, for home-use uncalibrated sensors do a good job to give you a rough idea about possible problems.

These sensors work as follows:


A light sends light into an air flow. Small particles will reflect the light. A receiver than measures these reflections. Seems very simple – right? It really is. The cheapest sensors are available for less than $20 on Chinese shopping sites. They use LEDs as a light source. Laser-based devices are a bit more expensive ($50 and up), but they can detect smaller particles.

Let’s have a look about a laser-based sensor like this:


The fan creates an continuos air flow through the device. Looking into the device you see the air channel and the detector.


The detector looks like this:

What else is inside?

This is the simple PCB. It is based on a small microcontroller and some external components.

The good thing about these (more expensive) sensors is that they already do the hard work for you. They have a serial output that already sends the PM1.0, PM2.5 and PM10 values.

You can use a simple USB-to-Serial converter and read the data directly from your PC. How to connect this sensor to the adapter is shown here.


Home Hack: Wifi Enabled Dog Flap/Treat Dispenser/Feeder

Every dog-owner knows the struggles of making it home in time to let the pup out, or the agony of waking up at 4am to let the Labrador outside to answer nature’s call. Well, there is good news to be heard. Wi-Fi enabled dog flaps and feeding dispensers are about to solve the most common problem known to the common pet owners.

Finding someone to pet-sit or look in your animals, whether it be a neighbour or a professional service used to involve someone else’s time and money. However, a new life-hack has revolutionised this and taken out the middle man, or in this case, your next-door neighbour who you have never really gotten to know.  Dog-flaps and feeders are now being connected to home networks and controlled by their owners from across the country when they are too busy to come home. Now, from the touch of your smartphone, you can control when and where your pet is allowed to go outside without having to leave the office.
pintofeedPintofeed is just one of the many automatic food dispensers on the domestic pet market that is controlled by its own app on your iOS, Android or Windows 8 smartphone. Once connected to Wi-Fi, you can dictate as and when the dispenser releases food for your pet, and as the app has numerous personal features, it can create feeding schedules based on your typical feeding times. It can even set up reminders to ensure your pet doesn’t miss a meal.
Similarly, with dog flaps, brands such as PetSafe have created various devices that can be controlled externally. The dog-flap is connected to your home internet and mobile or tablet, and can be opened or locked at the owner’s desire. There is also the option of having a chip implanted in the dog’s collar which can connect to the dog-flap when your pet is within a certain radius. It is then activated to open when your pet attempts to exit the home and prevents unwanted neighbourhood creatures wandering into your home.

The products and technology are becoming even more sophisticated, with in-built webcams fitted in the dispensers with a live feed to your phone, allowing you to keep tabs on your animals at any time of day. It is paving the way for single pet-owners who do not have the funds or means of employing somebody else to care for their animals to no longer schedule their life, businesses and affairs around their pets.

Cool sensors for your next automation project

Home automation isn’t about controlling a lamp with your smartphone. It is called “automation”. A home automation software should do things automatically. Do do this, it needs to have an idea what’s going on in your apartment (or outside). For this, you need sensors. While some sensor types are well-known you might not know what is available already on the market for a small budget. The following sensors can be integrated easily with your Arduino, EPS8266 or Raspberry Pi.


35040-img_0674Almost everybody already did experiments with temperature sensors. The DS18B20 is a 1-Wire sensor that can be connected easily to many platforms. You will find a lot of code snippets for this sensor already. It has a 0.5 degree celsius accuracy which is more than enough for most use cases. If you only want to monitor the temperature, go for this one.


dht-11-1The DHT-11 and DHT-22 are two sensors that combine a temperature sensor with a humidity sensor. Both are more expensive than a simple temperature sensor. However, humidity informations might help you to do better automatisations. One use case could be turning on an air humidifier when the humidity is too low. Another would be opening windows, when humidity is too high. While these sensors also use a 1-Wire-type protocol, it is different from the 18B20 sensor. You can’t connect both sensors to the same GPIO. However as the DHT-11 has the temperature sensor already included, there is no need for an additional 18B20.

Soil moisture

13995201090You’re plant are dying regularly because you forget to water them? Another use case for a sensor. Soil moisture sensors are available in 2 variants: the cheap sensors just measure the soil resistance. The problem with this sensor type is corrosion (over a longer lifetime). Capacitive sensors are becoming more popular and don’t show this problem as the electrodes are isolated. However, they are more expensive and a bit less sensitive. You need to experiment a bit to find the correct threshold for alarming.

Motion detection

pir-motion-sensor-536x408You want to know if somebody is home? PIR motion sensors are also available for a few bucks and will give you information about people (or pets) moving. If somebody is just sitting or sleeping, the motion sensor won’t detect this. However, for many use cases this is just fine.

Sound pressure

grove-Sound-SensorYou’re not at home, but your teenage son. What do you think will happen? A party! Your neighbors will tell you tomorrow. Wouldn’t it be cool to automatically reduce the volume of your stereo system when the volume exceeds a specific level? This level might be higher at 5pm than at 11pm. A sound pressure sensor will do the job – at least until your son finds our where it is located and puts some damping onto it.

Small particles

Particle sensorSmall particles in the air can be a problem for some people – especially if you suffer from asthma. These emissions can come from various sources. Measuring the number of small particles in the air might give you an idea what might be the source and do something against it. These sensors are based on optical measurements. While this might sound complicated, sensors like this are not very expensive anymore.

Accessing your Home assistant installation outside your house

Having a home automation solution that is only available inside your house might work for some people, but most people want to control their home also form the outside.

There are different options to achieve this in a secure way.


IC196810Using a VPN is usually the most secure solution. Even if there is a major security bug in your Home Assistant installation, attackers still can’t compromise your system as it isn’t publicly available on the internet. Many ISP’s today already provide a VPN service. You need to check with your ISP if it is available and how to configure it.

The disadvantage of a VPN is that you have to connect to the VPN first. This becomes an even bigger issue, if you use 3rd party applications (e.g. device trackers) that want to connect to your Home Assistant server. If the VPN isn’t connected, they will fail and some status informations might not be updated correctly.


Using a public HTTPS server is not the most secure solution, but still ok in general. Just note that you have to always check for security problems and update your Home Assistant installation regularly.

letsencryptFor HTTPS you will need certificates. A simple and free option today is Let’s encrypt. There is already a guide on the home assistant web site that shows how to use Home Assistant with Let’s Encrypt.

An additional security improvement can be implemented by using a web application firewall in front of the web server. While you can do this by yourself, it it quite complicated. Another option is using Cloudflare.  While you can’t use your own rules in the free version, it will still provide some basic security and protection against general attack patterns.

Comparison of both variants

Security Highest, as your system is protected even in case of security flaws in Home Assistant Ok, but you need to make sure that you regularly patch Home Assistant
Ease of setup Relatively easy if your ISP already offers it, otherwise complicated Medium, guides are available
Ease of use  Medium, you always have to connect the VPN first Very easy