Archive

Posts Tagged ‘automation’

How to Install Domoticz Home Automation System in NanoPi NEO and Other ARM Linux Boards

January 19th, 2017 1 comment

I’ve recently started experimenting with IoT projects, and the first hurdle is to select the hardware and software for your projects are there are simply so many options. For the hardware your first have to choose the communication protocols for your sensors and actuators, and if you are going to go with WiFi, ESP8266 is the obvious solution, used together with your favorite low cost Linux development board such as Raspberry Pi or Orange Pi to run some IoT server software locally or leveraging the cloud. But the most difficult & confusing part for me was to select the server software / cloud services as there are just so many options. I prefer having a local server than something running only in the cloud, as my Internet goes a few hours a month, so I started with a solution combining ThingSpeak with MQTT gathering data from Sonoff power switches running ESPurna firmware and vThings CO2 monitor. This works OK, but while ThingSpeak.com cloud service is continuously update, its open source version has not been updated since mid 2015. Among the many service and software framework available, one seems to have come more often than other, is supported by vThings air monitoring platforms, and recently been added to ESPurna. I’m talking about Domoticz described as:

a Home Automation system that lets you monitor and configure various device like lights, switches, various sensors/meters like temperature, rain, wind, UV, Electra, gas, water and much more. Notifications/Alerts can be sent to any mobile device.

The system can run on Linux, Mac OS, Windows on x86 platform, but also on 32-bit and 64-bit ARM Linux boards such as Raspberry Pi and Cubieboard with just 256MB memory recommended, and 200MB free hard disk space. It can also generate charts from the data like the ones below.

Click to Enlarge

On top of that, the forums appear to be very active, and the last stable version was released in November 2016, and the last beta release yesterday according the download page.

I’m going to take it slow, so today I’ve just tried to install it on NanoPi NEO since it’s compact and runs Linux. However, it does not appear to be officially supported by Domoticz, so we’ll have to see whether it’s possible to install it on the board.

Domoticz is not a Linux distributions but a framework, so first we need to install a Linux distributions on the board, and the obvious choice for NanoPi NEO is to use the latest Armbian release either Debian Jessie or Ubuntu Xenial.

I downloaded Debian, extracted the image, and flashed it to a micro SD card on a Ubuntu computer:

Replace /dev/sdX with your own SD card device, which you can find with lsblk command.  If you are a Windows user, you can flash the firmware like you’d do for a Raspberry Pi using Win32DiskImager after uncompress Armbian firmware.

Now we can insert the micro SD card into the board, and connect the power to start the board. If you have not connected the serial console to your board, please be patient for the first boot as the system may take around 3 to 4 minutes to boot before you can login to it, as it expands the micro SD card to full capacity, and creates a 128MB emergency SWAP file.

Once it’s done we can login through the serial console or SSH using root / 1234 credentials. The first time, you’ll be asked to go through the first setup, changing the root password, and creating a new user with sudo privileges.

So now that we have Linux running on the board, and after login again as the new user, we can follow the instructions for Raspberry Pi board and other ARM boards to install domoticz with a single command line that works on systems running Debian/Ubuntu:

After a minute or two, as the system update the packages, and download domoticz, the setup wizard should start.

At some points we’ll need a fixed IP address, either by configuring Linux with static IP, or setting a permanent IP linked to the board MAC address in the router. The second option is usually my favorite option. Nevertheless, let’s click on OK to proceed.

You’ll be asked whether you want to enabled HTTP or/and HTTPS access. I selected both for now, but it’s probably a good idea to only select HTTPS for better security.Next is the HTTP port number set to 8080 by default, followed by the HTTPS port number to 443 by default (no screenshot), and finally the installation folder which defaults to ~/domoticz. You should now have reached the Installation Complete! window, and you can click Ok to exit the installation wizard.
Wow.. That was easy, and no errors. But does it work? Let’s access https://192.168.0.110:443 from a web browser.

