Home Automation – Light Switches

Home Automation Disclaimer

One of the first things you want to control are the lights. Soon you realize that besides controlling everything from you phone,  you need physical buttons. And if you already has a house with switching boxes, it’s nice thing to use the same ones. So, to put everything nicely in a switch box  is one of the first home automation challenge.

Everything in my house is wired to an ESP8266 which are very little, but very power angry. So. to power them from 220V (or 110V) a 3.3V a SMPS is the only option I found. And those are relative bulky, but still could fit in a switch box. This what I usually do:



In this example there is a ESP01 in a socket, so you can remove it to program it, a 3.3V SMPS, and a 220V connector, a VCC to EN jumper, and two additional pull up resistors for GPIO00 and GPIO02 (the only two available in ESP01)

And here there is how it fits in the switching box



It’s using one unit, that left two units for switches, so everything is using same space that three switches.

Of course the physical switches aren’t the original (permanent on or off) but push style ones.I have some in my house and I’m very happy with those: in ten minutes is possible to build one, no PCB, no case. 

Posted in Uncategorized | Leave a comment

Home Automation Disclaimer

In a series of posts I will share my learning in home automation.
I did mostly guided by the standard “quick and dirty” (Well, at the end wasn’t so quick). Mostly because I have little time,  I’m very anxious and a little lazy. And let’s be honest, if you want to automate your garage door, you can take the time to do it nicely. But if you want to go for the entire house, meticulousness is a luxury. So yes, some thing aren’t nice; but in my defense I can say: they work.

Also, I know many things could be done with open source systems like openHAB but I need it to do it from scratch. I enjoy that, my mind just works when I can control everything… I don’t know, but is as it is. So yes I like to re invent the wheel, I like that feeling. I’m not chasing productivity. And not, there this no contradiction here: I’m lazy to do PCB, not to think how to solve a problem or to code.

I will share this because I enjoy it (to share), and also to receive constructive (please, constructive) feedback. The posts won’t be in any specific order, I will try to cover everything, but will be as it comes out. Sorry.

It will be one specific post on general architecture of the system, but to give a general idea: The brain of the system it’s a Raspberry running Python scripts and many ESP8266 around the house running LUA scripts. And everything communicating by MQTT.

Posted in Uncategorized | 1 Comment

Defectives ESP8266/ESP12

I want to share my very recent experience with several Wemos D1 boards. I hope this will help someone to save time and frustration.

This is my history: A customer ask me for 50 units of very simple WiFi data logger. It’s a product I sold several times. Yes, I used the ESP8266, in a Wemos board, with a ESP12 from DOIT.AM. Plus a 5v switching power supply, two status led, two optocouplers and not much more.







When the boards arrived I observed some very strange behavior when connected to a PC by USB cable: the computer enter in a cycle of: recognize the COM port and one second after loose it, and repeat forever. The period of the cycle sometimes was very homogeneous (~0.5Hz), that should be the first thing I should pay attention, but sadly I missed it. Intermediately I changed cables, computers, but nothing. Very soon I found that if I touch the module, the cycle stopped and I can access the module normally.


I thought  It could be something with the CH340, a defective chip, something with a floating pin, etc. I check everything, but not very convinced: I never like the idea of touch something to solve a electrical noise problem; it should be the opposite! But I didn’t have something better. Finally I remove the two transistors driven by the CH340 (which are used by the board to reset and to put the ESP in programming mode). Once it was programmed I won need them anymore, neither the CH340. Very dirty, but I needed to deliver the units to my customer.


That stop the ESP reboots, and seems to work for a while, but very soon I found anothers problems with the Wifi: disconnections, huge ping times, and some modules didn’t connect at all. I checked and suspected of everything. I tied to ground everything, I put filter caps everywhere, seems to help, but I didn’t get rid completely of the problem.

Of course in the middle I was trying to convince my supplier that something wasn’t right but at the same time I needed the boards as soon as possible, I knew that that kind of problems are very difficult to demonstrate (he still saying I should try  another USB cable), and the worse: maybe all the boards he has on stock could have the same failure. So I was determined to solve it.

Started to remove everything from the board, eventually I have just the ESP12 board without the metallic cover


