Archive

Posts Tagged ‘esp8266’

How to use Sonoff POW with ESPurna Firmware and Domoticz Home Automation System

January 21st, 2017 10 comments

Sonoff POW is an ESP8266 based wireless switch with a power meter that comes pre-loaded with a closed-source firmware that works with eWelink app for Android or iOS by default. But we’ve also seen Sonoff POW, and other Sonoff wireless switches from the same family, can be flash with open source firmware supporting MQTT (Message Queuing Telemetry Transport) lightweight messaging protocol such as ESPurna, and I initially sent data from Sonoff POW to ThingSpeak via an MQTT broker (mosquitto) to draw some pretty charts. I did that with the switch connected to a lightbulb, but I’ve since installed Sonoff POW in my office to measure the room’s power consumption minus the ceiling light and aircon as shown below.

Wall Mounted Sonoff POW WiFi Switch – Click to Enlarge

Sonoff cable mechanism is really a pain for hard copper wires, as they are hard to push inside the mechanism, and something come out. I finally managed by it took longer than expected to install. I had to cut the mains cable, and rewire the gang box too. The good thing is that I did not need to drill a hole in my wall, as the device is very light.

I could see the power value updated in ESPurna web interface, depending on the load on my computer, and whether I turned on or off other devices. That’s all good, but instead of using ThingSpeak, whose open source implementation is not updated, I decided to try Domoticz, and already wrote a short guide showing how install Domoticz in NanoPi NEO ARM Linux development board. I had not gone through the setup yet, as I had to study a little more, and upgrade Sonoff POW firmware first. I also planned to use vThings CO2 monitor with Domoticz, but canceled since it can’t be configured remotely, and a USB connection is needed.

ESPurna OTA Firmware Update

So I’ll focus only on Sonoff POW in this post, and first we need to update the firmware since Domoticz support is only recent. I’ll assume you have already followed the post entitled How to Build and Flash ESPurna Open Source Firmware to Sonoff POW Wireless Switch.

First we need to update platformio and ESP8266 development platform to the latest version otherwise we’ll get some build issues:

I updated the source code with git pull, but for whatever reasons the build failed, even after cleaning the code. So I did what any developer with enough experience would do in that case: start with a fresh check out ;), and rebuild the OTA firmware from there:

In order to update the firmware over the network, you’ll need to change sonoff-pow-debug-ota section in platformio.ini with your own IP address (upload_port) and password (in upload_flags) used in ESPurna web interface:

Once it’s done, you can upgrade the firmware, and then the file system as follows:

The Sonoff POW will reboot, and cut the power for about 2 seconds after both updates. My Sonoff POW is controlling my computer power, but that’s OK since I’m behind a UPS. Now I can access the web interface, and one of the improvement is that you’re being asked to setup a new password right after the update.

Click to Enlarge

I was then redirected to the Status page showing power, voltage (a bit low?), current, and power factor.

Click to Enlarge

I then jumped to MQTT menu to set the IP address to my NanoPi NEO board, and clicked Update.

Click to Enlarge

There’s a new DOMOTICZ menu which we’ll check out a little later.

Installing and Configuring MQTT in Domoticz

ESPurna communicates with Domoticz via MQTT, so the first task was to follow and adapt Domoticz MQTT wiki.

First login to your Domoticz server (NanoPi NEO) and access a terminal window to update the packages, install npm, node.js, Node RED, and mosquitto:

We then need to go to the Hardware page in Domoticz and configure a new “MQTT Client Gateway with LAN Interface” as shown in the screenshot below.

Click to Enlarge

We can test whether it works or not by creating a new Dummy device in the same Hardware section

Then click on Create Virtual Sensors, to add a new Temperature sensor which we’ll call Fictive Temp.

Now go to the list of Devices (Setup->Devices) to check the idx value (1 in our case), and a publish a MQTT message to update the temperature value of our virtual sensor:

The temperature switch from 0 to 25°C. Our installation is working. Great!

Using Sonoff POW with Domoticz

