Archive

Posts Tagged ‘automation’

Karl’s Home Automation Project – Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU

April 20th, 2017 1 comment

In a previous article, I wrote about an MQTT bridge by 1technophile. I added a DHT temperature and humidity sensor as well as a light sensor. Previously it included a software decoder to decode the IR signal. I never did test the IR transmitter on the gateway, as I didn’t have the parts. But thanks to IC Station, who sent me over a small YS-IRTM hardware based decoder and NodeMCU that I am writing about today. I have replaced the software based version with the YS-IRTM module in the latest update.

Click to Enlarge

Click to Enlarge

I found this project challenging. I admit I am a little weak in my programming skills. It was difficult to find documentation but I found a forum talking about this device and basics of how it works. When an IR code is recognized it sends 3 hex codes via serial connection on the transmit pin. To transmit, it expects 5 hex codes: A1,F1,xx,xx,xx. A1,F1 tells it to send the following codes. You can also set the baud rate but I left default 9600.

It is simple wiring wise. It only takes 4 dupont wires. It took a bit of coding to get it working but I finally got it to communicate via software serial. I started on a Arduino Uno with the code and then migrated it over to the ESP8266 board. I did have a little trouble when I first moved to the ESP board. I initially thought I might need a level shifter but that didn’t help. I am a little surprised I didn’t need a level shifter because the ESP needs only 3.3 volts. I was getting some weird responses and finally figured out I had to put in a slight delay. Maybe the ESP’s speed comes into play.

The way to use this is fill out your SSID and password and your MQTT server with credentials. Flash the device. You will need to add the necessary libraries. 1technophile has good documentation in his wiki.

Once flashed and ready to find your IR codes you will need to subscribe to the topics with the Windows command below. Give the gateway a moment to connect and point your IR remote at the sensor and press a button to find out code.

In your window, you will get something like this “home/sensors/ir 4,fb,8,” which is my power button for my TV. To test the code:

With this code, the TV will toggle on and off.

Click to Enlarge

After this you can use your favorite home automation project and control your IR devices with automations. You can omit any sensors that you don’t need. You will get some erroneous MQTT data if not all sensors are used. Below are the bits of Arduino code added for the IR module, and here’s the link to the github code:

I plan on 3D printing an enclosure with CR-10 I am reviewing, and I will remove the IR LED, and move it to a more suitable position, as both facing the same way isn’t ideal for my setup.

I would like to thank IC Station for sending the NodeMCU ($5.81 shipped) and IR transmitter and receiver ($3.39 shipped) for review. You can get 15% discount with coupon Karics. I finally have a complete gateway.

ESPurna-H is a Compact Open Source Hardware Board with ESP8266 WiSoC, a 10A Relay, HLW8012 Power Monitoring Chip

April 9th, 2017 7 comments

ESPurna is an open source firmware for ESP8266 based wireless switch as such Sonoff POW, which I’ve been personally using to monitor my office’s power consumption. The developer, Xose Pérez (aka tinkerman), has now developed his own hardware with ESPurna-H board, as existing wireless switches with power monitoring functions would not fit into a gang box.

ESPurna-H board specifications:

  • WiFi Module – ESP12 with Espressif ESP8266 WiSoC
  • Relay – Songle SRD-05VDC-SL-C 10A relay with NO and NC connection
  • Power Monitoring – HLW8012 chip as found in Sonoff POW
  • Expansion – 2x 5-pin header with the programming GPIOs, and two connections for external button and LEDs
  • Misc – Reset button
  • Power Supply
  • Safety – Optical isolation between the logic circuit and the relay circuit
  • Dimensions – 50x50x20mm

Xose designed the board with Eagle 8.0 and released the schematics, PCB layout, BoM and other hardware design files under the Creative Commons Attribution-ShareAlike 3.0 Unported License (CC-BY-SA 3.0). You’ll find the files on github.

ESPurna-H with Custom 3D Printed Plate before Installation in Gangbox – Click to Enlarge