We have a “Your Connection is not secure” error, but it’s expected as Domoticz simply generated a self-certificate, you can safely add exception to your browser to avoid this issue next time. Your data will still be encrypted, but if you plan to access your Domoticz setup from the Internet, you should probably install an other certificate using Let’s Encrypt certificate authority for example.
Once we have added an exception to the web browser we can indeed access Domoticz web interface, so the installation worked, but it will only show “No favorite devices defined…” Again that’s normal, because we need to configure it for example by clicking on the Hardware link.

Adding Hardware to Domoticz – Click to Enlarge

This will allow you to configure the system with MQTT, local I2C sensors, all sort of gateways, and even Kodi Media Center.  I’m pretty sure all devices working over the network or USB should work, but things like “Local I2C Sensors” which may be connected directly to the board may or may not work. Anyway, that looks promising, but I’ll stop here for today, as I have a lot more to study before going further, including upgrading Sonoff firmware, and configuring vThings CO2 monitor for Domoticz.

Qorvo GP695 “Smart Home” SoC Integrates 802.15.4, Zigbee 3.0, Thread, and Bluetooth LE

January 4th, 2017 No comments

GreenPeak Technologies ultra-low power, short range RF communication technology company was acquired by Qorvo last year, and Qorvo has recently announced a GP695 system on chip (SoC) for smart home devices part of GreenPeak’s previous family of devices, and supporting multiple short range RF protocols.

qorvo-gp695GP695 key features:

  • MCU Core – ARM Cortex M4
  • Connectivity
    • IEEE 802.15.4
    • ZigBee 3.0
    • Thread
    • Bluetooth Low Energy (BLE)
    • Qorvo Wi-Fi interference mitigation technology

GP695 has been designed to be used in device such as a door locks, smart HVAC, smart security systems, connected video doorbells and intercoms, lightbulbs, smoke alarms, and leak detectors, and complements GP712 multi-protocol SoC designed for smart home gateways.

Qorvo will feature live demonstrations of its smart home and IoT solutions at its booth during CES 2017, at Sands Expo, Halls A-D Booth #42114. There’s very limited public information, and no product page could be found in their website.

Samsung Introduces IoT-Ready POWERbot VR7000 Robot Vacuum Cleaner Compatible with Amazon Echo

December 29th, 2016 1 comment

2017 is the year where the future starts. You’ll be wandering in your automated home or office where lights and heating system are fully handled by a gateway taking into account sensors values, and equipped with a CO2 level controlled ventilation systems, your eyes constantly looking at your phone, wearing neckband speakers likely connected to your Amazon Echo to let you know when it’s time to get up, eat, go to work, brush your teeth, and get back to bed again. All your life will be taken care of on your behalf by the Internet of Things, relieving you of the stress of taking routine daily decisions… Luckily, you’ll still be have an illusion of control thanks to your “IoT-ready” Samsung POWERbot VR7000 vacuum cleaner that can be controlled with your voice via that Echo thing, giving your life a purpose.

Click to Enlarge

Click to Enlarge

Samsung Electronics’ latest POWERbot vacuum cleaner will be unveiled at CES 2017 in January with a slimmer design (97mm), and more powerful cleaning capabilities. POWERbot VR7000 vacuum cleaner will feature “Visionary Mapping Plus” and “FullView Sensor 2.0” in order to detect obstacles and generate a map of the room, its Intelligent Power Control feature will also automatically adjusts the level of suction power to surface type (hardwood, carpet, etc…). I think it’s also the first “IoT-ready” vacuum cleaner I’ve seen, and you can control it using a mobile app, or through voice commands thanks to its compatibility with Amazon Echo. TizenExperts also reports that the device will run Tizen, and can also be integrated with the SmartThings hub. I guess you could also have some sort of dust sensor(s) to decide when to start the vacuum cleaner, beside scheduling cleaning times.

Click to Enlarge

Click to Enlarge

POWERbot VR7000 will be showcased on Samsung Electronics’ CES booth #15006, between January 5th and January 8th 2017.

vThings WiFi CO2 Monitor Quick Start Guide

December 28th, 2016 5 comments

I’ve already checked out vThings CO2 Monitor hardware and we’ve seen it’s based on ESPrino ESP8266 board, and my model includes CM1106 CO2 sensor and BMP180 temperature and pressure sensor. I’ve now installed it in my kitchen, about 3 to 4 meters from the gas stove, and getting data to ThingSpeak.