In theory, we should be able to get two type of data for Sonoff POW: relay status and power levels. However, after looking at ESPurna source code, domoticz.ino only seems to handle the relay status that can be changed from Domoticz web interface, but the power values are only send in pow.ino to the MQTT server, with data not directly compatible with Domoticz. Maybe I missed something as Tinkerman – ESPurna developer – can use Sonoff SC to send temperature data to Domoticz. Alternatively, it might be possible to convert that data somehow with Node RED, but that’s something I’ll try later. So today, I’ll only try to control the switch from Domoticz.

To do so, I created another Dummy device called Sonoff POW Switch, and from there, another Virtual Sensor of Switch type.

Click to Enlarge

Click to Enlarge

We’ve already configured MQTT in ESPurna web interface, and from the screenshot above,we can see that “Sonoff POW Switch” Idx is 3, a value we need to update in the DOMOTICZ section of ESPurna web interface.

Now I can go Domoticz interface in my phone, and not my computer since my office’s Ethernet switch will be turned off, click on the Switch tab, and turn on and off Sonoff POW by clicking on the lightbulb as shown below.

Click to Enlarge

It works fine, however note that the initial switch status was wrong (off instead on on), despite the switch sending regular updates to the MQTT server.

NanoPi NEO Power Adjustments and Installation

Normally, at this stage, it should be easy simply install NanoPi NEO outside the office close to my router in the living room. But I’ve come across a few issues doing so, which I’m going to report.

First I decided to make a very short Ethernet cable to connect NanoPi NEO directly to my router. I have done a couple of Ethernet cables in the past a few meters long, and they all work. I tested my ultra short straight Ethernet cable connections with a multimeter, and the 8 wires were properly connected, however, when I connected NanoPi NEO to the router with that cable it failed to get a link. Maybe there was aonther issue with the cable, so I made another one just as short… Another fail. It turns out very short Ethernet cables may cause issues, which are normally solved by twister pairs, but with such short cables the length of the twisted pairs is also extremely short, maybe 2 to 3 cm which may not be sufficient. So I ended up using a “normal” 1.5 meter cable, not as neat but it works.

The power strip close to my router was full, and since I did not want to add another, I decided to use the spare USB port on my modem router in order to power NanoPi NEO board. A USB 2.0 port can only deliver 2.5W max, so I was clearly looking for problems here. In order to avoid an issues, I made use of h3consumption script to adjust the behavior of CPU cores and disable unused peripherals.

Let’s check NanoPi NEO current settings in a terminal:

h3consumption allows us to change the following settings:

So I decided to disable USB, and use two CPU cores at most in order to limit the board’s power consumption, and avoid random reboots:

The changes were properly applied after a reboot.

I powered the board with my modem router, and could use it without issue. I’ll monitor NanoPi NEO’s uptime to check if this works.

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

January 19th, 2017 7 comments

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.

$10 RTLDuino is an Arduino Compatible WiFi IoT Board based on Realtek RTL8710AF WiSoC

January 4th, 2017 1 comment

Last summer, we discovered a cheap RTL8710AF WiFi module with many of the same function as ESP8266, but with an ARM Cortex M3 core instead. The only problem is that it was not quite as easy to play with as ESP8266 boards, as at the time I started by playing with AT commands with B&T RTL00 RTL8710AF module, and later on, I got a more convenient PADI IoT Stamp with breakout board, but if you wanted to change the firmware you had to play with the SDK and a J-Link SWD debugger. Realtek RTL8710AF did not offer the convenience of Arduino IDE program like its big brother “RTL8195AM” from the same Ameba family. I know mbed is being worked on, but in the meantime things have changed for the better, as kissste informed me that RtlDuino implementation added Arduino support to RTL8710AF and RTL8711AM modules, and an NodeMCU-like board with the same name was also sold for less than $10 including shipping.