The board is not for sale, but you could purchase the PCB on OSH Park, purchase the components separately, and finally do the soldering yourself. Since this is a hobby project, not specific safety testing has been done, and you’d better understand what you are doing since the board is meant to be connected to the mains. Even companies do it wrong from time to time. If there’s a design flaw with the board it could overheat melting the plastic around, and in the worst case even start a fire.

Xose completed the setup with a capacitive touch switch attached to the cover, in order to turn on and off the light, and the final results above looks quite neat.

Cambrionix PowerPad 15S is a 15-Port USB Hub with 2.1A Output, Control API, Serial Console, Power Consumption Monitoring

April 8th, 2017 8 comments

Many development boards are powered over USB, usually via a micro USB ports, and if you have one board, you’d just use a 5V USB adapter with the right amperage, and it will work fine as long as you have a low resistance USB cable (AWG20 cables recommended for higher loads).  But when you start to running multiple boards using power strips with USB adapter start to take space, so USB hubs are much more convenient. However, you need to find one that delivers enough power, is reliable, and possible allows per port power control. The guys at LAVA (Linaro Automated Validation Architecture) are using a lot of boards to validate software developed by Linaro and their members, with the boards having to run 24/7, and they had various misfortunes with USB hubs, but as Dave Pigott reports they’ve now found that USB hub of their dream with a 15-port USB hub from Cambrionix which should be their PowerPad 15S model.

Cambrionix PowerPad15S technical specifications:

  • 15x USB port supporting charge and sync with up to 2.1A per port
  • 1x USB host port
  • Control Interface – Cambrionix API, Terminal Command Session, SSH, Minicom
  • Charging Method – Cambrionix VIC “Very Intelligent Charging Protocol”
  • Power Supply – 180W external power supply
  • Certifications – CE, FCC, Underwriters Laboratory (UL), WEEE and RoHS

Each port of the USB Hub can be controlled individually (charging, syncing, or off modes), allows retrieval of VID/PID data, and records power consumption (amps, charging time, total power consumed).  The hub can be monitored and controlled using LiveViewer App for Window or Mac OS, but if you want to automate the USB port, for example to power cycle a board that does not answer to ping request, you may want to use the Cambrionix API available for Linux x86/ARM, Windows, and Mac OS.

When Dave connect the HUB to his (Linux) laptop he noticed it was detected as  a serial device only, and after configuring ser2net, he could login via telnet, and help listed a bunch of commands to control each port. As he connected a Hikey boar, he found a command to check all the ports status with their current draw, so he wrote a Python script to control the port as he wanted.

They also found EtherSync Hub from the same company with that’s running Linux, and can be controlled from the network over Ethernet. LAVA team has been running both types of hubs for a while and found them to be reliable, and will update the complete lab with them.

Cambrionix has other USB charging product with various number of ports, and form factor, including a USB charging 1U rack, or a 54-port data transfer USB hub. Check out their products page for details. Those are all nifty USB hubs, but as expected price is pretty high with PowerPad 15 sells for $660 on Amazon US (that’s $44 per USB port), and while there are some other cheaper Cambrionix models on Amazon UK, they probably lack advanced functions like power monitoring. [Update: I’ve been informed model PowerPad 15C (notice the extra C) is much cheaper, as it sells for £159 ex vat (~$200) on Multipad UK. The main difference is that it does not support sync mode compared to PowerPad 15S model].

Karl’s Home Automation Project – Part 3: Adding Light Detection to a Motion Sensor

March 27th, 2017 No comments

This is the 3rd part of my Home Automation light project. In the first part, I wrote about basic setup with basic Sonoff Wifi MQTT switches and setting them up. In the second one, we added some 433 MHz motion sensors and a 433 MHz to MQTT bridge. And finally in part 3, we are going to modify the 433 MHz motion sensors to only work when it is dark in the room.

Motion Sensor

Click to Enlarge

