Electric Imp Temperature and Humidity Sensor Followup

This post is a followup from my post here about my Electric Imp based Temperature and Humidity sensor.

I left my sensor my the deck of my apartment starting on January 25, 2015 and it has been running up until September 17, 2016 on the same set of batteries. For the past almost 22 months it has woken up every hour, read the temperature and humidity and posted it to the internet.

This is the temperature data measured by the Silicon labs Si7021 Temperature/Humidity sensor:


There may be some erroneous readings as I don’t think the temperature spiked up to 50° C on my balcony but overall the readings usually seemed believable.

Here are the battery voltage measurements over the course of the test:


There is the occasional spike down where i believe it was a day where the electric imp servers had down-time or the electric imp software had an update where the device was online for longer than expected. One bug I noticed was that if the servers were down it would stay online trying to communicate with the electric imp servers and drain power. To improve this there should be a timeout implemented where if it cant communicate with the servers after a couple seconds it will give up and shut down, but I will be the first to admit I am not the best embedded software developer.

Overall I was impressed with the amount of battery life that I was able to get out of this mostly due to the low sleep current of the electric imp.

Another idea to improve the battery life would be to use a low power timer to cut the power to the WiFi device when sleeping instead of using sleep function of the microcontroller


This has a current consumption of 30nA compared to the ~8uA of the electric imp’s sleep mode. Which could be set to periodically wake up the microcontroller and then cut the power so that the sleep/off current is extremely low.


Electric Imp Based WIFI Power Switch

My quest for home automation has been slow but I have made some progress. The first thing I wanted to control was some of the lights in my apartment from my phone.

WARNING: This project contains mains power which can be dangerous; beaware this project has not passed any safety compliance testing. I hold no responsibility if anyone tries to reproduce this project

Since I had used the Electric Imp before I designed a board with the electric imp IMP001 module that would switch a relay when sent a command from the internet via my phone. The electric IMP module and relay get power from the mains from an AC/DC converter module from CUI VSK-1S this is a neat little module that takes in 85 to 305Vac and outputs 5V 200mA max power which is more than enough to power this project it’s also UL recognized and is CE compliant. For safety I added a fuse and an MOV to the mains.

Electric Imp WIFI Power Switch PCB

I also updated my Android application which I had made to monitor monitor my temperature and humidity sensors to send HTTP requests to the Electric Imp servers when then send the request to my board which  then turns the relay on and off.

Home Control App

I then designed a simple enclosure and 3D printed to finish it off.

WIFI Switch Enclosed

It was a simple project but fun and useful and am looking forward to making more projects to continue automating my apartment. One issue I had with this solution was the cost, the full BOM cost came to around $90. A big part of the cost was the Electric imp module and support circuitry needed for it. One option would be to change to the ESP8266 which is an inexpensive WIFI chip that’s getting really popular but would require a bit more software work since I wouldn’t have the Electric Imp server back-end. But that’s a project for another day.

Schematic Here


Electric Imp Temperature and Humidity Sensor

Continuing the project from my last post. I designed a PCB for my Electric Imp sensor but instead of the 10K thermistor I used on the prototype i changed it to use the Silicon Labs Si7021 Temperature and Humidity sensor. This sensor allows me to measure and trend both the temperature and relative humidity with pretty decent accuracy; it’s specced at +/-3%RH (from 0 to 80%) and +/-0.4 °C (from -10 to 80°C). I also added a boost converter from the battery to the electric imp so when the battery voltage gets below the threshold needed for the Wifi to operate (2.5V) it will get boosted to about 2.8V so that I can still use the remaining energy in the batteries.

Electric Imp Temp/Humidity Sensor

From testing I found the boost converter works well but if the battery voltage is too low the startup current of the electric imp will cause the board to brownout before it has time to enable the boost converter. I found this happens at battery voltages less that about 2.2V. Probably adding more low ESR bulk capacitance on the Electric Imp’s supply rail would help with this.

I originally designed it to use an off the shelf case but eventually just decided to 3D print a case for it. I would like to redesign this at some point to make it smaller; it’s pretty bulky right now especially in the case.

Electric Imp Sensor in it's Enclosure
Electric Imp Sensor in it’s Enclosure

