Sunday, November 12, 2017

Getting air quality with ESP8266 and Amazon Alexa

If last week I've managed to get the temperature and humidity with ESP8266 and Alexa, now it's time to integrate the air quality sensor GP2Y1010AU0F from Sharp.

The GP2Y1010AU0F it is a compact optical dust sensor that has an infrared emitting diode and a phototransistor that are diagonally arranged. It detects in fact the reflected light of the present dust in the air. It is effective to detect very fine particle like cigarette smoke and it can distinguish from the house smoke from the house dust.

GP2Y1010AU0F sensor.
It has 6 pins and the electronic inside is split in two parts, the IRED emitting part and the phototransistor (receiving part)

Internal schematic
For the Air quality module I've used an wemos D1 board. The datasheet for the GP2Y1010AU0F is referring as VCC and the provided output by using a 5V power supply. Since the ESP8266 on analog input is limited to 1V and the wemos D1 is having an 220K and a 100K divider, I've choose to power the transmitter part to 5V and the receiver part with 3V3.

According to the specification in the datasheet also you will need an 150 ohm resistor and a 220uF capacitor, both came with the package.

Connect them according to the datasheet.

Resistor and capacitor

The provided analog output is proportional with the number of the dust particle in the air. Powering the phototransistor part with 3V3 will not get exact the output graph from the datasheet unless you will not use the 5V Vcc. If you need to be 100% to the datasheet and you are using an wemos D1, add a resistor in series with the output VO (pin 5) so the maximum voltage on the A0 input will not exceed 1V. Probably an 180k resistor will be fine.

Output voltage vs dust density

Based on the output voltage you can setup some steps for the air quality like excellent, very good, good, fair or dusty.

Here is a video clip on how is working with platform and Amazon Alexa.

Now eNVi-A is online. Total cost: 18.50 euro.

Thursday, November 9, 2017

Getting temperature from ESP8266 over MQTT with Amazon Alexa

With the help of the platform now I can get room temperature or outside temperature with just an ESP8266 and a temperature sensor like DHT22 or DS18B20 or BMP280.

The Alexa is questioning the server that will ask my local broker that will publish a message the the ESP8266 to ask the temperature for my room. The values for temperature and humidity will travel the other way around to Alexa, that is so nice and is letting me know about them.

On you will find also a demoapp ( source code on git) for a plug, but you can convert it easy to other IoT device. Also there is a mobile application in Google Play named Homy4( source is on git) that connects to the and allows you to turn on/off the plug device from demoapp.

Let me know what you think and what modules do you want to integrate on, on Alexa, ESP8266  and on the mobile application.

Everything is done encrypted and authenticated against 2 servers, so the entire communication is secured.

I will publish soon this skill to Amazon so any of you can have it. Just use the demoapp from and adapt it to send temperature. Maybe will be a good option to create also a demoapp for the temperature, not only for a plug.

The final box is small and compact. I've choose the DS18B20 since it can be integrated well in the box I have. To bad that there are not some enclosures for wemos D1 or nodeMcu which are most popular boards on the market. A printed 3D one it is an option, but takes time and I don't know if they can be produced in a large number.

Final box with eNVi - Alexa thermometer

So now the eNVi-T is up and running in 3 rooms. Next will be an air quality module and maybe an thermostat.

Total cost:10 euro.

Monday, October 2, 2017

MQTT Broker on ESP8266

Running an MQTT broker to serve all devices for a house ( 20pcs) it requires at least a Raspberry Pi or an equivalent SOC.

SD card fails from time to time and requires some Linux skills to make it work and the final price is over USD 70. (Good power supply, case, HDMI cable, keyboard )

But how about running an MQTT broker on this USD 3.99 ESP8266 board ? It is possible ? Yes, it is ! Go to and with few clicks you will be able to flash your ESP8266 ( 4Mb) with the binary. 

No need to compile code, to solve errors , just click and run. More than that your MQTT broker will communicate with your instance so you still get your messages on your phone if your mobile app is connecting to the websockets to your cloud instance. 

But what I am at home and my internet connection is down ? Can I communicate with my devices or I am isolated?  Don't worry, your mobile app will still be able to connect to the ESP8266 MQTT Broker over the websocket so you can control your devices.

Monday, September 18, 2017

Control any TV with your voice

Few months ago I was writing about the Broadlink RM3 mini in this article.

The big news is that nows supports the  Amazon "Alexa" voice control.

So saying "Alexa, change to channel 77 on Television" will change your TV to channel 77.

You can also rename your favorite channel to a specific name and call it like this: "Alexa, change to channel Sport on Television" and the Broadcom RM3 mini will do that for you.

To have all this features you need to install this application from Google Play ( I don't know for iPhone) and make sure  you have the latest version of firmware on your Broadlink RM3 mini.

If you have an STB Like I have and you are using your TV just as a panel you need to assign the virtual remote buttons to your STB remote buttons. After that everything will work fine.

The last step is to add the "BroadLink Remote Control" skill to your Alexa app and do start a device discovery.

BroadLink RM3 mini
What I miss from the previous e-Control application is the possibility to share the configuration of devices with other phones.

And a video ( sorry for accent :-) ) for demo.

Tuesday, August 1, 2017

ESP8266 anti cloning system

If you are investing time and money in developing a new module you want to have confidence that no one will clone it.

Assuring the authenticity of a product is a good for your brand image. No one wants that his nice and cheap power socket to also mine bit coins for someone else or do a DoS attack based on an external command. So, be aware on cheap IoT devices.

Since the flash memory of ESP8266 is external to the MCU then you will need an external encryption chip ( ATSHA204 EUR 0.5) that helps to authenticate your module.


  • Crypto Element with Protected Hardware-based Key Storage 
  • Secure Symmetric Authentication Device Host and Client Operations
  • Superior SHA-256 Hash Algorithm with Message Authentication Code (MAC) and Hash-Based Message Authentication Code (HMAC) Options 
  • Best-in-class, 256-bit Key Length; Storage for Up to 16 Keys
  • Guaranteed Unique 72-bit Serial Number 
  • Internal, High-quality Random Number Generator (RNG) 
  • 4.5Kb EEPROM for Keys and Data  512 bit OTP (One Time Programmable) Bits for Fixed Information
  •  Multiple I/O Options ̶ UART-compatible High-Speed, Single-Wire Interface ̶ 1MHz I2 C Interface
  • 2.0V to 5.5V Supply Voltage Range 
  • 1.8V to 5.5V Communications Voltage Range 
  • <150nA Sleep Current 
  • Secure Download and Boot ̶ Ecosystem Control ̶ Message Security ̶ Anti-Cloning 
  • 8-lead SOIC, 8-lead TSSOP(2), 3-lead SOT23, 8-pad UDFN, 8-pad XDFN, and 3-lead CONTACT Packages


  • Secure Download and Boot 
  • Ecosystem Control 
  • Anti-cloning 
  • Message Security

Basically the ESP will compute a challenge and pass it to the encryption chip. Solution for the challenge is then compared with the expected one and if both matched then the board is authentic. The ESP8266 will not start if the challenge is not solved correctly.

ATSHA204 Challenge Response

The chip I've used is the ATSHA204 and it has I2C and SWI as interfaces.

You can read the Application Notes here.

SWI interface

And the I2C version.

I2C version

First check if some how the chip is not altered before arrives to you. Check the default registers values with the default values from the manual, so between factory and you nobody altered the chip.

Here you will find all documentation related to the chip, how to configure it, how to debug it and more.

Trying to clone an ESP8266 module:

Anti-cloning system in action