rtlduinoRTLduino board specifications:

  • WiSoC – Realtek RTL8710AF ARM Cortex-M3 micro-controller @ 83 MHz
  • Connectivity – 802.11 b/g/n WiFi
  • USB – 1x micro USB port for programming and power
  • Expansion – 2x 16-pin breadboard friendly headers with GPIOs, UART, SPI, I2C, PWM, I2S, power signals….
  • Misc – Reset and test button, RGB LED
  • Power Supply – 5V via micro USB port or Vin pin
  • Dimensions – 49 x 24.5 mm (same as NodeMCU)

As you can see from the picture above,the board is actually based on the B&T RTL-00 module I previously tested. This is obviously quite easier to use since you don’t need to solder any cables to connect a USB to TTL board since RTLduino is equipped with CH340g and a micro USB port.

rtlduino-board-rtl8710af

The Aliexpress page has some claims about 5 function that accordingly to kissste are not quite all correct:

  1. Function 1 – “Mbed debugging mode” over micro USB cable -> you won’t get – this is a different board (at least for now)
  2. Function 2 – “JTAG debugging mode” over micro USB cable -> you won’t get – this is a different board
  3. Function 3 – “Simple & fast by OTA to upgrade debugging” -> you will get partially – no debugging, but you can OTA upload new sketch
  4. Function 4 – “Serial data directly to the network transceiver function” (serial console via UART) -> OK
  5. Function 5 – “Smartconfig mode” -> yes, will work – OTA upload new sketch

If you want to do debugging, I understand you’ll still need a JTAG or SWD programmer. If you want to get started with Arduino on the board:

  • Install Arduino IDE and Ameba SDK
  • Go to Arduino IDE installation directory
  • Clone github.com/pvvx/RtlDuino into hardware/development/rtl87xx directory
  • Restart Arduino

I could not find anything in English where other people tested the implementation, but you’ll find a forum thread (in Russian) on esp8622.ru, and other person mentioned the project on hackaday.io, but has not reported on details about it yet.

Beside Aliexpress, RTLduino board can also be found on ICStation for $9.99, and Amazon US for $10.99.

Ten Most Popular Posts of 2016 on CNX Software and Some Stats

December 31st, 2016 13 comments

The last day of the year is a good time to look back at what the year brought us, and I have to say it has been a fun and interesting year on CNX Software. The TV boxes news cycle has been dominated by Amlogic products, but most products have now switched to 64-bit ARM SoC, with 4K and HDMI 2.0 support, and price have kept going down, so you can now get a 4K TV box for as low as $20, although many people will prefer spending a bit more for extra memory and support. Intel based Bay Trail & Cherry Trail mini PCs have continued to be released with Windows, and in some cases Ubuntu, but the excitement seems to have died off a bit, maybe with the expectation of upcoming Apollo Lake mini PCs that should be more powerful. The year have been especially fruitful in the IoT space with a dramatic reduction in costs and sizes from ESP8266 boards to GPS modules and microwave radar modules, and we’ve also seen LPWAN modules & boards, mostly based on LoRa, but also Sigfox, being brought to market, as well as an alternative to ESP8266 with Realtek RTL8710AF, and of course the launch of Espressif ESP32 SoC with WiFi and Bluetooth LE. We’ve also been spoiled with development boards this year with the launch of 64-bit boards such as Raspberry Pi 3, ODROID-C2, and Pine A64+, as well as more dirt cheap Orange Pi boards, joined by NanoPi boards later in the year, and made all the more useful thanks to armbian community.