I setup the electric imp to wake up once per hour read both the temperature and humidity and post the data to Thingspeak.com. I built two of these sensors and placed one inside my apartment and one out on the deck. To read the sensor data I wrote a small Android app that reads the last sensor reading plus pulls in the graphed data from the last 5 days.

From the bit of testing I have done I expect to get at least a year off two AA batteries but probably much better than that.

(Left) Android App Main Page (Center) Plotted Sensor Data (Right) Plotted Batter Voltage
(Left) Android App Main Page (Center) Plotted Sensor Data (Right) Plotted Batter Voltage

The schematic for the sensor is located Here:

Wifi Temperature Sensor Schematic

Next I want to build a Wifi power switch and expand this Android app to be able to control things in my apartment using the electric imp platform and after that maybe some wifi controlled LED lights for my workbench.


WiFi Temperature Sensor Testing Continued

Continuing from my last post here about my Electric Imp based WiFi temperature sensor.

I left my prototype sensor running for 14 days before it stopped transmitting which isn’t nearly the batter life I want out of this but as I said in my last post I was getting anywhere between 800uA and 2mA of current consumption when it was asleep which was way too high.

Here is a plot of the battery voltage over the 14 days the sensor was running:


To show it was working and because I like to make graphs here is a plot of the temperature readings over the same time period:


From the battery voltage graph you can see it drops off very quickly, also you can see all those sharp dips. I’m not sure what was causing that I did add a 1000uF capacitor in parallel with the battery to help with the peak power consumption from the WiFi transceiver but maybe the ESR of my capacitor was too high, I’m not sure.

After the battery died I decided to investigate why the sleep current consumption was so high. After looking into it I found that that all the current consumption was from the buck converter on the Electric Imp development board. Since it is a 3.3V buck converter and my battery voltage is 3V max I didn’t need it anyway. Anyway after I modified the board to bypass the buck converter the current consumption dropped significantly to around 31uA.

CurrentNot quite the 6uA sleep current that the Electric Imp datasheet quotes but much better. Even through there is no power going into the buck regulator’s input anymore there might be some leakage currents through the output and/or feedback pin. This current consumption would probably drop if i removed the chip altogether.

Picture of board with buck regulator bypassed:


With this change I have only had it running for 24 hours so far but the batter voltage looks a lot better and I’m thinking I should get much better battery life out of this.


Well I am going to leave it running and see how things go. Next step is to design a permanent board for the WiFi sensor with a boost regulator so I can get all the power out of my batteries.



AC and DC Dummy Load

I wanted a variable load for 24VAC that would go up to at least 12VA. Before I would connected power resistors in series but that gets troublesome when you want to change the load with a fine resolution. There are variable power resistors or rheostats but they are big and clumsy and from what I can tell expensive. So I decided to design a little variable AC load that would simulate a resistive load and that would also work with DC. After a bit of work and one board spin I came up with this:

AC Load


Load Circuit

It works like the standard DC load that you can find all over the web with an op-amp that drives an N-Channel MOSFET with a current sense resistor but on this one I added a P-Channel MOSFET in series. This way during the positive half of the AC waveform the body diode of the  P-Channel MOSFET conducts and the  N-Channel MOSFET provides the load and then during the neagtive half of the AC waveform the  the body diode of the  N-Channel MOSFET conducts and the  P-Channel MOSFET provides the load.

To turn of the MOSFETs the op-amp needs to drive the N-Channel FETs gate positive and the P-Channel FETs gate negative so I added a simple +/- 10V supply. First I bring in power through USB just because that is a simple and easy was to get 5V, also I thought I might redesign this with a micro-controller at some point that will be able to do more complex loads. The 5V is fed into a voltage doubling charge pump and then that is fed into an inverting charge pump.

When the voltage to be loaded is connected to the device it is divided by R1 and the potentiometer R3 which provides the set-point for the control loop this makes the load dependent on the voltage which means this simulates a resistive load unlike most DC loads which are constant current loads.



I had a few issues with this design to begin with:

  • First originally I had one gate resistor that was shared between both mosfets but I was getting some very high frequency oscillations when ever the N-Channel FET turned on, isolating the MOSFETs with separate gate resistors solved that issue.
  • Next I had trouble getting the control loop stable; originally I used the jellybean part TS321 for the op-amp but no matter what combination of gate drive resistor and compensation capacitor I couldn’t get it stable. I changed the op-amp to the fancier LM7321 which is a higher current output and unlimited capacitive load op-amp and with that I got the control loop stable.