vair-monitor-co2-sensor

The door and window of my kitchen are open all day, and the wall have ventilation holes. That’s important for CM1106 sensor since it auto calibrates every 3 days in clear air. If you plan to use such sensor in a closed environment, you should buy Vthings with CM1102 CO2 sensor that costs more, but does not require calibration.

Since all WiFi systems I’ve just so far starting AP mode for configuration, I first looked for an access point, but… nothing… Then I decided to read the documentation (might be useful at times), and the monitor is actually configured via a Chrome (desktop only) add-on through USB. There are three types of devices made by vair-monitor, and I first used  vThings Configuration Utility add-on, but eventually found out I had to use vThings – Dual Beam Configuration Utility.

vthings-chrome-apps

vThings Configuration vs Things – Dual Beam Configuration Utility

I used Ubuntu (Linux), but if you are using a Windows or Mac computer, you’ll need to install drivers first. Once you’ve connected the monitor through USB and started “vThings- Device Configuration Tool” the following windows should be shown.

Click to Enlarge

Click to Enlarge

The fist thing to do is to connect the monitor to your WiFi router by entering its SSID and password, and click on Set WiFi.

Click to Enlarge

Click to Enlarge

It should connect to your router, and the first time updated the firmware automatically. Wait a couple of minutes for it to complete, and you can go to the next step to configure one or more of the following Public, Private or Generic services:

Public Private Generic
BeeBottle DomoticGa HTTP
Blynk.cc DomoticZ MQTT
dweet.io FHEM RF 433/315
EmonCMS Homeseer
ThingSpeak HomeAssistant
UbiDots JeeDom
OpenHAB
Pimatic

I decided to go with ThingSpeak since I got familiar with it while writing Sonoff POW tutorial.

Click to Enlarge

Click to Enlarge

Select the data provided by the sensors inside your vthings Co2 monitor, in my case CO2 levels, temperature, and pressure, and nothing else, or connection will fail, as I found out when I used 4 default fields including humidity, and ThingSpeak was not updated at all. You’ll also need ThingSpeak API write key, that you can get my create a channel on ThingSpeak.com as shown below.

thingspeak-co2-monitor-thingspeak-channel-configuration

Once the channels is create on ThingSpeak website, and you’ve added the API write key in vThings Device Configuration Tool, you could go to Generic Services->HTTP and notice an HTTP request has been created, so if you have installed ThingSpeak locally, you could change api.thingspeak.com to your own IP address.

Click to Enlarge

Click to Enlarge

By default the data will be updated every 120 seconds, but you can change that in Settings->Update Interval. Once configuration is done, you can unplug it from your PC, and connected to the location you want to monitor. vThings Device Configuration Tool requires a USB connection to find the device, it can not find it over WiFi, so if you want to change configuration, you’ll need to connect it back to your computer. There’s a function to (auto)start a webserver in vESPrino, but it did not seem to work for me.

After a few hours or minutes depending on your update internal you should get some nice charts on ThingSpeak with CO2 levels, temperature and pressure, or other data based on the sensors you’ve selected while purchasing the hardware.

Click to Enlarge

Click to Enlarge

The channel is public if you are interested/curious in seeing the data. ThingSpeak will show 60 samples (2 hours in my case) by default, but let’s see what happened over the last 12 hours with CO2 levels.

Click to Enlarge

Click to Enlarge

The CO2 levels started at about 500 to 600 ppm while I did the configuration in my office (windows closed), and dropped to around 404 ppm once I installed in the kitchen. That value correspond roughly to the current CO2 ppm value in the atmosphere (in Hawaii). Three times around 18h00 people warmed food and CO2 jumped to around 500 ppm. During the night, CO2 levels slowly increased to 480 ppm, likely because of the plants cycle (producing oxygen during the day, and carbon dioxide during the night). This morning CO2 levels spiked at around 900 ppm when cooking right after 6am and 8am.