I’ve compiled a list of the most popular posts of 2016 using the page views count from Google Analytics:

  1. Amlogic S905 vs S812 Benchmarks Comparison (January 2016) – Amlogic S905 was probably the most popular SoC for TV boxes in 2016, thanks to a decent set of features, and aggressive pricing from manufacturers. So people wanted to find out if it was worth upgrading from S812 to S905, or maybe had to decide between purchasing a S905 or S812 TV box.
  2. Raspberry Pi 3, ODROID-C2 and Pine A64+ Development Boards Comparison (February 2016) – 2016 was also the year of cheap 64-bit development board with the launch of Raspberry Pi 3, ODROID-C2 and Pine A64+ boards, more or less at the same time, so again people want have wanted to look at which one to buy through this comparison.
  3. This is What a 16 Raspberry Pi Zero Cluster Board Looks Like (January 2016) – What can generated more buzz than the Raspberry Pi Zero? A cluster of Raspberry Pi Zero boards, as this post went viral the day after being posted. There was some talk about a crowdfunding campaign at one point, but it never happened.
  4. Review of K1 Plus Android TV Box with Combo DVB-S2/DVB-T2 Tuner (February 2016) – My review of K1 PLus T2 S2 might not be the most viewed post on CNX Software, but it sure generated a lot of comments, as while the product offers a unique combination of DVB-T2 and DVB-S2 tuners in an Android TV box at an attractive price, the documentation and software may need some improvements. Unofficial OpenELEC firmware images later surfaced from the community.
  5. How to Change Language to English and Install Apps Remotely on Xiaomi Mi Box 3 Enhanced (April 2016) – Xiaomi Mi Box 3 Enhanced is probably the most powerful TV box that can easily be purchased worldwide, but the caveat is that it has only been designed for the Chinese market. That post explains how to work around that limitation.
  6. Amlogic S905 vs Amlogic S912 Benchmarks Comparison (September 2016) – Quad core vs octa core, yeah twice the performance! Well not quite, but people were still curious to find out how the latest octa-core Amlogic S912 SoC would perform against Amlogic S905, and the truth is that the performance difference is rather minor, except for 3D graphics.
  7. NEXBOX A95X (Amlogic S905X) TV Box Review – Part 2: Android 6.0 and Kodi 16.1 (August 2016) – NEXBOX A95X was one of the first TV boxes based on Amlogic S905X processor, and my second review. The device is tiny an relatively cheap, so the review attracted some eyeballs.
  8. Mini M8S II TV Box (Amlogic S905X) Review – Part 2: Android 6.0 Firmware (July 2016) – My first review of an Amlogic S905X TV box nearly had the same number of views as NEXBOX A95X post, and many of the same features, just in a different package.
  9. Getting Started with Wemos D1 mini ESP8266 Board, DHT & Relay Shield (March 2016) – Wemos D1 mini is a great little ESP8266 board. It’s small, cheap ($4), and easy to use. The optional shields, just as cheap, make it a very attractive option for your IoT projects. Other people noticed it too, and then visited my review to get started.
  10. Raspberry Pi 3 Model B Board Features a 64-Bit ARM Processor, Adds WiFi and Bluetooth Connectivity (February 2016) – The last post is the list if a Raspberry Pi 3 leak just one day before the actual announcement.

Stats

Traffic has been rather steady in 2016 over the months.

cnx-software-traffic-2016The blog got around 9.8 millions pageviews in 2016 compared to about 7.2 millions pageviews in 2015, a 36% growth in traffic that was likely helped by my not going on a 3 months trip this year…

“openwrt” and scoop.it, respectively the top keyword and referral in 2015, were replaced by “amlogic s912” and Facebook in 2016.  Google Analytics only shows the last three months for keywords, and the full year for referrals, with referrals excluding search engines such as Google where CNX Software gets most of its traffic.

Top 10 Keywords Top 10 Referrals
amlogic s912 facebook.com
rk3399 flipboard.com
s905 vs s905x scoop.it
s905x vs s912 t.co
mxq box m.facebook.com
amlogic s905 4pda.ru
orange pi vs raspberry pi com.google.android.googlequicksearchbox
s905 vs s912 duckduckgo.com
s912 vs s905x plus.google.com
amlogic freaktab.com

The visitor mix of the blog per country as not changed much, with the top 10 countries of 2015 still there in 2016, and the top five order unchanged with United States, United Kingdom, Germany, Canada, and France.

cnx-software-visitors-2016London still hold the top city spot, but Hong Kong and Moscow dropped of the list to be replaced by New York and Melbourne.

cnx-software-2016-browser-operating-systems