One thing I would do if I do another revision of this design would be to add more protection. I have damaged it a few times by connecting the load power without connecting the 5V.

Full Schematic:

Variable AC-DC Load

Anyway this was a fun little project that I wanted to share :)


Wifi Temperature Sensor Testing

Electric Imp CurrentLike I said in my last post I’ve decided to rethink my wireless temperature sensor. Instead of using a local wireless protocol like ZigBee or the Nordic Semiconductor 2.4GHz wireless. I want to investigate using WiFi instead. After doing a bit or research I found the Electric Imp WiFi modules (Electric Imp) look like they might be a good fit. They should have a low sleep current (<10uA) and seem to have a lot of support for the software side which is where I usually am lacking in my projects; I’m fine designing hardware but get frustrated with software development easy.

With some very quick back of the napkin calculations I figure that I can have one Electric Imp Running off 2 x AA batteries that logs the temperature and sends it out to the internet every hour and have it last at least a year on one set of batteries. Yesterday I bought and Electric Imp IMP001 module and a breakout board. I powered it with 2 x AA batteries in series and set it up to log the temperature of a thermistor and the battery voltage. With a  little bit of code I have it sending the readings out to Xively; I used them when they were called Cosm on a previous post.

Electric Imp Test

Here are the live feeds from Xivley for the past 24 hours for both the thermistor temperature and battery voltage (Sorry to all future readers if these go down eventually)

Now this isn’t a perfect test since the Wifi on the Electric Imp module with cut out when the voltage reaches 2.5V or about 1.25V per cell and Alkaline AA batteries are fully drained when they get to 0.8V per cell. So at some point I will need to design a board with a boot converter so I can utilize the full capacity of my batteries.

I did some testing last night to measure the current draw of the Imp module and found that my sleep current was a bit higher than what is specified in the datasheet; I was getting around 800uA but that’s most likely I have it setup wring and not going to sleep fully. I did make sure that I am controlling the thermistor properly which a GPIO pin so that isn’t wasting current when the device is asleep. I also measured the current when it wakes up and transmits.

Electric Imp Current


This was measured through a 10 ohm resistor so we have a peak current of about 130mA and an average current for the whole transmit pulse of about 50mA for 75ms. So that’s not bad as long as it’s not waking up very often I should get pretty decent battery life. I think when I have the whole thing setup I will probably have it text or e-mail me when the batteries get low.

Going forward on this project I think I am going to have to get another electric imp module so I can do some more development while I leave this one running and I will work on my own board with a boost converter and maybe some other sensors to connect to the Imp.


Wireless Temperature Sensor Rev 1.0

Well in the past I had talked about wanting to do a big home automation project and to start with that I wanted to design a battery powered wireless sensor node that I could place around my apartment. The first iteration of this design was posted here http://andrewswanton.com/?p=780 but I had problems with the PIC24 microcontroller I designed in to that one.

I have been wanting to get some experience programming Atmel AVRs since they seem to be very popular and look like very nice little 8-bit microcontrollers. I took the same basic design of the last revision and replaced the microcontroller with the Atmel ATmega168. Since these are very popular microcontrollers so I figured there would be a lot of libraries already done to me getting it up and running quicker. Although, this microcontroller doesn’t have all the fancy low power features of the low power series PIC24 used in the last version but I figure that I get get the power consumption down by having it sleep most of the time and then just quickly wake up every once and a while to read the temperature sensor and then transmit.

Here is picture of the populated board with the NRF24L01 wireless module.

Sensor Rev 1 Layout






Wireless Temperature Sensor Rev 1_0

Now I actually designed this a while ago and am just getting around to posting about it now. Since designing this board I have been thinking about the whole system design and am thinking about taking a different approach. Instead of having this local network of sensors that talk to a main “server” in my apartment why not jump on the “Internet of Things” bandwagon that everyone else is doing and make it Wifi enabled. This eliminates having to deign a support the local server portion of the system and I could have the devices talk to some sort of “cloud” service. Anyway it’s just an idea and I will post more about it in the future and if it doesn’t work out I can always come back to this design.