Again, improved, but still I had connection problems, and the board feels a little hot.  Sadly, wasn’t so straight as I writing it, and took me 2 days (and several boards), but finally I found the culprit component: one inductor (or at least what I think it’s) capacitor in the RF output. It’s between the antenna and ground. In the picture it was already (brutally) removed. I think it should be a filter matching network which has a different value of what should be, shorting the antenna and injecting RF to GND.


After I remove it everything started to work perfect: nice ping times, no disconnections, no resets, and cold boards.

In the picture, it’s a before and after: it’s clear improvement in ping times and current consumption (0.47 ohms in series, 50 mv/div). Also it shows as fast I can open a ESP12 and remove a SMD inductor capacitor (and that explains the previous picture ;)


As soon I saw this, all pieces fit’s correctly in my mind: principally why touching something helped, and why the disconnection-connection cycle was so precise.  I feel very dumb I had all the evidence: it’s was RF noise coming from the ESP, not from outside; but sadly didn’t see it clearly.

In the middle I expend time searching the web for the same symptom, but I didn’t found nothing: I can’t have so bad luck to be the only one in the world with 50 defective Wemos boards. So I hope to help someone with the same problem, or maybe to learn as not to troubleshoot.



Posted in Uncategorized | 17 Comments

Improving fridge thermostat

Since some time my fridge’s thermostat started to work erratically, so I decided to replace it. But, you know, do it in a normal way: go to the spare store, buy a new one, and replace it (2 hours top) it’s not an option for a geek.  So choose the hard (and long way): make a new one. Course it should be much better than the old one, so I designed it with some features I want it:

  • Configurable “on temperature”, and “off temperature” (hysteresis)
  • A configurable minimum off time, to allow defrost.
  • A configurable maximum on time, to  allow defrost also, and to cool down the compressor if something happens (a door left open)
  • An automatic backup if something fails (a mechanical thermostat is not prone to fail like an electronic)


My thermostat while I was testing it

So with all this a made a simple program in a PIC16F88, a use a LM335 for temperature sensing and two relay: one for the thermostat and another one (using an NC contact) to put in parallel the old thermostat in case of power fail (my PIC power source) or a cut in the sensor cable (implemented by software).

As I don’t wanted to deal with buttons, displays and so, I use a piece of code from other project: a home network over RS485. I’ll write some day about it, but basically I designed (from the ground) a communication protocol between several slaves (pic’s) and one host (a PC). I plan to use it to automate my future home, but so far I have three devices in my network, one of them: my fridge.  So, with commands, from my PC I can change temperatures , times and turn on and off the fridge. And everything without any button or display. But also I can log the temperature over the time.


Temperature over time. The two anomalies where the door opening (dinner 10pm, a coke 1.30am)

I plan to use that (objective) information to make some investigations regarding how the fridge performance is related to: refrigerant pressure, insulation, distance from the wall, room temperature, etc. And also, to find the right mass to the sensor, because it’s not a good idea to leave the sensor naked to the air, because if you do it that way when you open the door the temperature will raise (temporary) and the fridge compressor will start. But what is important is the food temperature. So I think that the mass of the sensor should be equal to the less massive peace of food that is sensitive to temperature. But that’s theory… I’m not sure yet.

I have a really long wish list (It’s incredible how many things I would like to add to my fridge if I had the time) But so far I ‘m very happy with my fridge with RS485 interface ;)

Posted in Uncategorized | Leave a comment

Religion is dangerous

“Religion is dangerous because it allows human beings who don’t have all the answers to think that they do”

Bill Maher

Posted in Uncategorized | Leave a comment

How to keep fresh basil, parsley and others vegetables

I use to grow some plants (wink, wink), sometimes from seeds, sometimes cloning. To make a clone basically you cut a branch, put in water and wait until it grow roots. Because during the process the plant doesn’t have roots you have to minimize the water loss. There are a lots of ways, but all of them uses the same principle: put the leaves in high humidity environment; you know, if there is a 100% relative humidity the water won’t evaporate, so the plant won’t lose it. For example I use two half bottoms of coke bottles to make a sealed container.


But well, I used to do it, so when I buy basil or parsley, I put it in water, and I covert it with a plastic bag, I do it automatically. But I didn’t realize that most people doesn’t know that.


Hacking a plant this way you will have a fresh and crunchy leaves for many days, even eventually they will grow roots and won’t needed the bag anymore.

Posted in Uncategorized | Leave a comment

High Altitude Balloon – First test

Great night!… I just finished the first integration test of my High Altitude Balloon project, and worked perfect!