Windows is still the main operating system of CNX Software visitors, but its share, as well as the share of other desktop operating ssystems including Linux and “Macintosh”, keeps dropping, while Android and iOS are having a stronger and stronger presence. In the “browser war”, Chrome lead extended further from 52.93% in 2015 to 59.41% in 2016, and Firefox dropping from 23.54% to 18.90%. Microsoft Edge probably had the best growth going from 0.56% last year to 1.86% this year.

Some of the 2016 review samples and I wish all my readers a very happy, prosperous, and healthy new year 2017.

Click to Enlarge

Click to Enlarge

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.

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.

ESP8266 based Wireless Air Quality & Environmental Monitors Teardown – Sonoff SC and vThings CO2 Monitor

December 20th, 2016 3 comments

The mailman delivered two parcels today, and interestingly enough they have a similar functionality measuring air quality and environmental data such as temperature. The first package was ITEAD Studio Sonoff SC environmental sensor with ESP8266, an Atmel MCU, DHT11 temperature & humidity sensor, a dust detector, a light sensor, and a microphone, while the second was v-Air Monitor vThings CO2 monitor v3 also based on ESP8266 with a CO2 sensor and other optional sensors. I’ll test both with their stock firmware later on, but today I’ll have a look at the hardware design.

Click to Enlarge

Click to Enlarge

v-Air Monitor vThings CO2 monitor specifications

While I’ve already written about Sonoff SC, it’s the first time I cover v.Air Monitor products, so let’s start with the specifications of vThings CO2 Monitor v3:

  • SoC – Espressif ESP8266 WiSoC
  • Connectivity
    • 802.11 b/g/n WiFi
    • Optional RF315 / 433 MHz RF module
  • Sensors
    • CO2 Sensor (one of them)
      • CM1106 NDIR sensor with 3-day auto-calibration period and < ±(50ppm+5% reading) accuracy (default)
      • CM1102 calibration-free sensor with best accuracy: < ±(40 ppm+2% of reading)
      • CDM7160 calibration-free sensor with < 10ma power consumption and better accuracy < ±(50 ppm+3% of reading)
    • Other optional sensorsDust (PM 2.5 and PM 10), temperature, humidity, pressure

The project is open source and open hardware based on vESPrino board, and you can easily program the board through micro USB, and custom the firmware that already supports HTTP and MQTT, OTA firmware updates, Apple Homekit (WIP), and Chrome app configuration (WIP). You’ll find source code and resources on Vladimir Savchenko’s github account.

Sonoff SC Teardown

Now that we have gone through both devices specifications, let’s check out Sonoff SC hardware.

Click to Enlarge

Click to Enlarge

The device ships with a USB cable equipped with power switch, and both Sonoff SC and the cable are stored in their respective anti-static bag.

sonoff-sc-micro-sd-slot-audio-button-power
The back of the device comes with a micro SD slot to store data, an “Audio” button actually used for pairing with the mobile app, and a micro USB port for power.

open-sonoff-scThe device is very easy to open as you just need to loosen four screws.

Click to Enlarge

Click to Enlarge

Removing the bottom cover gives you access to the main board with serial header for both ESP8266 and Atmel ATMega328 MCU. I understand that ESP8266 runs the AT commands firmware, and everything is mostly handled by the Atmel/Microchip MCU with the Arduino firmware available from the Wiki. The ESP8266 also has a SDA pin, that’s normally for I2C, but I don’t see any SCL pin, so it might just be used for one GPIO.. That side of the board also have the microphone used to detect noise levels.

If beside changing firmware, you also want to hack the hardware, for example changing sensors, you’ll need to remove the two “silver” screws to take out the complete system out of the case.

Click to Enlarge

Click to Enlarge

One side features Sharp GP2Y1010AU0F dust sensor connected to 5V, GND, and “VIN” (A1 pin) and “VO” (A5 pin), while the other shows DHT11 temperature and humidity sensor and the light sensor glued to the backside. I also asked the company to include the more accurate DHT22 sensor, as I plan to replace DHT11 with it later, and soldering is not even necessary.

Click to Enlarge

Click to Enlarge