Wireless Temperature Sensor

Since I am done with school I want to get back into doing some hobby electronics a project I posted about before was wanting to build a home automation system.

This was to consist of multiple wireless sensors and IO points around my apartment controlled by one central server.

To start this project up again I have designed a small battery powered temperature sensor. The idea would be that I could have one of these in each room of my apartment and they would measure and send the temperature back to the central server wirelessly.

This first board is going to be a prototype

Wireless Sensor


I have designed it around the Microchip PIC24F16KA101 it’s a fairly low cost, low power 16-bit mircocontroller from Microchip. I have designed i two wireless trancievers, the XBee module I used on the Quad-copter and a module using the Nordic Semiconductor NRF24L01. The Nordic Semi one is much lower cost and lower power if it works out I will design another board with the chip right on it instead of using the module. But since I have experience with it and there is some risk the Nordic Semi part wont work out I designed in the XBee module as a backup.

This while thing is going to be powered by a singe CR2032 coin cell battery, so battery life will be a concern but with with some good software I think I can get it to last a good long time on that battery.


I will send off the Gerbers this weekend and will post more about it once I have something up and running.


Capacitive Touch Business Card

Buisness Card


I wrote a post about my design for a capactitive touch business card a few months ago but I have finally had time to build it up and test it out. overall it works well but I could make some improvements. Here’s a quick video of it working:

To implement the capacitive touch I used the PIC10F206 microcontroller. I chose this microcontroller over something bigger like a PIC12 or PIC16 or MSP430 because like the simplicity of this very low cost, low power, 6 pin micro controller.

Here’s the circuit for implementing the capacitive touch

Buisness Card Circuit

The theory of how it works is that the timer in the microcontroller is used to send a train of pulses out of pin 4 of the microcontroller:



These pulses charge the capacitor made by the capacitive touch pad on the PCB. The voltage on this pad is monitored by the internal comparator on the mircocontroller on pin 1 and it discharges through the resistor R1. The next picture is a scope capture of the voltage on the capacitive touch pad when there is no finger on the pad. (Note that the capacitive of the oscilloscope probe does add enough capacitance to trigger the comparator but we still will be bale to see a difference when a finger is on the pad). Here we can see that it chages up fast when the output goes high and when the output goes low the capacitor cannot discharge through the output due to the diode blocking it, it can only discharge through R1. The larger the capacitance of the pad the slower the discharge which means the bottom value of the ripple will be smaller.


Here we can see the effect of a finger on the capacitive touch pad; there is more capacitance  on the pad and that makes the minimum values of the ripple lower. The internal comparator on the mircocontroller has a 0.6V reference voltage so when the minimum values of the ripple drops below 0.6V it triggers the comparator. If the comparator does not get triggered for a certain amount of pulses set in the software it determines that the pad had been touched and it turns on the LED output.


That’s the basics of how the capacitive touch works on this board, which is one of many different ways it can be implemented.


Sensor Datalogging with Cosm


Continuing with the Home Automation System I talked about in the last post I have been working on the datalogging server portion of the project. The purpose of this is to receive sensor data from the sensors in my apartment and server them on an internal websever and post them on Cosm for logging the data. I chose to use Cosm.com to log the sensor data since there is a very limited amount of onboard memory on the ATMega328 on the Arduino board and this way I don’t need to have external memory.

To test out the Arduino’s ability to function as my home automation system server I bought an Arduino Ethernet Shield and connected a 10K Ohm thermistor with 10K pull-down to the analog input on the Arduino board. I wrote a program that reads the analog input and posts it to my Cosm feed. I added a bit of software filtering to the ADC reading to smooth it out a bit, adding a capacitor to the ADC input may help as well but it’s working reasonably well for not

Here is a plot of the temperature in my apartment over the last 5 mins in degrees Celsius.

Using the Ethernet shield I also setup a little web server that posts the current temperature and pulls the graph from COSM to show the temperature over the last 5 mins. This webpage refreshes automatically every 5 seconds. I might try to setup dydns so I can access it from outside my apartment. I think I could also add controls to this web server so at some point I may be able to control the lights or temperature through it.