
mySailing has been moved to its new web page. Please have a look at https://mysailing.app
Software development and electronic stuff assembly

mySailing has been moved to its new web page. Please have a look at https://mysailing.app
It will be short this time. I have just received new set of toys from Nettigo.pl – ESP8266 chip with a few boards. At first glance it is very promising and allows for nice boxing of chips.
What’s inside:
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 🙂
For quite long time I have been using my “so called” smart home system based on Z-Wave device (around 20 pieces) with RazBerry and software from its web page. Additionally I used several plugins and mobile phone app on iPhone. How was it? Not bad – I could monitor house parameters, active some scenes… But I missed like hell a few features:
When playing with Smart Home I play with different chips but currently heart of my application is RazBerry2 with Z-Wave. This chip was improvement comparing to version 1 including PCB antenna. Team from z-wave.me gave however possibility to attach external antenna using connector or simply wire antenna. Continue reading RaZberry2 antenna extension
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.
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 https://github.com/feelfreelinux/ds18b20.git cd ds18b20 mkdir include mv ds18b20.h include
In previous post I have described Hello World example coming from ESP_IDF environment. Now let’s build Hello World from the scratch.
First of all let’s grab template application. It is available on GitHub under espressif project.
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf-template.git
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:
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0008,len:8 load:0x3fff0010,len:3424 load:0x40078000,len:10388 ho 0 tail 12 room 4 load:0x40080000,len:252 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
REG_CLR_BIT(TIMG_WDTCONFIG0_REG(0), TIMG_WDT_FLASHBOOT_MOD_EN_S);
REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN);
//Enable allocation in region where the startup stacks were located.
heap_alloc_enable_nonos_stack_tag();
app_main();
vTaskDelete(NULL);
}
/Rook
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
sudo easy_install pip
sudo pip install pyserial
cd curl -O https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-61-gab8375a-5.2.0.tar.gz mkdir -p ~/esp cd ~/esp tar -xzf ~/xtensa-esp32-elf-osx-1.22.0-61-gab8375a-5.2.0.tar.gz
export PATH=$PATH:$HOME/esp/xtensa-esp32-elf/bin
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
export IDF_PATH=~/esp/esp-idf
ls /dev/tty.* /dev/tty.usbserial-DN01DXXH
Note name of the port as it will be needed later.
screen /dev/tty.usbserial-DN01DXXH 115200
Example output of serial from ESP32
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
Set serial port to correct one for your machine.

Now just build, flash and see if it works
make flash Flashing binaries to serial port /dev/tty.usbserial-DN01DXXH (app at offset 0x10000)... esptool.py v2.0-beta3 Connecting...... 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. Leaving... 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...
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; esp_chip_info(&chip_info);
It is app_main.
Coming back to reading, flashing and hopefully I’ll manage to explain it more and better.
/Rook
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.

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 :).
[/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.
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.
/Rook
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 z-wave.me.
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
Wait a second… 16W when nobody uses anything? While sleeping or outdoor? It is not smart.
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
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 will be found and configured as dimmers. Changing value will change frequency of LED blinking – easy