Home

Arduino

In order for your cell phone to control other devices, Heximus needs a way to communicate with them.  A sidenote to our readers.  Sure you can just buy an off the shelf OTS  home automation system but before you do, ask yourself these questions.

If you answered yes to every question above, you can bypass this section.  Others, please read on.

I may be wrong, but I will state here, the most cost effective solution is to use an Arduino board $10 and Bluetooth module $5.  For 15 dollars you have the foundation.  Then you simply buy the senors, relays, displays and a whole host of other gizmos that will plug into the Arduino board.  Included on this site is an Ardunio sketch to get you started.

Included with Heximus is a simple application that connects via bluetooth from your Arduino board back to your cell phone. Complete Arduino source code is given down below.

The app logs the temperature,humidity,voltage and time on the Arduino board and sends the data back to the Android device.  The data is stored in a circular buffer on the Arduino board.  Since memory is very limited on Arduino devices we cannot have large arrays to store months of data.  Therefore we pull the data from the Arduino before the circular buffer fills up.  This is done by the sample Heximus app in  Bluetooth.hex using the SetTimer method.

Note, that this sample uses things you may not be interested in, however they are easier to comment out than have to add them later The sample uses A LCD display which was only added to make debugging easier.  The sample code below defines a database schema, this is consumed by the Heximus app, which then creates a Sqlite database on your Android cell phone or tablet.  When the Heximus app reads the data via Bluetooth from the Arduino, the data is just a bunch of bytes but by using the schema defined below, the Heximus app can decipher the data and populate the database with new data.  Therefore, it is critical that the schema definition order exactly matches the Pack structure order.  A CRC is also computed on the fly and the code for CRC cannot be changed without a new version of Heximus, since both Heximus and Arduino share the same algorithm for CRC.  Since the Arduino is connected to the Bluetooth chip via TX0 and RX0,  you cannot upload a new sketch while the Bluetooth chip is powered on.  I simply attached Bluetooth VCC to a button switch to make this easier.  Another thing to note, is the Bluetooth chip transmit and receive require 3.3 volts.  The output of the tx0 on the Arduino board must go through a voltage divider before going to the Bluetooth chip.  Also watch for a loose ground wire, that happened to me so the full 5 volts went the to the Bluetooth chip.  It burned out. No magic smoke, but the result was the same.  A 1K and a 2K resistor work for a voltage divider,  however electronics is not exactly my trade.

The sketch also makes use the EEPROM,  I use the first 8 bytes, 4 for the interval, and 4 for timeoffset in seconds.  The reason I use EEPROM is in case of power failure, you want the board to carry on with the same values at startup.  EEPROM does wear out, but care is taken to only write to EEPROM if the value changes.

 

Different versions of Arduino boards, the main difference between them is the amount of onboard memory and number of input/output pins.

Arduino UNO board about 8$

Arduino Mega 2560 about 12$

Arduino Nano for about 5$

BMP180 module, monitors atmospheric pressure and temperature for about 75 cents.

As you can see from the prices above, using an Arduino with third party modules is a very cost effective approach to

home automation, monitoring and surveillance.

 You just have to follow the included bluetooth sketch and download Heximus from the playstore which are both free and ad free.