fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Wifi Internet Boiler

Tue Nov 06, 2012 6:55 pm

frontend.png
frontend.png (21.99 KiB) Viewed 13495 times
After seeing a few people interested in this idea I thought I'd put what I have made up.

Currently its made up of a relay board, two switches to provide physical buttons for boosting the water and heating and a 16x2 LCD for display of the heating status.

The software is in two parts a java program that actually turns the relays on and off and a web based frontend that I can control from my phone/tablet or PC and allows me to set holiday times, schedules and groups.

Features:
Hardware
16x2 LCD display support
Physical boost buttons

Software
Unlimited number of on/off times
Independent water/heating controls
Ability to group schedules which can be activated/deactivated as needed (great if you work different shift patterns)

Downloads
https://github.com/james-jaynne/boiler-control
https://github.com/james-jaynne/boiler-control-php
Rough install instructions are included at the above links, I will endeavour to improve those if anyone is interested in using this.
BE AWARE IF YOU ARE MESSING WITH YOUR HEATING CONTROLS THIS IS LIKELY TO USE MAINS ELECTRICITY - BE SURE YOU KNOW WHAT YOU ARE DOING AND DON'T KILL YOURSELF.

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Thu Nov 08, 2012 8:08 am

gorstj wrote:Glad I found this thread. Ordering a new pi to try it.

