Category Archives: Science

Battery-less switches: The next big thing in IoT ?

Internet of Things, or IoT as it is popularly known, needs no special introduction as it has been making rounds for quite a few years. As I am writing this, I know there are probably million other researchers in thousands of laboratories around the globe, sweating it out to come up with something new in this field. IoT relies on good quality sensor data at the right time in the right format, which is why energy harvesting wireless sensors are of special interest.

Imagine, being able to control your air-conditioner or television through a remote which doesn’t need a battery; yeah, you read that right. This is one of the many applications that energy harvesting switches can offer.


EnOcean, a Siemens spin-off, is a leading batteryless switch manufacturer with open APIs available for researchers to  play around and hook it up with other IoT devices. It uses a piezoelectric generator,  and the mere mechanical pressure generated by pushing the switch generates just enough electricity to transmit a unique switch code. Range of the switch comes in at around 120 meters which should give end-users plenty of flexibility. Two way communication is possible with EnOcean and the datarate comes around 125 kbps (For more info and comparison of EnOcean with other IoT technologies, refer to my paper here)


Refer to enocean website here for details on motion energy harvesting.

Today, energy harvesting wireless technology is very well established for providing M2M (Machine to Machine) solutions in the building automation sector, bridging the control of light, HVAC and other fields of building technology to smart home, smart metering and energy management systems. This is the starting point to actuate further applications that lead to the Internet of Things in the long term.

For hobbyists, hooking up a EnOcean switch to your home automation network is not a Herculean task. There are open source automation applications like OpenHab available which can do the task seamlessly.


MG811 CO2 Sensor with Arduino

The MG-811 sensor is highly sensitive to CO2 and moderately sensitive to alcohol and CO. It could be used in air quality control, ferment process, in-door air monitoring application. The output voltage of the module falls as the concentration of the CO2 increases.

It is available as a breakout board like this from dfrobot or you may opt for the sensor only option, in which case you might need an external amplifying and conditioning circuit.


It has an onboard heater which needs a separate 6V supply , but if you are getting the breakout board this can also be eliminated as the circuit itself takes care of heater supply voltage.

Connecting to arduino and getting the data is a fairly simple process. What I suggest would be to write a simple program like the one below to get the output values in terms of mV first against some known PPM values. You might want to get a high precision NDIR monitor or PPM monitor for this.

int sensorValue = analogRead(A5);
float voltage= (sensorValue * (5.0 / 1023.0))*1000;

Note down all the output voltage values against the known PPM values (ranging from around 300 ppm to 1000 ppm maybe) and plot a graph in excel. Add a trend-line and use curve fitting tool to get a logarithmic formula, something like the one shown below. You cannot always depend on the formula you get from web because the amplification factor of your particular breakout board might be different and it is always better to work reverse and get the formula by using a standard CO2 monitor.



Since the output voltage is directly proportional to this logarithmic function, you may use this formula in your code to convert the values to PPM.

float refy = (voltage-264.76)/-17.644;
float ppm = pow(2.71828,refy) * 10000;

Note: This piece of information is supposed to be used for demonstration only. More sophisticated calibrations are required for industrial applications.

Remote /Cloud Air Conditioner Control using Arduino, Bluetooth and J2EE

So, we have this very old air conditioner in our lab with a wired thermostat, which basically works alright but doesn’t have a remote control. The air conditioner is so old that the spare parts of this system are not even available in the market right now. As part of making everything “futuristic”, we decided to do little tweaking to enable wireless cum cloud control for this thingy.

The initial step was to check how the system works. The thermostat is DC powered and have its own proprietary protocol for sending commands and signals to the machine. Examining the terminals of the ON/OFF switch with a multimeter revealed that shorting the terminals for a few seconds would send the ON/OFF signal to the system. And I guess, this is how most of the thermostats, irrespective of the brand, do the job.

Now that we know how to turn ON/OFF the system, time to gather the hardware. Do reverse engineering, what needs to be at the end of the system is a Relay, which can do the “shorting”. And what can power the relay? A 5V signal. And where should it come from? From an output pin of Arduino. And what should trigger the signal? A command from PC/Mobile/Tablet. And how should the command be transmitted. Via Bluetooth/Zigbee/Wi-Fi. Here we use Bluetooth, because the hardware is comparatively cheap, and it can be easily integrated with Arduino. So here it goes, the complete hardware and software list for making this system.

1. Arduino (Can be any. Here I use Uno)
2. Bluetooth Adapter for Arduino HC-05 or HC-06
3. 5V Relay
4. Wires and Jumpers
5. Breadboard/ Soldering Board
6. Arduino Programming Software
7. Eclipse IDE where we run the Dynamic Java Application for web interface.
8. Serial Terminal for Windows, For Example TeraTerm
9. Bluetooth Serial Terminal Software for Android (Optional)
10. And obviously the thermostat connected to AC and a little bit of patience 😉

Start by wiring the HC-06 to the Arduino. Connect the TX pin of HC-06 to the RX pin of Arduino. Connect the RX pin of HC-06 to the TX pin of Arduino through a voltage divider. Connect Vcc(5V) and GND pins of HC-06 to respective terminals (Refer figure).

Take the output from any of the Arduino digital pins. In my case, I used pin number 10 (Of Arduino Uno). This output is connected to one of the the energizing coil terminals of the relay. And the other pin is connected to the GND. The outputs of the relay are connected across the ON/OFF terminals of thermostat.


Time to program the Arduino. Set the pin 10 as output and make it LOW and HIGH with a delay of 1 second. Why because the shorting has to persist for a second for the thermostat to turn ON. Do the same thing for turn OFF process as well. During programming, make sure you disconnect the HC-06 from Arduino.

char VAL;
int AC = 10;
void setup() {
pinMode(AC, OUTPUT);
void loop() {
Serial.println(“AC CONTROL \n”);
Serial.println(“Press 1 to turn ON or 0 to turn OFF”);
while (!Serial.available());
VAL =;
if(VAL == ‘0’ ) {
digitalWrite(AC, LOW);
if( VAL == ‘1’ ) {
digitalWrite(AC, HIGH);
}Now that the entire hardware setup is ready, we should check if this really works. Pair your laptop or PC with the HC-06 (Obviously, your machine should have Bluetooth. Use a Bluetooth adapter, if it is not available inbuilt). The password should most likely be “1234”. Open a serial terminal, for eg TeraTerm. Connect to the respective COM port. Type “1” to see if the relay is working. You can also use Bluetooth Serial Terminal for Android to check.

To enable local control using a web application, we should make a dynamic Java application and run it on a local server. Import RxSerial and RxParallel libraries for Java. Open the respective COM port, set the Baud Rate to send the commands. For the front-end, use JSP-JSF or HTML-5 to create a simple web page. Note that for cloud control, the program should be written in such a way that the web app should send a signal to the local machine which is connected to the HC-06 via Bluetooth. This signal should trigger opening the COM port on our local machine.

Export this application as a WAR file and upload to cloud server. The cloud server should support JSP-JSF /HTML and should also have an application server like Apache Tomcat. Do note that the local web application and the server should be running the same version of the Web Server; Tomcat or JBOSS or whatever. Otherwise, there might be problems launching the application from Web.


You could also make an Android application to do the control from mobile or tablet. Bluetooth Terminal Apps are available though, as I already mentioned.

That’s it. Restart your application server after deploying the web application. And voila!! You can control your AC from web. Further modifications like temperature control, auto scheduling ON/OFF can be done easily. But yeah, once you are done with the basic stuff, you can always build on top of it. 🙂


Rahul Ashok