That’s all fun, but is there a real benefit to measuring CO2 levels in your house? In the kitchen I could probably trigger an alert over 1,500 ppm in which case it may mean something is burning, but smoke detectors are much cheaper and better suited to the task. Vladimir Savchenko, vThings developer, found a study claiming that high CO2 levels may decrease creative thinking and lead to bad sleep, so he used vThings CO2 monitor in his bedroom and discovered CO2 levels reached close to 4,000 ppm, and that just open the door or window would greatly reduce the concentration of the gas.

sleepwithcloseddoortext-co2-levelsvThings CO2 monitor does not only monitor CO2 levels as we’ve seen above, as temperature, humidity, and/or pressure sensor can be included in the case, as well as a PM2.5 & PM10 laser dust sensor.

vThings CO2 Monitor v3 is sold for 60 Euros with CM1106 CO2 sensor, and more if you use a better CO2 sensor, or add extra environmental sensors. 135 Euros would get you a top of line monitor with a laser dust sensor, CDM7160 CO2 sensor, temperature and humidity sensor, and RF connectivity.

SmartHomy Hybrid TV Box with DTV Tuner Triples as a Game Console & Home Automation Gateway (Crowdfunding)

December 26th, 2016 24 comments

SmartHomy Homy Player is a TV box running Android TV that includes an ATSC, DVB-T2/C,DVB-S2, or ISDB-T tuner, is said to be powerful enough to be used as a 3D gaming platform, and serves as a security system and home automation gateway using Z-Wave, Bluetooth, WiFi and IR blaster to control your things.

smart-homyHomy player specifications [Updated on January 19th, 2017]:

  • SoC – Amlogic S912 octa-core Cortex A53 processor with Mali T820MP3 GPU
  • System Memory – 3 GB DDR3
  • Storage – 32 GB eMMC flash
  • Video Output – HDMI 2.0 up to 4K @ 60Hz with HDCP 2.2, HDR, CEC
  • Audio Output – HDMI and optical S/PDIF
  • Video / Audio Capabilities – 10-bit 4K H.265 @ 60 fps, HD audio pass-through, Dolby Digital & DTS licenses
  • DRM – Widevine Level 1, Microsoft PlayReader, Netflix license
  • Digital TV Tuner – DVB-S2 (satellite), DVB-C/T/T2 (Cable/Terrestrial), ATSC, and ISDB-T
  • Connectivity – Gigabit Ethernet, dual band 802.11 b/g/n/ac WiFi, Bluetooth 4.0, Z-Wave (Plus 500 series)
  • USB – 2x USB 2.0 ports
  • Dimensions – 200 x 143 x 40 mm
  • Weight – 530 grams

The device ships with Homy Remote, a backlit Bluetooth 4.0 LE remote control that includes gyroscope, and allows to control the player with voice commands. Smart Homy appears to mostly targets the US markets as seen in the comparison table with some home automation solution, media players. and game console.

smart_homy_comparison

Click to Enlarge

It would have been a little more fair to include the non-pro version of NVIDIA Shield Android TV since the price without hard drive is also $199, and it still lacks home automation support and the tuners. While you can play games with Amlogic S912 SoC, the performance will be much lower than the NVIDIA box.

In order to maximize Z-Wave interoperability, Homy Player supports more than 50 command classes for Z-Wave devices, and the player/gateway also supports more than 70 Security Devices, including common security cameras. Configuration of home automation is allegedly simplified thanks to a “patent pending” Scene Recording System where you can easily record trigger and action using your physical devices.


SmartHomy has launched Homy Player on Indiegogo (flexible funding), where the company targets to raise $59,000 or more. A $199 pledge should get you Homy Player with the remote and an extra 64GB storage. Shipping adds $30, and delivery is scheduled for July 2017. You may also get more details on SmartHomy website.

Sonoff SC WiFi Environmental Monitor mini Review

December 21st, 2016 6 comments