This afternoon a put all pieces together (well… if we can say that), and test almost everything but get a GPS lock.


Because I live in an apartment in the middle of Buenos Aires it’s nearly impossible to get a lock from here. So I went to the roof and I left “the thing” (I have to think in a name) with a Gel Battery, and come back to my apartment.  Wasn’t easy, I left alone a lot of work, and imagine that thing with a Gel Battery, and three or four leds blinking… in the state of social paranoia we are living, just one led blinking is enough: a bomb about to explode.

But well, once in my apartment I stared the screen for 10 minutes until I get 4 satellites and a lock!

First Lock<- My custom telemetry soft ;)

In the next post I’ll will write about the technical details of… the thing. Now I’ll celebrate.

Posted in Uncategorized | 1 Comment

Dirty Power On

I think my high altitude balloon is consuming a lot of (my) resources. But well… another hack related to the same project.

My primary communication channel is over UHF, modulating in FSK. But I cant rely in just one communication channel. So I think in a cellphone. A typical implementation is to send a SMS over the phone with the coordinates. But that means to deal with some obscure and undocumented commands and interfaces. Not to mention: to have the right cellphone.

So I have another idea: why not to call the cellphone and receive the FSK modulation over the line?. For that I needed to things:

  • A way to power up the phone when I energize it
  • A way to answer the call

Yes, I could use a μC, but I think in a simpler way. To power up the phone I used a capacitor in parallel with the Power key. So, when I energize the phone * the capacitor will be a short until it charges. Playing with the capacitor value I can change the “button pressing time”. And a resistor in parallel will discharge the capacitor for a next power up.

And to answer the call automatically I use a NPN transistor to short the Answer button, and the base that transistor connected to the vibrator output,  so when I call, I close the circuit and answer automatically.


*You may be wonder why instead of energized the phone not to press the power button. Well, during the fly I’ll power up the phone several times (mostly to save energy, because in at some highs there is no signal and when that happens the phone increase the tx power, consuming a lot on energy). So, with this configuration when I energize the phone I’m sure it is power on, and when I de-energize it I’m sure it’s off and not consuming energy. In short: I can control the phone without any feedback, and I can be pretty sure it is in the state I want it.

Posted in Uncategorized | Leave a comment

High Speed Photography

I like photography, and as geek a like to take “tech” photographs. High Speed Photography is one of those. A classic is water balloon exploding, but to freeze the moment when the balloon is exploding we need to understand the timing. All action happen in, lets say,  5mS. Very little time. But the main problem is when to shoot. Yes, you can do it manually trying many times, until you get the shot. Or you can do it right. A typical DSLR camera has a delay of ~100mS from the time you press the shutter (or remote shutter). So if we detect the balloon exploding and we send a signal to the camera shutter we will take a shoot of… nothing, we’ll miss the action for 95mS. So we have to use another technique: we will arrange everything in a dark room, we open the shutter (bulb mode), and when the balloon explodes we… well, some electronic device, fires the flash. A flash has nearly no delay and a duration of (depend of the power) ~0.1mS. It’s perfect!

We juts need some way to detect the balloon exploding and fire the flash. First I use a mic with an amplifier + a comparator.


And worked very well… but the flash fires when the action started, and I want to see what happen after. So I made a “delayer” with a PIC microprocessor in order to add a variable delay to the signal.


Sorry, I don’t have the schematics, I made it on the fly. But it’s very simple.

And was amazing!… I could get the exact moment I wanted.

IMG_4360More pictures here

And a picture of my bathroom (sorry) with all the setup. You can see the camera, the flash, the “delayer” and the mic (near to the balloon).


Posted in Uncategorized | Leave a comment

Pyrotechnic Release Device

My high altitude balloon needed a reliable and lightweight device to release the balloon in the case it remained neutrally buoyant.

I saw some implementations with a nichrome wire (melting the rope), but I don’t like it: too much current, big MOSFET, another battery pack. And let’s say it: not enough spectacular, and dangerous ;) So I decided to make my own pyrotechnic device.

Pyro1 Pyro2

For the fuse I used a very thin wire from a regular kitchen steel wool. With just 200mA it start to melt and burn. I put the fuse in one end of a plastic tube (from a ball-pen tank) and  just a wire loop in the other. And YES!… black powder in the middle. Guaranteed an spectacular balloon release with very little power!

Posted in Uncategorized | Leave a comment