MQTT and ESP8266, using i2c sensor things work

Forget the DHT11. Implementing the protocol to read temperature and humidity eats all your memory on the ESP8266 and there is nothing left if you want to support MQTT messaging. However, and I2C sensor works. The I2C implementation using an LM75A can be done and integrated with MQTT.

I am preparing a post with the details on what I did.

Posted in Uncategorized | Leave a comment

MQTT and ESP8266

Got the vibration detection board working with MQTT. This was really an ordeal given that the memory issues with LUA and the ESP8266 are really frustrating. Its trial and error. Finally and after stripping the code to the bare minimum, i.e., remove all the fancy web page interface to the board configuration, things got working pretty good.

I installed my own MQTT broker on a MacBook, Mosquitto, and got it to work without major issues.

MQTT is really great for IoT, of course if you have a broker running or want to go through a public broker, otherwise my ad-hoc messaging solution I think it is a bit easier for home projects. But again, MQTT is the way to go if you want to control several devices, send and receive various commands, etc.

On my future boards I will offer ad-hoc messaging or MQTT, check them out on Tindie

Posted in Uncategorized | 2 Comments

Color recognition board using the ESP8266 and the TAOS TCS230 color-to-frequency module

This is a wifi enabled board that reads color components Red, Green and Blue of any material placed closed to the sensor.

The reading of the color components is done via a TCP request to the board and the percentage color component values are returned in a JSON string.

The sequence for reading is done by sending the following strings via TCP on port 9999:


(wait 5 seconds for acquisition to complete)


The return message is in JSON format as follows:

{“RGB”: [{ “Red:”: “53”, “Green”: “23”, “Blue:”: “24”}]}

each number representing the percentage of that color. The board can be configured via web browser without the need for a serial interface to program it!

This board can be purchased at Tindie, press here to go to Tindie store

Posted in Uncategorized | 2 Comments

ESP8266: Handling analog signals without an analog input, just GPIO!

Experimenting with the ESP8266 at one point I came across the need of dealing with analog signals. There are a lot of versions of the module and most of them have GPIO accessibility but not ADC access. Some of the lates versions of the module have ADC though, but I have a few modules in stock that do not have it. And I need ADC handling.

Well, it is totally possible and here is how to do it.

There are 4 basic things that need to be done:

  • convert the analog signal into pulse width modulation (PWM)
  • read the PWM on any GPIO
  • read the PWM duty cycle on the ESP8266
  • calibrate the PWM to analog level response

This module can be purchased at my Tindie store


I am using NodeMCU Lua API. Lets look in more detail:

Convert the analog signal into pulse width modulation (PWM)

This is quite simple. The popular LM555 will do the trick. Here is the circuit:

Screen Shot 2015-04-20 at 11.37.38 AM

A sawtooth signal ramping up from 0 to 5v simulates the analog signal, the 555 spits out a PWM, with duty cycle proportional to the analog level. The 555 output is then connected to a GPIO pin.

Read the PWM on any GPIO

This is even simpler. Just pipe the output of the 555 to any GPIO pin.

Read the PWM duty cycle on the ESP8266

To do this, watch for the GPIO pin ‘up’ and ‘down’ events:

file.writeline([[gpio.trig(pin, 'both', callback)]])

In the callback function, read the pin, track the time when the up and downs happen and calculate the ratio, that is the duty cycle:

file.writeline([[time_read= time_read-time_base]])
file.writeline([[if cnt == 0 and rp == 0 then low_start=time_read]])
file.writeline([[if cnt == 1 and rp == 1 then low_end=time_read]])
file.writeline([[if cnt == 2 and rp == 0 then high_end=time_read]])
file.writeline([[high_start = low_end]])
file.writeline([[if (high_end-low_start) > 0 and cnt == 3 then]])
file.writeline([[duty = (100*(high_end - high_start))/(high_end-low_start)]])
file.writeline([[print("Duty: " .. duty) ]])
file.writeline([[cnt = 0]])

Read the PWM duty cycle on the ESP8266

Finally, pick a few calibration points between the PWM duty cycle you are reading and the actual analog signal value and calibrate the reading.

My prototypes are available on Tindie.

Posted in Uncategorized | 1 Comment

WIFI vibration sensor using the ESP8266

A simple vibration sensor can be connected to the ESP8266 GPIO pin and an alarm can be triggered via TCP to report vibration. This could be useful for a number of things, including industrial monitoring, security, etc. The prototype uses a sensor originally designed for Arduino, but can easily be connected to one of the GPIOs in the ESP8266. The firmware checks whether the GPIO has triggered and if so it sends a TCP message to a server listening. SSID and password for the WIFI can be programmed remotely via web as with my other prototypes and the nice things is that the server address and the port number the server is listening at can also be programmed remotely via web, no serial connection required and it is persistent!!!



Vibration switch


Vibration switch connected to ESP8266 board

Screen Shot 2015-04-16 at 6.19.16 PM

TCP trigger received overtime there is a vibration

 Check my other and future boards on Tindie


Posted in Uncategorized | 2 Comments

Temperature and Humidity sensor and control using ESP8266-03

Temperature and humidity sensor and control

Temperature and humidity sensor and control

This module is available for preorder at Tindie click here

This project implements a temperature and humidity sensor using the ESP8266 WIFI module and a DHT11 temp/hum sensor.

The board can be configured via web in a similar way as previous projects. Connect to the  ESP8266 station (ESP8266-XXXXXXX) and on a web browser point to IP, then you are prompted to enter wifi network SSID and password. Within a few seconds, the IP address of the ESP8266 module will appear on the web page.

Any TCP message sent to the module IP address will return a JSON feed  with the current temperature and humidity:

{“dth11”: [{ “Temperature:”: “24”, “Humidity”: “39”,}]}

Now the interesting part. By sending a TCP special string, I can set a minimum and maximum temperature and humidity. When the minimum temperature is reached, then a relay is triggered; similarly, when the maximum temperature that has been set is reached, another relay is triggered and the other one is reset. The same can be done for humidity. Now we have a sensor that reacts.

The control string is of the form


and can be sent at any time to set the min/max limits, in return you always get the current temp and hum as

{“dth11”: [{ “Temperature:”: “24”, “Humidity”: “39”,}]}

A video of the project can be accessed here

Posted in Uncategorized | 20 Comments

General purpose WIFI control board x4 based on ESP8266-03

I’ve just finished getting the ESP8266 working. I can now configure it via a web browser and the LUA based firmware will also allow me to control 4 signal, on and off, that can feed relays or other low consumption devices.

ESP8266-03-x4ControlBoard-v01Pic2 ESP8266-03-x4ControlBoard-v01Pic1

Check the video on Youtube


Next is the temperature logger…

Image | Posted on by | Leave a comment