Yesterday I received two environmental monitors with Sonoff SC and vThings CO2 Monitor, and while I’ve plugged both, I have not had time to look into vThings documentation, but since I’m already using eWelink app for Sonoff TH16 wireless switch, setting up Sonoff SC just took me a few minutes, so I’ll report my experience with the device in this review.
sonoff-sc-usb-power-modemI powered Sonoff SC using the USB port of my modem router, and the green LED on the back of the device started to blink every 2 or 3 seconds. Then I started eWelink app in my Android phone and taped on the “+” icon to add a new device following the instructions here which are basically the same for all Sonoff devices.

Click to Enlarge

Click to Enlarge

Then you need to press the “Audio” button for about 5 seconds until the green LED blinks faster, at which point you can click Next, configure connection with your WiFi router, and complete registration by giving it a name, such as “Air Quality Monitor”.

Click to Enlarge

Click to Enlarge

Now Sonoff SC will show with your other Sonoff devices in eWelink app and show the air quality level, temperature, humidity and noise level. You can click on the > button to get to the prettier representation of the data as shown on the right screenshot above. The data was matching reality as the temperature was about 20 C at the time, and since it was still early morning, humidity was high.

Click to Enlarge

Click to Enlarge

I started to talk a bit loud, and Noise level changed from quiet to Normal. However when I turn on a headlight in to the top of the device, the light intensity was still at dusky… I took at screenshot a little later in the morning and the temperature had risen to 24°C, while humidity lowered to 53% normal, matching reality although probably not perfectly accurate due to the sensors used (e.g. DHT11).

Beside reporting data to the app, Sonoff SC can also be used as a smart hub to control other Sonoff devices. You can create “Scenes” by tapping on “…” icon in “All Devices” window, and add a condition (trigger device) using sensors from Sonoff SC or other Sonoff devices shown as “Air Quality Monitor” and “Water Pump” in the screenshot below.

Click to Enlarge

Click to Enlarge

However, while I could setup a trigger device (Sonoff SC) using the temperature data, I was not able to add an “Execute Device” despite having a Sonoff TH16 wireless switch registered with eWelink app and set in manual mode (e.g. not using external sensors to trigger it on or off).  I have a temperature and humidity sensor attached to Sonoff TH16, so maybe that’s why.. It might be only categorized as a “trigger device” and not an “execute device” despite also coming with a relay. I’ve contacted the company to see if there’s a solution.

Sonoff SC is sold for $19.99 + shipping directly on ITEAD Studio.

Sonoff SC WiFi Environmental Monitor Sells for $20

December 9th, 2016 8 comments

ITEAD Studio has done some good job with their Sonoff home automation devices based on Espressif ESP8266 WiSoC, as they are affordable, working as advertised with default firmware, and hackable with our own. The company has now added a new model, which may or may not be as useful, with Sonoff SC environmental monitor device that detects current temperature, humidity, light intensity, air quality, and sound levels, and sends the data to eWeLink app installed on your Android or iOS phone.

sonoff-scYou may be thinking it can be used as a home assistant since it really looks like a speaker and include some sort of microphone, but the top of the device is probably used to let air and dust go through.

Sonoff SC specifications:

  • WiSoc – Espressif ESP8266 Tensilica L106 processor @ 80/160 Mhz with WiFi
  • MCU – Atmel ATMega328 MCU
  • Connectivity – 802.11 b/g/n WiFi
  • Sensors
    • Sharp GP2Y1010AU0F dust sensor to detect smoke and dust
    • DHT11 temperature and humidity sensor; Range: 0 to 100 °C
    • GM5528 photo-conductive resistance
    • Electrat condenser microphone
  • Power Supply – 5V via micro USB port

esp8266-environmental-monitor

The default firmware and eWelink app also allows to set various smart scenes to trigger other devices, for example if air quality is too poor, Sonoff SC could turn on a fan connected to Sonoff wirelesss switch, or lights could be turned on when it becomes dark.

eWelink Environmental Report Card

eWelink Environmental Report Card

But you don’t have to use the default firmware if you don’t want too, as Sonoff SC’s ATMega328 controller can be programed through the Arduino IDE if you want to change the firmware, while ESP8266 is used for WiFi only. You’ll find the schematics (PDF) and Arduino code in the Wiki.

If you are interested, you can purchase Sonoff SC for $19.90 on ITEAD Studio website with shipping adding $7.33 to $17 depending on selected shipping method.