The motion sensor I linked in part 2 is run by a common chip called a BISS0001. We are interested in pin 9. If voltage is below .2v it will not trigger a motion. This solves the problem discussed in part 2, when we have a gloomy day or if blinds are closed etc.

By adding an GL5537 LDR (Light Dependent Resistor) shown as R3 in the diagram above, you will achieve the desired effect. Extend the LDR with some wires and solder between ground and pin 9.

The GL5537 is extremely sensitive. You can adjust your sensitivity by placement. I put mine right next to the PIR sensor so it sees outside the window. It works perfectly. If you wanted it to get a little darker you can use the mounting hole on the back or make a new on the top or sides. Direct access to the outside light would mean it would need to be darker in the room for it to trigger. You have to be careful with the motion sensor placement or your light being triggered might cause the motion sensor not to trigger because there is too much light. I get this if the motion sensor is too close to the lamps I am triggering.

Home Assistant

Before modifying we had 2 automations one for before sunrise and one for after sunset:

Now that we’ve added the logic for light and dark at the motion sensor itself, we can simplify these 2 down to one automation, and only specify the time. The rest of the home assistant configuration can be found in 2nd article here.

That is all I have for now. If you have an idea or a product that you feel that meets the cheap and DIY criteria leave a comment below. I will test it out. I know you can do a ton of things with Home Assistant and a lot seem over the top. I want to focus on mundane things like turning off lights. I am also going to get some 433 MHz moisture sensors for my house to place in crawl spaces, and under the sink but that is pretty basic.

Continue reading “Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU“.

Xiaomi 6-in-1 WiFi & Zigbee Smart Home Kit Works with Domoticz Home Automation Software

March 24th, 2017 11 comments

Xiaomi “Mijia” 6-in-1 smart home (security) kit is an home automation set with a WiFi & Zigbee multi-functional gateway with RGB light and speaker, a wireless switch, a window/door sensor, a  human body sensor, temperature & humidity sensor, and a smart socket.

The key features of each item are as follows:

  • Multifunctional Gateway Remote Control
    • WiFI and Bluetooth connectivity
    • Built-in speaker
    • Light sensor and 18x RGB LED for notifications potentially trigerred by connected sensors: body sensor, door sensor, IP camera…
    • Online radio support
  • Window / Door Sensor Set
    • Light and rings the gateway when opened or closed
    • Away from home mode: can trigger IP camera recording
    • Power – CR2032 cell battery that should last for 2 years
  • Smart Wireless Switch
    • Programmable one key switch to turn off all lights/applicance, turn on one light at night, etc…
  • Human Body Sensor
    • Motion sensor allowing you to control other devices through the gateway
    • Power – CR1632 battery
  • Smart Socket
    • Zigbee connectivity to gateway
    • Reports actual power consumption
    • Overload protection
    • Set timing turn on and turn off
  • Temperature Humidity Sensor
    • Triggers alarm if the temperature and/or humidity are out of normal range
    • Log data over time via Gateway
    • Power – CR2032 battery

You’d normally use this kit using MiHome app from the Apple Store or Google Play, but if the rather mixed user reviews scare you off, the good news is that the Xiaomi gateway (Aqara) is now supported by Domoticz (Beta). Note that there appears to be multiple hardware versions of the gateway, and Domoticz will only work with version 2.0 or greater.

Domoticz integration still requires you to install MiHome app, as you need to enable developer options, specifically “LAN functions” to set a fixed IP address. Once this is done you’ll be able to select “Xiaomi Gateway” in Domoticz web interface, and input the IP address. After getting back to the Android / iOS app again to setup the sensors, Domoticz should automatically detect them.

Click to Enlarge

Once this is done, you should not need to access Xiaomi’s mobile app anymore, and can manage and control your devices with Domoticz web interface or/and Android app.

