Michelangelo Guarise
Published

UPlug

A power consumption monitor Android application with UDOO

Full instructions provided1,860
UPlug

Things used in this project

Hardware components

UDOO DUAL
UDOO DUAL
with UDOO's Ubuntu
×1
Arduino Relay Shield
×1
Wireless Network
×1
Wall power cord with socked
×1
Current Sensor
×1
Rooted Android device
necessary to install the standalone .apk
×1

Story

Read more

Code

code.txt

Plain text
sudo apt-get update
sudo apt-get install open-jdk-6-jdk

code.txt

Plain text
cp/opt/arduino-1.5.4/lib/librxtx-* /usr/lib/jvm/JAVA_VERSION/jre/lib/arm/

code.txt

Plain text
sudo nano /etc/rc.local

code.txt

Plain text
sudo stty -F /dev/ttymxc3 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

code.txt

Plain text
ln -s /dev/ttymxc3 /dev/ttyUSB0

code.txt

C/C++
#include "EmonLib.h"                   // Include Emon Library

EnergyMonitor emon1;                   // Create an instance
boolean isOn  = true;
int relay_pin = 8;

void setup()
{
  Serial.begin(115200);
  pinMode(relay_pin,OUTPUT);
  emon1.current(0, 111.1);             // Current: input pin 0, calibration.
}

void loop(){
   while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    
    if(inChar=='1'){
      relay_pin != relay_pin;
      digitalWrite(relay_pin, relay_pin);
    }
  }

  double Irms1 = emon1.calcIrms(1480);  // Calculate Irms only
  // calibration parameters
  Irms1-=0.33;
  Irms1=Irms1/4;
  Serial.print("<");
  Serial.print(Irms1*230.0);
  Serial.print("#");
  Serial.print("0.0");
  Serial.println(">");
  delay(1000);
}

code.txt

SQL
--
-- Database: `Uplug`
--

CREATE DATABASE `Uplug` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

USE `Uplug`;


--
-- Table structure for table `Powers`
--

CREATE TABLE IF NOT EXISTS `Powers` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `TimeStamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `Power1` float NOT NULL,
  `Power2` float NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


--
-- Table structure for table `Labels`
--

CREATE TABLE IF NOT EXISTS `Labels` (
  `ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `TimeStamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `Labels` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Github

https://github.com/openenergymonitor/EmonLib

Github

https://github.com/UDOOplug/Uplug-server

Github

https://github.com/UDOOplug/Uplug-andorid-client

Github

https://github.com/UDOOplug/Uplug-sketch

Credits

Michelangelo Guarise

Michelangelo Guarise

7 projects • 57 followers
Founder @ volumio.org , passionate maker, unpredictable developer, misunderstood creative. I do stuff, I build things.

Comments