How to Build and Flash ESPurna Open Source Firmware to Sonoff POW Wireless Switch

December 3rd, 2016 31 comments

ITEAD Studio Sonoff family is comprised of various inexpensive ESP8266 WiFi power switch, and the company sent me two of their latest CE certified models with Sonoff TH16 + external temperature & humidity probe, and Sonoff POW to measure power consumption. I checked the hardware is the first part of the review, and used Sonoff TH16 to control a water pump with the stock firmware and Ewelink Android app in the second part. It works reasonably well, but it relies on the cloud, so if you lose your Internet connection or the service closed, you can’t control the relay manually anymore. Luckily, the UART pins are exposed on Sonoff switches so you can solder a 4-pin header and connect a USB to TTL to flash your own firmware.

Click to Enlarge

Click to Enlarge

Please don’t connect Sonoff devices to the mains when programming them, it’s very dangerous, instead the USB to TTL board will power the system, and will allow you to program the board safely. Later you’ll be able to update the firmware, if needed, over the network.

The next step is to select the firmware you want to use, and I’ve been advised two firmware for ESP8266, namely ESPurna specifically designed for Sonoff devices, and ESPEasy with a larger community of users. The latter may be usable to control the relay, but it has yet to support HLW8012 chip used to measure power consumption in Sonoff POW, so I decided to go with ESPurna.

That’s the description of the firmware from its bitbucket page:

ESPurna (“spark” in Catalan) is a custom C firmware for ESP8266 based smart switches. It was originally developed with the ITead Sonoff in mind. Features:

  • Asynchronous WebServer for configuration and simple relay toggle with basic authentication
  • Communication between webserver and webclient via websockets with secure ticket check
  • Flashing firmware Over-The-Air (OTA)
  • Up to 3 configurable WIFI networks, connects to the strongest signal
  • MQTT support with configurable host and topic
  • Manual switch ON/OFF with button (single click the button)
  • AP mode backup (double click the button)
  • Manual reeset the board (long click the button)
  • Visual status of the connection via the LED
  • Alexa integration (Amazon Echo or Dot) by emulating a Belkin WeMo switch
  • Support for automatic over-the-air updates through the NoFUSS Library
  • Support for DHT22 sensors
  • Support for the HLW8012 power sensor present in the Sonoff POW
  • Support for current monitoring through the EmonLiteESP Library using a non-intrusive current sensor (requires some hacking)
  • Command line configuration

I could not find firmware release for ESPurna, but Xose Pérez – the developer – has provided some basic instructions to build and flash the firmware to Sonoff. Those are not really detailed however, and it took me nearly a full day to successfully build and flash the firmware to Sonoff POW, mostly because I was not quite familiar with most of the tools used. So I’ve reproduced the step I went through in Ubuntu 16.04, and hopefully this can help people getting things done more quickly.

Let’s retrieve the source code, and enter the code directory first:

You can build the project with PlatformIO or the Arduino IDE. The instructions are for PlatformIO so that’s what I used. There are two ways to build the code with the project wither using Platform IDE for Atom and the command line, or simply using the command line. With insights, I ended up using the command line, but I’ll show both methods.

Setup PlatformIO IDE for Atom to build ESPurna

First, you’ll need to download PlatformIO IDE for Atom for your operating systems, and install it. For Ubuntu 16.04, I selected “Download .deb” for Linux and installed it through through Ubuntu Software program. Alternatively, after download, you can install it from the command line:

You can now start Atom program in Ubuntu dash, select Open Project, and browse for espurna/code directory to load the project we’ve just gotten from Bitbucket.

Click to Enlarge

Click to Enlarge

The tick button on the top left corner is to build the project, and the right button just under is to upload the firmware to the target board. But if we try to build the firmware now it will fail with an error about “espressif8266_stage”. That’s because we need to install Espressif 8266 (Stage) development platform. First we need to enable Developer mode in the IDE by going to the top menu to select PlatformIO->Settings->PlatformIO IDE, and checking “Use development version of PlatformIO“.

platformio_core_enable_development_version

Click to Enlarge