Support for Xiaomi Smart Home gateway was merged on Github last December, and if you want to find others experiences, there’s a long thread about it on Domoticz forums. The kit described above can be purchased from GearBest for $74.5 shipped. You’ll also find the kit on other shops such as DealExtreme with various options  (4-in-1, 6-in-1, gateway only, etc…), as well as Aliexpress.

Thanks to Harley for the tip.

Dell Edge Gateway 3000 Series Are Powered by Intel Bay Trail-I SoCs for Automation, Transportation, and Digital Signage

March 17th, 2017 No comments

Dell has recently introduced Edge Gateway 3000 series with three models powered by Intel Bay Trail-I processor, running Ubuntu Core 16 or Windows 10 IoT, with each model targeting respectively general-purpose automation, transportation & logistics, and digital signage and retail.

The specifications for the three models can be found in the table below.

Dell Edge Gateway 3001
Model for General-Purpose Automation
Dell Edge Gateway 3002
Model for Transportation & Logistics
Dell Edge Gateway 3003
Model for Media & Retail Kiosks
SoC Intel Atom E3805 dual core processor  @ 1.33 GHz (3W TDP) Intel Atom E3815 single core processor @ 1.46 GHz with GPU @ 400 MHz (5W TDP)
System Memory 2 GB DDR3L-1066
Storage 8 or 32 GB eMMC flash
Industrial-grade Micro-SD card: 8GB / 16GB / 32 GB / 64 GB
Connectivity 1 x 10/100 Fast Ethernet (RJ-45)
with PoE (15.4W)
WiFi 802.11 b/g/n
Bluetooth 4.0 LE
Optional ZigBee module.
2x 10/100 Fast Ethernet (RJ-45), main port supports PoE (15.4W)
WiFi 802.11 b/g/n
Bluetooth 4.0 LE
Integrated Zigbee/802.15.4 module for mesh
networking.
2 x 10/100 Fast Ethernet (RJ-45).
Main port supports PoE (15.4W)
WiFi 802.11 b/g/n
Bluetooth 4.0 LE
Optional ZigBee module
Cellular Connectivity 3G or 4G LTE for select countries, US/Canada 4G LTE with AT&T or Verizon
Video & Audio DisplayPort 1.1 up to 2560×[email protected]
3.5mm Line Out/Line
In; RealTek codec
Serial Interfaces 2x RS-232/422/485.
GPIOs 8x channel, independently
programmable, DAC, ADC.
CAN Bus CAN2.0 A/B/FD 1Mbps (CAN2.0), 5Mbps (CAN-FD)
USB 1x USB 2.0, 1x USB 3.0
GNSS Integrated GPS
Sensors Accelerometer, Pressure, Temperature and Humidity
Power Supply 12V-57V wide DC input;
PoE compliant with IEEE 802.3.af standard up to 15.4 W, 48 V over existing Ethernet infrastructure, no
modifications required.
Dimensions 125 mm x 125 mm x 51 mm
Weight Around 1.1 kg

While all three models can run Ubuntu Core 16 and Windows 10 IoT Enterprise LTSB 2016, the latter requires a 32GB eMMC flash. Each gateway also comes with a Trusted Platform Module (TPM) 2.0, secure boot, BIOS password and I/O port disablement, and a fleet of gateway can be managed via Dell Edge Device Manager (EDM) cloud-based manageability suite (sold separately).

Gateway 30001 used for Mining Operations – Click to Enlarge

The gateway can be used for all sort of applications from mining management systems as shown above, to 18-wheelers, and revenue generating city fountains.

Dell Edge Gateway 3000 series will start selling this May for $399 and up. More details can be found on Dell website.

$12 AI Light ESP8266 based WiFi RGB Light Bulb Supports MQTT via ESPurna Open Source Firmware

March 3rd, 2017 20 comments

