Host Software

Rather than re-invent the wheel, I thought there should be software out there that provides SCADA/HMI functionality for free. It is a commoditized activity by now.  After combing the web, I stumbled and settled on Mango, an open-source M2M solution. Mango is Java based that integrates with MySQL and runs under Apache. All good stuff so far.  The web site describes the features and how to install the software.  I liked the data historian, alarms, and the various types data points including calling external web based sources. I set one to get the external temperature at the airport and using regex to scrape of the temperature form the HTML. All within Mango.

I found it relatively easy to get going. One thing I had to do was write a Modbus function 6 (write a single register) for the Arduino in C as I want to send commands to the arduino. i.e. set the time for example.

The diagram below shows some of the points I configured to handle the home energy monitoring. I used ISA motivated nomenclature to name the tags. I may revert to a human readable tags as I won’t have hundreds of points and becomes cryptic after a while.


Data logging for each data point is configurable as shown in the screen shot below. The example is for the temperature in the basement. All of this info is in the MySQL database from which one can chose to slice and dice the data later on using external tools.


As for graphical objects, one can create custom objects e.g. dials, meters, etc. and assign tags to them. When this is all done I will add an iPhone friendly UI to this so I can interact with the home energy system on the road. One thing that Mango does is allow me to work on my solution rather than re-inventing the wheel.  I know have the facility to hook up multiple ardduinos and focus on the fun stuff which is the embedded side of things.

Just XBee Left Wire

I finally got around to spend some time on this and got everything on a perfboard . I also included a temperature sensor (LM35) along with a button to select the LCD display mode.  If I had to change one thing, I would chose different connectors so I can disconnect the current and voltage sensing wiring without screwing on a terminal block. I removed the CT and voltage wiring to the terminal block in the picture.


Given that I will be working with two current transformers any open circuit can be lethal. I will  add a switch that short circuits the secondary before I disconnect from the terminal blocks. The last piece to connect will be a XBee chip to send the data to the master. As stated early, I am using Modbus over serial as the protocol to communicate with the host.

One thing that did give me grief is that the temperature reading was erratic under certain scenarios.  I sampled the currents and voltage to get 2000 samples do some computations and then take a sample of the ambient temperature. If I did not perform the 2000 sample burst, I got a stable temperature reading. If I looped for sample 2000 readings then took a temperature, the temperature would be erratic.  I still don’t know why and my hunch is that it lies in the A/D mux in the Arduino.  What I did was take average 10 temperature readings with a delay of 20 ms between sample which led to a more stable temperature reading.

All that is left is to mount an XBee chip on the bread board and the hardware should be ready to stuff into an enclosure.