Now install PlatformIO shell commands from either a system Terminal, or PlatformIO IDE terminal (PlatformIO->Terminal->New Terminal):

and finally install ESP8266 development platform:

At this point you can click on the tick icon to build the default “node-debug” environment, a build output window will show in the IDE, and quickly disappear if the build is successful.

Setup PlatformIO via Command Line to Build ESPurna

If instead we want to use the command line we can install the latest pip version, the developer version of PlatformIO, and the staging version of ESP8266 development platform:

You can check the build environment is set properly by running the following command in espurna/code directory:

It will automatically download, build and install all dependencies and build for “node-debug” firmware for NodeMCU board. If it is successful, it will end as follows:

So I find the command line option much more easy and straightforward.

Build ESPurna for Sonoff POW

However, we are not using NodeMCU board here, but Sonoff POW, and there are two environments defined just for that:

  • sonoff-pow-debug – Build firmware to flash over serial
  • sonoff-pow-debug-ota – Build OTA firmware to upgrade the firmware over the network

The parameters for each environment are all defined in platformio.ini. First we need to build sonoff-pow-debug environment:

But it failed with an error message related to hlw8012 library:

I reported the issue on Bitbucket, but the main developer could not reproduce the issue. Eventually I found out that it could be a PlatformIO bug, as the system does not recursively checking for includes outside of main.ino. So I added <hlw8012.h> in the main.ino as follows:

and the build could complete:

Since we’ve already changed the code, you may also consider changing “#define ADMIN_PASS  fibonacci” in code/src/config/general.h to use a different default password. The password can also be changed in the web interface, but this makes sure you won’t have a device somewhere with the default password common to most users.

Flashing Firmware to Sonoff POW

Now that we’ve made sure the firmware could build, it’s time to flash it to the device.

First we need to setup some udev rules to allow flashing over serial:

Now connect the USB to TTL to a USB port on your computer, press the button (connected to GPIO0) on Sonoff POW for several seconds until both LEDs are off to make sure you are in bootloader mode, and start flashing with:

Success! Great. If you have your own firmware to flash it may be useful to know the actual command used to flash the firmware was:

Building and Flashing the ESPurna filesystem

Wait! We’ve just flashed the firmware, isn’t it all? Nope, as the webserver files are stored in another partitions, and compressed in a single index.html.gz file for better performance. The exact reasons why are further explained here.

We’ll need Node.js and gulp command line client:

Now inside espurna/code folder , we can check if building the file systems works with two commands:

Here my successful gulp attempt:

Finally, we can run the following (which also runs the two commands above) to flash the file system to the board, after entering bootloader mode by pressing the button:

Now that’s done.

A Quick look at ESPurna Web Interface

ESPurna firmware and filesystem has now been flashed to Sonoff POW. But does it work?

Click to Enlarge

Click to Enlarge

I can see a new SONOFF_POW_XXXXX access point, so that does look good. I can connect using the default password “fibonacci”, then go to my web browser to access http://192.168.4.1, and login again with admin/fibonacci credentials.

Click to Enlarge

Click to Enlarge

ESPURNA 1.03 interface goes to the status menu first, and there I can turn on and off the relay remotely, and check the power consumption in watts, which remains at 0 watt since I have not connected it to the mains yet. It’s also possible to turn the relay on and off with the button, and there an option to select whether to turn on or off the relay at boot time, which is great since I need it on at all times.

The web interface also allows you to change general parameters including the hostname and password, as well as enable or disable the HTTP API (disabled by default). The WiFi section is used to connect to up to 3 wireless routers, the MQTT section lets you configure an MQTT (Mosquito) broker, and the power section is used to calibrate the power monitoring device.

If you just intend to check the current power consumption and turn on and off the switch with your phone, you don’t have to do anything else. But I’d like to find some ways to draw daily, weekly, monthly charts of my office power consumption using either MQTT or the HTTP API. I’ll have to study how to do that, and that will hopefully be the topic of my next post about Sonoff POW.

Sonoff POW can be purchased on ITEAD Studio for $10.50 plus shipping, but is currently out of stock with the company manufacturing a third batch soon.