The two black  screws holding the sensors’ holder were a bit loose, and I first thought it was due to a lack of quality assurance at the factory, but then I tried to reassemble it, and it would just not fit because of the “Audio” button… Then I realized the screws were actually loose by design in order to allow assembly of the system.

vThings CO2 Monitor Teardown

vThings “vAir Monitor” box has a sticker on top showing the option selected, and mine had CO2-CM1106, temperature and pressure selected. We can check this by loosening the three screws holding the two top covers of the 3D printed case.vair-monitor-casevESPrino ESP8266 board is screwed to the case, and connected to the CO2 monitor and the temperature & pressure sensor via 2.54mm jumper cables. The latter has its own compartment in order to avoid being influence by the other components. If you order a device without temperature sensor, you’ll get a smaller case without the extra compartment.

Click to Enlarge

Click to Enlarge

One we take everything out, we’ll see vESPrino board with an ESP8266 module, and vESPrino Cookie board connected to off-the-shelf CM1106 CO2 sensor, and BMP180 temperature and humidity sensor.

vthings-c02-monitor-bottom The bottom of the case gives access to vESPrino button that has no use for now. It’s even more easier to program than Sonoff SC since you don’t even to open the case to load your own custom firmware with programming done directly through the micro USB port.

Sonoff SC is sold on ITEAD Studio for $19.99 + shipping, while 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 with the price going up to 135 Euros with a dust sensor, CDM7160 CO2 sensor, temperature and humidity sensor, and RF connectivity. Bear in mind that both products have different kind of sensors, which explains the price difference.

$24 Winkel Arduino Compatible Board Includes WiFi, Bluetooth, 2.4 GHz RF, and an RTC (Crowdfunding)

December 13th, 2016 3 comments

There are plenty of Arduino compatible boards with WiFi based on ESP8266 WiSoC going for around $5 to $10, and with ESP32 processor, we are starting to have $15 to $20 boards with both WiFi and Bluetooth, but while ESP-IDF SDK has been progressing nicely, some parts of Bluetooth functionality are still not implemented. Winkel board offers an interesting alternative by offering WiFi, Bluetooth, 2.4GHz ISM, and an RTC for $24.

winkelWinkel board specifications:

  • MCU – Microchip/Atmel ATmega128 MCU @ 16 MHz with 128KB flash memory, 4KB SRAM, 4KB EEPROM
  • Connectivity
    • WiFi 802.11 b/g/n via ESP12E module based on ESP8266
    • Bluetooth 2.0 + EDR via HC-05 module
    • RF Radio – NRF24l01 2.4 GHz ISM radio. (Note: It might be possible to use it for Bluetooth LE connection, see here and there).
  • I/Os (through both Atmel MCU and ESP8266)
    • 38x Digital I/Os
    • 7x PWM Digital I/Os
    • 8x Analog Inputs
  • USB – micro USB port for programming and power
  • Misc – DS3231 Real-Time Clock + CR2032 battery slot, a few LEDS, reset button, jumper for OTA mode, ISP header, optional MPU-6050 Gyro+accelerometer mount
  • Power Supply – 5 V
  • Dimensions – TBD
Click to Enlarge

Winkel Pinout Diagram – Click to Enlarge

Winkel board can be programmed with the Arduino IDE via a micro USB cable, but you could also program the Atmel MCU over Bluetooth, and ESP12 module over WiFi without any cable required, a must if you want to update your firmware while the board is already in a case or hard to access. Thanks to the company’s “Smart Opt system” individual components can be power on and off individually, so that unused module don’t draw power. Source code for the firmware and code samples can be found on github.

arduino-esp8266-rtc-hc05

Rishi Hegde of Mintbox Technologies informed me that the board has now been launched on CrowdSupply with the company aiming to raise at least $1080. A $21 early bird pledge should get you the board will all modules (the price will be $24 after the first 50 boards are gone), but if you only want the core boards, and add your own modules, you could also pledge $12 to get the board with Atmel ATMega128 MCU and a micro USB port only. Shipping is free to India and the US, but adds $9 to the rest of the world, with delivery expected in March 2017. More details may be available in Mintbox Technologies’ Winkel product page.