Engineer’s dream – Wemos D1 mini pro arrived

New toys

It will be short this time. I have just received new set of toys from – ESP8266 chip with a few boards. At first glance it is very promising and allows for nice boxing of chips.

Unboxing Wemos D1 mini Pro - ESP8266
Wemos D1 mini Pro

What’s inside:

  • ESP8266 chip
  • temperature sensor DS18B20
  • DHT11 humidity sensor
  • SD card reader
  • LiPo charger
  • button
  • some proto boards
  •  OLED 0.66″ display

and more…


This time I am preparing some (again) weather station with openHAB integration. I will post updates with code, diagram and links to some materials if you are interested 🙂

ESP32 – Check temperature with DS18B20

One of my goals when playing with these chips is to enhance elements of smart home. One of features is measurement of home parameters including temperature. Earlier I have integrated it with Fibaro sensor, now I’ll check it with ESP32 and DS18B20.

Application setup

First step is to get empty project as described here and rename it to temperature for example. Update Makefile, set serial port and remove main.c file.

Now we need to add support for DS18B20. On GitHub there is already component which handles it but it will require minor update to compile seamlessly. Each project may contain several components organized in components subdirectory. Components are simply pieces of code which are compiled into static library and then linked into our application. Some of them are available in ESP-IDF but we can create also ours. For purpose of handling DS18B20 I used component from FeelFreeLinux, there are 2 small changes which must be applied.

cd components
git clone --recursive
cd ds18b20
mkdir include
mv ds18b20.h include

Read More

ESP32 – Hello world reinvented

In previous post I have described Hello World example coming from ESP_IDF environment. Now let’s build Hello World from the scratch.

Template application

First of all let’s grab template application. It is available on GitHub under espressif project.

cd ~/esp
git clone --recursive

Rename esp-idf-template directory to hello_world2.

mv esp-idf-template hello_world2
cd hello_world2

Edit Makefile and change value of PROJECT_NAME variable to hello_world2.

Main files of the projects are located in main directory, additional components will be located in components by default. So let’s got to main and remove source file main.c. This file contains example how to connect to wireless network and will be interesting in future. Create the easiest existing example hello_world2.c as below. Name of the file does not matter but one of source files must contain void app_main(void) function:

#include <stdio.h>

void app_main(void)
  printf("Hello world\n");

Remember to run make menuconfig to set serial flasher connection and then flash and monitor. At the end of the results you will see something like:

mode:DIO, clock div:2
ho 0 tail 12 room 4
0x40080000: _iram_start at ??:?
entry 0x40080034
0x40080034: _iram_start at ??:?
Hello world

It works. Now as general rule tasks should be created in form of endless loop and this peace of code hasn’t got loop. But task can delete themselves when finished. But where this task from app_main is deleted? When you quickly look into cpu_start.c file from esp-idf/components/esp32 folder you will see that right after app_main ends the task is deleted:

static void main_task(void* args)
    // Now that the application is about to start, disable boot watchdogs
    //Enable allocation in region where the startup stacks were located.


ESP32 – Hello world!

Environment setup

In my development I use currently MacOS. I have set up environment using  guide from Read the Docs. Jump to this page and check for update, I put quick list which is copy of their list

  1. Instal pip package manager
    sudo easy_install pip
  2. Install pyserial for accessing serial port
    sudo pip install pyserial
  3. Download ESP32 toolchain from Espressif website and extract to esp directory

    curl -O
    mkdir -p ~/esp
    cd ~/esp
    tar -xzf ~/xtensa-esp32-elf-osx-1.22.0-61-gab8375a-5.2.0.tar.gz
  4. Update your PATH variable either by creating alias or setting updating .profile file
    export PATH=$PATH:$HOME/esp/xtensa-esp32-elf/bin
  5. Get ESP32 API and libraries from Espressif’s ESP-IDF repository.
    cd ~/esp
    git clone --recursive
  6. Set IDF_PATH variable so toolchain has access to ESP-IDF
    export IDF_PATH=~/esp/esp-idf
  7. Check device name of serial connection to ESP32. As I am using Mac I run the command below twice – with unplugged and plugged board to identify correct device
    ESP32 connected to Mac
    ls /dev/tty.*

    Note name of the port as it will be needed later.

  8. When plugged check if chip is working using for example screen command
    screen /dev/tty.usbserial-DN01DXXH 115200

    Output should be similiar to

    Example output of serial from ESP32

Getting Hello World

ESP-IDF comes with several example projects, here we start traditionally with Hello World. Let’s copy it to esp directory to test it.

cd ~/esp
cp -r $IDF_PATH/examples/get-started/hello_world .

Jump to the directory and using make command execute configuration utility menuconfig.

cd ~/esp/hello_world
make menuconfig
Main menu of menuconfig

Set serial port to correct one for your machine.

Serial port configuration in menuconfig utility

Now just build, flash and see if it works