AI-Thinker is famous in the maker world for their ESP8266 modules, but they’ve also recently launched a WiFi RGB light bulb that sells for about $12.5 and up on Ebay and Aliexpress (here and there). Some people noticed, and bought samples online, including Xose Pérez (aka Tinkerman), ESPurna open source firmware developer, who could confirm ESP8266 was used in the light bulb, did some investigations, and eventually added the light bulb into ESPurna, which means it can be managed using MQTT or a web interface.

AI Light looks very similar to Philips Hue, but comes with WiFi instead of Zigbee. AI Light “M1636” key features:

  • RGBW LED E27 bulb with 16.7M colors
  • Connectivity – 802.11 b/g/n WiFi
  • Encryption – AES
  • Voltage Range – 110-240V
  • LED Power – 5 watts
  • WiFi Power Consumption – ≤0.3W
  • Temperature Range – -5~45degree
  • Humidity – ≤80%
  • Certifications – FCC, CE, ROHS

If you’re going to use the stock firmware, you can control the LED with Tuyasmart Android app. You’ll find the user’s manual and more photos on the FCC page for the light bulb. But there are already plenty of Wifi light bulbs on the market,  and what makes this light bulb interesting is that it’s based on ESP8266, and you can have full control over it using open source firmware.

The bulb cap is allegedly very easy to pop out, as it’s not glued to the board.A close up on the board itself reveals it’s indeed powered by Espressif ESP8266EX WiSoC connected to a 1MB Winbond 25Q80BVSIG flash, and MY-Semi MY9291QD LED driver.

Click to Enlarge

If you look from the bottom left to middle left of the inner circle, you’ll see 3V3, GND, RX, TX and IOO pads, which we can use after soldering some wires, and connect a USB to TTL board in order to flash the firmware. Note that IOO must be connected the GND to enter flash mode, you can remove the wire after flashing, in order to check the serial output during a normal boot.

After further investigation, Xose found out that there’s already some software implementation for MY9291 driver in Noduino OpenLight project, made by the developers who designed Noduino ESP8266/ ESP32 boards, and are likely the developers of AI Light. All needed source code can be found in Noduino-SDK released under a GPLv3 license, and includes a driver written in C language for MY9291 LED driver chip. Xose wrote a wrapper to make the driver work with Arduino ESP8266, and released the code on Github.

The code sample below shows how to set the LEDs to RED color at 100% duty cycle:

Ai-Thinker Ai Light / Noduino OpenLight have now been added to ESPurna 1.6.8 firmware, and you can turn the light on and off, select the color from the web interface, and/or control it via MQTT.

ESPurna installed on AI Thinker Light Bulb – Click to Enlarge

Karl’s Home Automation Project – Part 2: 433 MHz / WiFi MQTT Bridge, Door & PIR Motion Sensors

March 2nd, 2017 11 comments

Karl here again for part 2 of my home automation project. We will be looking at how to automate your lights based on time of day and motion. In the first part we setup Home Assistant and uploaded firmware to basic Sonoff Wifi switches. Today we will setup a 433 MHz to MQTT bridge and some sensors.

433 MHz

Depending on your country 433 MHz is an open frequency to use to communicate with. There are hundreds of different types of devices that use 433 MHz to communicate information. We will be focusing on 2 today from Gearbest: WMS07 motion sensor (left) and WDS07 door/window sensor (2 parts, right).

I am not taking the door/window sensor apart, since it is super basic, but I’ve included some photos of the PIR motion detector.

Click to Enlarge

Click to Enlarge

433 MHz Bridge

While contemplating how to get presence on a per room basis I ran across this project. It monitors 433 MHz signals and publishes it to the MQTT server. It is a really an easy project. It also has an IR to MQTT feature. I did have an IR receiver and tested it but have not implemented it. He has some good instructions on his page so I won’t go over too much. You can do the bare bones version and just leave off the unused sensors. I also went an extra step and added a light intensity sensor and DHT sensor to the project. It can be found here. I am not going to add those to this write up because trying to keep costs down.

What you will need is

  1. NodeMCU $5.69
  2. H3V4F Receiver Module $1.21
  3. Prototyping board $2.88