Does anyone have any suggestions re: relay board for controling a combi boiler 'zerovolt' thermostat input. (basically when the two inputs are shorted the boiler is 'on', when disconnected the boiler is 'off'. I don't think there is any current passing).

Re: lcd board and boost buttons - I could not ifnd out off your github website what you used/what they were connected to?

Thanks
The LCD is a HDD44780 and this tutorial from Adafruit shows how to wire them up http://learn.adafruit.com/drive-a-16x2- ... i/overview. You can buy them from Adafruit but I got mine off Ebay for a few pounds.

The switches are simple momentary switches that you can get from maplins etc. The first or second edition of the magpi (free online) shows how you can wire them up.

I'm not sure how 0 volt boilers work - I'm not sure I believe that they are actually 0 volts as I'd have thought that using 3V or 5V would be easier to build a circuit round. In theory if it really were 0 volt you could just hook up a single GPIO pin perhaps with a zener and resistor to the boiler wires. Personally I would still use relay or optoisolator to make sure my Pi was protected. Again the first few editions (I think it was 3) of the magpi had how to wire up a relay - its dead easy - I'd use a 240V 3A one just in case its not as if the cost is large.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Mon Nov 12, 2012 2:55 pm

Thanks for the info.

Awaiting delivery of all my kit. Will let you know how I go!

Do you have a photo of your finished product?

How adaptable is the http code for being adapted for smartphone use +/- app?

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Mon Nov 12, 2012 7:05 pm

I don't have a pic of the fully cased final design - I really should take one - here it is though on a breadboard though.
Image
I don't have any trouble using the interface on my Android phone though it is best used in landscape. I only ever really use the boost function from my phone but you could easily change it to a pure phone interface just through css.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Tue Nov 13, 2012 4:54 pm

Have my new pi for the project but hitting a problem with the java app.

When I run

Code: Select all

sudo /etc/init.d/boilercontrol start
I get an error about

Code: Select all

Starting boiler control
/etc/init.d/boilercontrol: line 15: screen: command not found
/etc/init.d/boilercontrol: line 17: screen: command not found
I installed

Code: Select all

sudo apt-get install screen
and that error seemed to go away. But should 'screen' be really necessary?
However running

Code: Select all

ps -ef | grep boiler
did not find any boilercontrol process running.

So I ran

Code: Select all

sudo /opt/boilercontrol/startcontrols.sh
Error:

Code: Select all

Exception in thread "main" java.lang.NoClassDefFoundError: uk/co/jaynne/BoilerControl
Caused by: java.lang.ClassNotFoundException: uk.co.jaynne.BoilerControl
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: uk/co/jaynne/BoilerControl. Program will exit.
Any ideas
p.s. I installed Java with

Code: Select all

sudo apt-get install openjdk-6-jre
p.s.s. as you can see I am not that used to linux command line, but am getting there!

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Tue Nov 13, 2012 5:04 pm

Only if you're starting it with that script do you need screen - I use that to monitor the java program in the background.

There are three scripts I've included compileandrun.sh which compiles the source and runs it in the current terminal.
run.sh is the same but just runs it in the current terminal. These two are super simple if you look at them and are just to save some typing.
You run them like run.sh uk/co/jaynne/Boilercontrol.
The other script is designed to be stuck in /etc/init.d/ and used for launching the program at startup and shuting it down when powering off. It calls the run.sh in a screen which is a way of sticking something in the background. You can monitor it by typing sudo screen -r. You need to make sure that run.sh is working before using this otherwise you may find its erroring out and exiting the screen before you can open it.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Tue Nov 13, 2012 5:14 pm

A bit confused! Do I need to compile it first?
I tried

Code: Select all

[email protected] /opt/boilercontrol/java $ sudo ./compileandrun.sh /src/uk/co/jaynne/Boilercontrol
Compiling
./compileandrun.sh: line 5: javac: command not found
Done, running
Exception in thread "main" java.lang.NoClassDefFoundError: /src/uk/co/jaynne/Boilercontrol
Caused by: java.lang.ClassNotFoundException: .src.uk.co.jaynne.Boilercontrol
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: /src/uk/co/jaynne/Boilercontrol. Program will exit.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Tue Nov 13, 2012 5:20 pm

also tried above without /src/ at the beginning of the path with same effect

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Tue Nov 13, 2012 6:23 pm

gorstj wrote:A bit confused! Do I need to compile it first?
I tried

Code: Select all

[email protected] /opt/boilercontrol/java $ sudo ./compileandrun.sh /src/uk/co/jaynne/Boilercontrol
Compiling
./compileandrun.sh: line 5: javac: command not found
Here's your problem you're missing the java compiler javac. I've only tested with Oracles java runtime which you can install by following these instructions http://www.savagehomeautomation.com/pro ... -170u.html

I think its missing one additional command that you need to run at the end

Code: Select all

sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_06/bin/javac" 1
You should be able to run both java -version and javac -version and get the same answer at the end of this. You also need to move the contents of the src directory (the uk folder) into /opt/boilercontrol/java and run with the command sudo ./compileandrun.sh /uk/co/jaynne/Boilercontrol

It looks like I need to update my instructions and try following them with a fresh Pi install.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Tue Nov 13, 2012 7:07 pm

Thanks for your help. I'll try and document what I have done as I am going from fresh

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Wed Nov 14, 2012 8:38 pm

So I am running the latest version of raspbian..... which is hard float. So that means I can't run the oracle java compiler?

Can I steal a ready-compiled version off you? Or will that only work with soft-float distributions?

I can't even work out how to install an alternative java compiler.

On a better note I have built my relay and switch circuits!

Edit: I have a Ubuntu desktop system. Could I compile it on that and transfer it across? (p.s. I am not used to compiling things!)
Last edited by gorstj on Wed Nov 14, 2012 8:47 pm, edited 1 time in total.

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Wifi Internet Boiler

Wed Nov 14, 2012 8:46 pm

gorstj wrote:So I am running the latest version of raspbian..... which is hard float. So that means I can't run the oracle java compiler?
Correct.
gorstj wrote:Can I steal a ready-compiled version off you? Or will that only work with soft-float distributions?
It would be possible to run all java jars and classes compiled on a different system. You can for example compile on X86 and run on ARM, no problem.
gorstj wrote:I can't even work out how to install an alternative java compiler.
You can install the OpenJDK java compiler by running:

Code: Select all

sudo apt-get update
sudo apt-get install openjdk-7-jdk
this will give you javac!
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Wed Nov 14, 2012 8:51 pm

Ah ha! I installed the JRE...... downloading as we speak.

Will try again tomorrow! Thanks

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Wed Nov 14, 2012 8:57 pm

I've not tested anything other than the Oracle compiler - I don't see why openjre wouldn't work so give it a shot. If the openjre compiler doesn't work the runtime almost certainly won't. I can't post a JAR though as this version has the SQL settings in the code. I'd need to change it to use a config file or command line options to be able to give you a jar.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Thu Nov 15, 2012 9:23 pm

When I run compileandrun.sh I get the following error:

Code: Select all

[email protected] /opt/boilercontrol/java $ ./compileandrun.sh 
Compiling
javac: file not found: .java
I am a bit confused as to where certain directories need to be located after looking at compileandrun.sh

Which directory should /lib be in? Which directory should /java be in? Which directory for /uk ? I thought they had to be in /opt/boilercontrol

Code: Select all

LIBS=libs/raspberrygpio.jar:/home/pi/java:libs/commonsio24.jar:libs/mysql-connector-java-5.1.21-bin.jar:libs/framboos-0.0.1.jar:libs/pi4j$

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Thu Nov 15, 2012 10:11 pm

gorstj wrote:When I run compileandrun.sh I get the following error:

Code: Select all

[email protected] /opt/boilercontrol/java $ ./compileandrun.sh 
Compiling
javac: file not found: .java
I am a bit confused as to where certain directories need to be located after looking at compileandrun.sh

Which directory should /lib be in? Which directory should /java be in? Which directory for /uk ? I thought they had to be in /opt/boilercontrol

Code: Select all

LIBS=libs/raspberrygpio.jar:/home/pi/java:libs/commonsio24.jar:libs/mysql-connector-java-5.1.21-bin.jar:libs/framboos-0.0.1.jar:libs/pi4j$
Sorry I really should clear up the instructions

/opt/boilercontrol should have a directory called java inside java should be libs and the uk directory as well as the compileandrun.sh and run.sh scripts.

Both compileandrun and run are run as follows ./compileandrun.sh uk/co/jaynne/BoilerControl

I'll try and update the instructions this weekend and make the scripts more friendly as they were designed for me while I was prototyping so aren't as easy for someone else to use as they could be.

One thing another user had a problem with was compiling from the /opt/boilercontrol directory due to permissions issues - to solve this they had to run sudo chown -R pi:pi /opt/boilercontrol

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Thu Nov 15, 2012 10:44 pm

Looks like openjdk won't compile it? Is this what these error messages imply?
I will try and compile on my Ubuntu x86x64 box and transfer over to the Pi...... persumeably oracle run time will work ok on the hard float Pi raspbian?

I think eventually a pre-compiled version with a separate config file would work better!

Code: Select all

[email protected] /opt/boilercontrol/java $ sudo ./compileandrun.sh uk/co/jaynne/BoilerControl
Compiling
uk/co/jaynne/BoilerControl.java:18: error: cannot find symbol
		Thread scheduler = new Thread(new Scheduler());
		                                  ^
  symbol:   class Scheduler
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:22: error: cannot find symbol
		Thread wBoost = new Thread(new BoostMonitor(ControlBroker.SWITCH1, true, false));
		                               ^
  symbol:   class BoostMonitor
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:22: error: cannot find symbol
		Thread wBoost = new Thread(new BoostMonitor(ControlBroker.SWITCH1, true, false));
		                                            ^
  symbol:   variable ControlBroker
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:25: error: cannot find symbol
		Thread hBoost = new Thread(new BoostMonitor(ControlBroker.SWITCH2, false, true));
		                               ^
  symbol:   class BoostMonitor
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:25: error: cannot find symbol
		Thread hBoost = new Thread(new BoostMonitor(ControlBroker.SWITCH2, false, true));
		                                            ^
  symbol:   variable ControlBroker
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:27: error: cannot find symbol
		Thread wConfigBoost = new Thread(new ConfigBoostMonitor("toggleWater", true, false));
		                                     ^
  symbol:   class ConfigBoostMonitor
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:30: error: cannot find symbol
		Thread hConfigBoost = new Thread(new ConfigBoostMonitor("toggleHeating", false, true));
		                                     ^
  symbol:   class ConfigBoostMonitor
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:33: error: cannot find symbol
		Thread lcd = new Thread(new LcdOutput());
		                            ^
  symbol:   class LcdOutput
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:82: error: cannot find symbol
		ControlBroker control = ControlBroker.getInstance();
		^
  symbol:   class ControlBroker
  location: class BoilerControl
uk/co/jaynne/BoilerControl.java:82: error: cannot find symbol
		ControlBroker control = ControlBroker.getInstance();
		                        ^
  symbol:   variable ControlBroker
  location: class BoilerControl
10 errors
Done, running

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Thu Nov 15, 2012 10:52 pm

Did you check the permissions? Try to copy the java directory to your home directory and make sure you have ownership of all the files.

You also don't need to run the command with sudo it does that itself.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Fri Nov 16, 2012 5:30 pm

Getting some where!
Copied jave directory to my home directory and it compiled!

Tried run.sh with the following error

Code: Select all

[email protected] /opt/boilercontrol/java $ ./run.sh uk/co/jaynne/BoilerControl
Error: Could not find or load main class uk.co.jaynne.BoilerControl
So removed the java directory from my home folder and copied accross a new copy of it from the /opt directory.

I then tried to run again:

Code: Select all

[email protected] /opt/boilercontrol/java $ ./run.sh uk/co/jaynne/BoilerControl
Exception in thread "main" java.lang.NoClassDefFoundError: uk/co/jaynne/Scheduler
	at uk.co.jaynne.BoilerControl.main(BoilerControl.java:18)
Caused by: java.lang.ClassNotFoundException: uk.co.jaynne.Scheduler
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 1 more
I have tried installing the default-jre package incase it was a runtime issue with no success

Any help much appreciated!

On a more positive not I got my LCD screen today and have that fully operational (with a python script)! Just got to test out my solid state relay with my thermostat 'zerovolt' input of the boiler.

Code: Select all

sudo apt-get install default-jre-headless

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Fri Nov 16, 2012 6:02 pm

gorstj wrote:Getting some where!
Copied jave directory to my home directory and it compiled!

Tried run.sh with the following error

Code: Select all

[email protected] /opt/boilercontrol/java $ ./run.sh uk/co/jaynne/BoilerControl
Error: Could not find or load main class uk.co.jaynne.BoilerControl
You say you copied it to your home directory and it compiled - once it has compiled it should run straight after - did it do that successfully? what was the output from ./compileandrun.sh uk/co/jaynne/BoilerControl

The command you have above ([email protected] /opt/boilercontrol/java) shows you trying to run the version from in /opt/boilercontrol/java NOT in your home directory which is why I'm asking.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Fri Nov 16, 2012 7:10 pm

[email protected] ~/java $ ./run.sh uk/co/jaynne/BoilerControl
Exception in thread "main" java.lang.NoClassDefFoundError: uk/co/jaynne/Scheduler
at uk.co.jaynne.BoilerControl.main(BoilerControl.java:18)
Caused by: java.lang.ClassNotFoundException: uk.co.jaynne.Scheduler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
When I did the compilation I did it using the /opt/boilercontrol version
The output when I compiled was unremarkable and claimed boilercontrol was running, however searching for the process failed:

Code: Select all

[email protected] /opt/boilercontrol/java $ ./compileandrun.sh uk/co/jaynne/BoilerControl
Compiling
Done, running
[email protected] /opt/boilercontrol/java $ ps aux | grep Boiler
pi        2974  0.0  0.1   3532   804 pts/0    S+   19:09   0:00 grep --color=auto Boiler
[email protected] /opt/boilercontrol/java $ ps aux | grep java
pi        2985  0.0  0.1   3532   804 pts/0    S+   19:09   0:00 grep --color=auto java

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Fri Nov 16, 2012 7:15 pm

Would it be possible to put up a compiled copy of boiler-control with some default mysql info?

e.g.
database: boiler
user: boiler
password: hot

I know this isn't 'secure' but as long as the mysql server isnt running on an open port this should not be a problem? Even if apache is running on an open port?

I am using the same GPIO pins that you have set as default.

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Wifi Internet Boiler

Fri Nov 16, 2012 8:15 pm

Here's a compiled version - delete your uk directory and replace it with this. The program wasn't running after that compile as ps aux | grep java would have shown it and the program runs in the foreground and outputs to the screen.

Your problem looks identical to the permissions problem I have seen on another users Pi
http://dl.dropbox.com/u/19001748/boilercontrol.tar.gz

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Fri Nov 16, 2012 8:18 pm

Ok. Managed to get a little further....
I
chmod 755 /opt/boilercontrol/uk/co/jaynne/BoilerControl.class
which presumably was the file that was the result of the compiling.

I then get....

Code: Select all

[email protected] /opt/boilercontrol/java $ ./run.sh uk/co/jaynne/BoilerControl
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libpi4j.so: /tmp/libpi4j.so: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1935)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1860)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821)
	at java.lang.Runtime.load0(Runtime.java:792)
	at java.lang.System.load(System.java:1059)
	at com.pi4j.util.NativeLibraryLoader.load(NativeLibraryLoader.java:106)
	at com.pi4j.wiringpi.Gpio.<clinit>(Gpio.java:159)
	at com.pi4j.io.gpio.impl.GpioControllerImpl.<init>(GpioControllerImpl.java:58)
	at com.pi4j.io.gpio.GpioFactory.getInstance(GpioFactory.java:74)
	at uk.co.jaynne.gpio.GpioControlPi4J.<init>(GpioControlPi4J.java:24)
	at uk.co.jaynne.gpio.GpioControlPi4J.<init>(GpioControlPi4J.java:16)
	at uk.co.jaynne.gpio.GpioControlPi4J$SingletonHolder.<clinit>(GpioControlPi4J.java:31)
	at uk.co.jaynne.gpio.GpioControlPi4J.getInstance(GpioControlPi4J.java:35)
	at uk.co.jaynne.ControlBroker.<init>(ControlBroker.java:25)
	at uk.co.jaynne.ControlBroker.<init>(ControlBroker.java:12)
	at uk.co.jaynne.ControlBroker$SingletonHolder.<clinit>(ControlBroker.java:34)
	at uk.co.jaynne.ControlBroker.getInstance(ControlBroker.java:38)
	at uk.co.jaynne.Scheduler.<init>(Scheduler.java:11)
	at uk.co.jaynne.BoilerControl.main(BoilerControl.java:18)


Googling libpi4j.so problems seem to relate to Pi4J hardflot/softfloat issues which should be sorted in the 0.02-SNAPSHOT which boilercontrol uses.

gorstj
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm

Re: Wifi Internet Boiler

Fri Nov 16, 2012 8:21 pm

Just tried your compiled version (thanks). Getting the same libpi4j.so error.

Return to “Automation, sensing and robotics”