make flash
Flashing binaries to serial port /dev/tty.usbserial-DN01DXXH (app at offset 0x10000)... v2.0-beta3
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x0220
Compressed 15824 bytes to 9221...
Wrote 15824 bytes (9221 compressed) at 0x00001000 in 0.8 seconds (effective 152.2 kbit/s)...
Hash of data verified.
Compressed 355088 bytes to 167202...
Wrote 355088 bytes (167202 compressed) at 0x00010000 in 14.9 seconds (effective 191.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 82...
Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.0 seconds (effective 1548.1 kbit/s)...
Hash of data verified.
Hard resetting...

and if everything went fine

make monitor

I (1143) cpu_start: Starting scheduler on PRO CPU.
Hello world!
I (202) cpu_start: Starting scheduler on APP CPU.
This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 0, 4MB external flash
Restarting in 10 seconds...
Restarting in 9 seconds...
Restarting in 8 seconds...
Restarting in 7 seconds...
Restarting in 6 seconds...
Restarting in 5 seconds...
Restarting in 4 seconds...
Restarting in 3 seconds...
Restarting in 2 seconds...

What next

Definitely important reading is project and components structure. I will try and address it during next exercises.

Furthermore some more reading on memory and partitions and application entry points.

void app_main()
    printf("Hello world!\n");
    /* Print chip information */
    esp_chip_info_t chip_info;

It is app_main.

Coming back to reading, flashing and hopefully I’ll manage to explain it more and better.


Looking for new wifi chip


During my exercises with smart home approach and wireless devices I was playing recently mainly with Z-Wave. While Z-Wave seems nice way to connect different devices and actors to wireless network it has some weak points for me.

Z-Uno solution
href=””> Z-Uno = Arduino style with Z-Wave[/c
  • Price – Z-Wave enables devices are not very expensive however if you want to deal with something fully customised for your needs it turns out chip is more expensive. Z-Uno is nice solution but for more experiments it can be costly.
  • Inclusion/Exclusion – ok, this is smart and secure. But often when I was fighting with my toys I was facing problems, especially with battery working devices
  • No direct mobile interface – simple – you must always run a server even for a single switch at home, even if you don’t want to use it from outside. Ok, ok – this use case is stupid for smart home as it does not even touch subject of being smart. But sometimes we can see need to quick adaptation of device without playing with a server – but mobile must be trusted and device itself should report back to smart home server with update.

The best features of Z-Wave however is low energy usage and mesh. Build-in mesh solution makes Z-Wave very good solution for having many devices spread around your home. I have dozen devices working in Z-Wave and there are pros and cons… But cost and problems with range/visibility sometimes disturbs me. But indeed there are still new devices coming to the market :).


tp://”> ESP8266 WiFi chip

[/caption]Another option which I have looked at was Wifi. I made a few small experiments and did some readings. during my tests I used ESP8266. Cheap solution with great possibilities. But it is missing mesh feasibility. it is great due to the price but building micro routers on each chip and mesh functionality yourself is cumbersome and depth of mesh is very limited. If on the other side we would like to connect all devices to single router I think router would come to its limits quickly with that many connections

But still this is very nice chip :). Maybe if I found out how to build bigger and efficient mesh I would gladly come back to it.

Bluetooth”> ESP32 with Bluetooth, WiFi and more stuff[/caption]Well.

Well… for long time I was ignoring BT as I had impression it is eating batteries quickly… But this was over 15 years ago :). I was scanning specifications around and found out we have BT LTE available with piconet, scatternet, Bluetooth 5.0 with mesh around the corner. Then for a while I was sad that ESP8266 has no Bluetooth… and then I found ESP32 with everything and even more – input/outputs, WiFi, Bluetooth 4.2, LTE, CAN and more and more. It looks really interesting…


So in this situation I will keep my existing toys with Z-Wave running and try to investigate ESP32 more. And because the best way to learn something is to try to explain something someone else I will try to describe my progress with some examples and reference to interesting materials.


Is smart home smart?

For some time I have been interested in smart home subject. Finally during last months I made a few big steps and started implementing something on my own. I have started build it alone from available components from different vendors and integrated with Smarthome app coming from

Currently my system consists of some temperature , window open/close, motion sensors, plugs, dimmers, thermostats. It works, I like it. A friend of mine has similar system with much more features and scenes, I have also implemented some scenes, associations. So light on stairs automatically turns on when someone wants to go up/down, I can turn off heating/lights in kids’ room when they go out, turn off TV with equipment during sleeping time to preserve energy.

But – is such home smart?

I asked myself this question for the first time when I have added integration of IntChart to my TV plug

  • Power consumption of TV and decoder 160W
  • When XBox is up – 200W
  • Turn off 16W

Wait a second… 16W when nobody uses anything? While sleeping or outdoor? It is not smart.

Read More

Z-Uno – new toy

My new toy – Z-Uno – has just arrived. My first idea is to use it as platform for managing a few items in the kitchen – two set of lights under the shelves, monitoring temperature, humidity and pressure. But first quick glance and checking if it works

Z-Uno unpacked

According to leaflet attached it is enough to connect the board via USB cable to the computer and lights should turn on. Z-Uno comes with blinking demo sketch preloaded. Start Smorthome UI and set controller into inclussion mode and press button B three times.

Z-Uno unclussion

Z-Uno will be found and configured as dimmers. Changing value will change frequency of LED blinking – easy

Z-Uno with blink demo