That is all that is needed. For about $10 you have an inexpensive 433 MHz bridge. You can put in a box if you want and hide it in a central location away from interference. I would suggest soldering headers to your board just in case something goes bad. I didn’t at first and made my life a pain. There are a ton of 433 MHz receivers. I purchased all the ones on Gearbest and this is by far the best. I did upgrade to a superheterodyne but I am not sure it is any better. I upgraded because I wanted to put the door sensor on my mailbox and get a notification when the mail was delivered. It is about 200’ away and is a little spotty even with a new 433 MHz receiver. I used this antenna design (see picture on right), as it seemed to work the best

Coverage is the biggest concern.  I have a brick single story ranch style home about 2000 square feet and it covers the inside with ease and a lot of the area around the house. If you have a multi-story house or would need multiple receivers you would need to change the MQTT topics to avoid getting duplicates. Below is the final project. To be honest temperature is really the only thing that is useful to me, but wanted to see what could be done. I purchase the DHT11 and the readings are not good. If you want to do this go with the DHT22. Below is a mostly loaded bridge. I don’t have an infrared transmitter yet. I have a different one coming that does the encoding/decoding on a chip and will follow up when I receive it. I am hoping it will be easier/better than using the Arduino library.

Motion Sensor

The motion sensor itself is really easy to setup with jumpers. I suggest turning the LED off, and the time to 5 min after finished setting up with the jumpers. If you notice there is a micro switch in the top left of this picture. It is meant to be a tamper switch but I use it as a toggle switch to quickly turn off the lights. The motion sensor is meant to be used for a security system but I just have them sitting on night stands and corner tables. It works really well to override or turn a light on when Home Assistant ignores the motion. A little squeeze of the box and the light will toggle states on or off.

After your bridge is set up and connected take the motion sensor out and put some batteries in it. Run your batch file to see what code is being sent. For this one we need 2: motion and tamper. Write these codes down.

Home Assistant

Below is the YAML code that I am using with Home Assistant. I made it find and replace friendly. If you copy and find the 4 items below it should work. I think it is relatively easy to follow. It is the typical timed lamp on motion that is on Home Assistant website with some slight modifications. I had to add the turn off motion script because the motion sensors only sends when it senses motion. I also had to add the tamper toggle switch. When you are adding multiple sensors you can only have one “binary_sensor:” group and one “automation:” group etc.

Find/Replace Explanation
generic use livingroom or masterbedroom etc no spaces
5555555 use the motion number you found earlier
8888888 make up a number around your tamper/motion number
9999999 use the tamper number you found earlier.

 

Door Sensor

For the mailbox sensor here is an example. Same thing on this one run the batch file and find the open and closed codes. I have it send me a notification via pushbullet.

Almost there

We are almost there. Lights are turning on and off magically. Life is good. But there is one situation where it’s not so good. The gloomy day. With the automations above we cannot determine if the blinds are pulled or it is gloomy. We still need the lights to come on under those circumstances to make it really cool. In the next installment we are going to take the motion sensors above and add a light intensity sensor to them. We will be able to do this cheap. We still have a pretty good budget. With the bridge above you open yourself to a bunch of battery operated sensors. You can also control devices, as well, with a transmitter. Any of the transmitters should work on GearBest. You can get the one linked and throw away the receiver. It’s only $1.25.  If you have any questions or concerns feel free to leave a comment.

Item Qty Price Total
Initial Setup Sonoff Basic 5 $4.85 $24.25
Headers 1 $1.50 $1.50
USB to TTL 1 $2.54 $2.54
$28.29
Motion Sensors NodeMCU 1 $5.69 $5.69
H3V4F Receiver 1 $1.21 $1.21
Prototyping board 1 $2.88 $2.88
Motion Sensor 4 $7.03 $28.12
$37.90
Grand Total $66.19

Continue reading “Part 3: Adding Light Detection to a Motion Sensor“.