How to use RaspberryPi as controller/timer


12 posts
by saltsaint » Tue Aug 21, 2012 10:38 pm
Hello,
We are a group of students working at a new project.
A blessed soul has donated us 120 $ that we intend to use to buy 4 Raspberry Pi.
What we want is, first, to find out if we can control a 12V DC motor connecting the RbP directly to it (if possible) and second if an app, for Android OS, can control the settings below communicating with RbP wireless.

Basically, we want to have a simple, intuitive and easy to operate interface on a phone/ tablet screen so that:
- be able to set the working hours of a a 12V DC motor (i.e. from 9 a.m. to 5 p.m.) and within this schedule, set the number of minutes when the motor is working or not (i.e. work 3 minutes, rest 2 minutes)
- additionally, to control the speed of the 12V DC motor

Please receive our gratitude in advance for any ideea of how we can reach our goal.
Posts: 2
Joined: Tue Aug 21, 2012 10:25 pm
by Serac » Wed Aug 22, 2012 1:33 am
Yes, you can control a motor using a Pi, BUT... You will need an external switching device to handle the voltage and current a 12V motor requires. This could be as simple as a relay & transistor or as complex as a switch mode H-bridge. If it is just a single motor spinning in one direction and you desire speed control, the Pi has a PWM output that could be used.
Posts: 124
Joined: Wed Jul 18, 2012 2:49 pm
by fruitloaf » Wed Aug 22, 2012 6:48 am
I'm actually just writing code to do this exact same task. Its intended for central heating control but there's no difference to using it for your task.

I'm writing it as a two part program, the first part is in java which is the program that runs all the time and controls the GPIO. The second part is going to be a PHP program to give a web frontend and both communicate by storing the data in a MySQL database. I've done it this way for two reasons - firstly security as I wanted this to be exposed to the web and I didn't want to run apache as administrator to control the GPIO. Secondly I wasn't confident that PHP was a great way to run this all 24x7 java seemed a more stable way to have a constantly running process than PHP. Finally I already knew both of the languages!

I'm going to be uploading the project to GIT to share it - I can do that later today if you want to look at it. The java bit is currently working - my pi is currently working infront of me controlling some LEDs and a 16x2 display to a time schedule. I'm still to do the PHP bit but you could create a simple site to do that in an hour - I'm going to go for something fancier but the bones of the project are there for you.
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by saltsaint » Wed Aug 22, 2012 9:22 am
@Serac, @fruitloaf – Thank you for your help and for sharing this informations!
To clarify:
- there is a single 12V DC motor
- there is a single rotation direction that we want to control the motor

I will meet this evening with my coleagues and will follow soon with our progress
Posts: 2
Joined: Tue Aug 21, 2012 10:25 pm
by fruitloaf » Wed Aug 22, 2012 10:30 am
You'll need some sort of interface for your motor but if its just on and direction you're looking to control my code would work fine however its not particularly hard to write the same thing in python, PHP or whatever language you are familiar with.

The solution I'm using is easy enough to modify but its done using the languages and frameworks I'm familiar with rather than necessarily whats the simplest option.
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by fruitloaf » Fri Aug 24, 2012 1:53 pm
Heres my git upload of what I have so far which is the java part designed to run and check for a schedule in the database.

I haven't done the frontend yet but will probably manage that over the weekend.

Right now it features a MySQL backend, GPIO support to control relays and/or LEDs and output support to a 16x2 HD48770 LCD. Its all pretty modular and you would find it easy to not use parts or change it for your needs.

Linky
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by Bulluk » Sat Oct 27, 2012 4:38 pm
fruitloaf wrote:Heres my git upload of what I have so far which is the java part designed to run and check for a schedule in the database.

I haven't done the frontend yet but will probably manage that over the weekend.

Right now it features a MySQL backend, GPIO support to control relays and/or LEDs and output support to a 16x2 HD48770 LCD. Its all pretty modular and you would find it easy to not use parts or change it for your needs.

Linky


I'm currently controlling my boiler by clicking a pin in WebIOPI but your 'all in solution' is very appealing. I'm going to try and get your project running but was wondering if you'd written a tutorial anywhere (I'm very much a windows guy so any help is gratefully accepted!)
Posts: 3
Joined: Sat Oct 27, 2012 4:32 pm
by fruitloaf » Sun Oct 28, 2012 11:28 am
Bulluk wrote:
fruitloaf wrote:Heres my git upload of what I have so far which is the java part designed to run and check for a schedule in the database.

I haven't done the frontend yet but will probably manage that over the weekend.

Right now it features a MySQL backend, GPIO support to control relays and/or LEDs and output support to a 16x2 HD48770 LCD. Its all pretty modular and you would find it easy to not use parts or change it for your needs.

Linky


I'm currently controlling my boiler by clicking a pin in WebIOPI but your 'all in solution' is very appealing. I'm going to try and get your project running but was wondering if you'd written a tutorial anywhere (I'm very much a windows guy so any help is gratefully accepted!)


I have my Internet Wifi Boiler up and running now. It features schedules, groups (disable or enable a whole bunch of schedules at a time - great for different shift patterns) and holiday times.

Its pretty easy to get setup and running - I'm using a soft-float debian wheezy image as I can install Oracle java on that plus you will want to install apache plus mysql however that can be done via a single apt-get command. There are guides on this forum on how to do that and once you have that setup I'd be more than happy to help with how you get my application running.
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by Bulluk » Mon Nov 05, 2012 5:18 pm
fruitloaf wrote:Its pretty easy to get setup and running - I'm using a soft-float debian wheezy image as I can install Oracle java on that plus you will want to install apache plus mysql however that can be done via a single apt-get command. There are guides on this forum on how to do that and once you have that setup I'd be more than happy to help with how you get my application running.


True to his word, fruitloaf helped me get this up and running and I must say, it's very impressive!

thanks again
Posts: 3
Joined: Sat Oct 27, 2012 4:32 pm
by fruitloaf » Tue Nov 06, 2012 6:56 pm
I've created a dedicated thread for my wifi internet boiler app if anyone is interested.
viewtopic.php?f=37&t=22244
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am
by gorstj » Wed Nov 07, 2012 8:43 pm
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
Posts: 25
Joined: Mon Mar 05, 2012 2:03 pm
by fruitloaf » Thu Nov 08, 2012 8:09 am
I've replied in the thread I started so I can keep answers together for future people to find more easily viewtopic.php?p=211364#p211364
Posts: 80
Joined: Sun Feb 05, 2012 11:41 am