I/O Board with php control


13 posts
by SteTommo » Tue Jun 19, 2012 7:49 pm
Hi Everyone, I've owned a RasPi for quite a while now and I've been hard at work making a project to suit my own needs. Now that I'm nearly there I thought I would see if anyone else would be interested in it.


Image
(^unfinished prototype)

Here's the idea. It's a plug in board that sits on top of your RasPi and connects to the GPIO. It has 4 digital 5v inputs/outputs, 4 analog inputs, 4 PWM FET driven outputs and 2 relay outputs. It also has a voltage reg to drive your Pi from any power source upto 24v.

It's controlled via a php module, and the php code needed to do this is very simple and lightweight.

<?php

$pio = new PIO;

//read digital pin 2
$myVar = $pio->digitalRead(2);

//set pwm 1 output to 50%
$pio->writePwm(1,128);

//find out what PWM pin 2 is currently set to
$myVar = $pio->getStatePwm(2);

?>

So the end result is a web server with apache/php/mysql that is capable of interacting with the real world. Of course you can always interface via C/Python command line if you wanted to. But by using a webserver, you can write a really funky HTML5 GUI which could then run on a mobile/tablet/desktop from in your home, or anywhere on the internet.

It's built using Arduino, so if you want you can re program it to do anything you want, but you don't need to know anything about Arduino to use it out of the box, you just need to know HTML and the php above.

Right now it's just a prototype but if there's enough interest I can get the PCBs made up, there won't be a separate arduino board, all the components will be on 1 board with screw terminals for connecting up to your devices/sensors.

What do you guys think?
Posts: 8
Joined: Tue Jun 19, 2012 7:27 pm
by gordon@drogon.net » Wed Jun 20, 2012 7:05 am
SteTommo wrote:Hi Everyone, I've owned a RasPi for quite a while now and I've been hard at work making a project to suit my own needs. Now that I'm nearly there I thought I would see if anyone else would be interested in it.


Image
(^unfinished prototype)

Here's the idea. It's a plug in board that sits on top of your RasPi and connects to the GPIO. It has 4 digital 5v inputs/outputs, 4 analog inputs, 4 PWM FET driven outputs and 2 relay outputs. It also has a voltage reg to drive your Pi from any power source upto 24v.

It's controlled via a php module, and the php code needed to do this is very simple and lightweight.

<?php

$pio = new PIO;

//read digital pin 2
$myVar = $pio->digitalRead(2);

//set pwm 1 output to 50%
$pio->writePwm(1,128);

//find out what PWM pin 2 is currently set to
$myVar = $pio->getStatePwm(2);

?>

So the end result is a web server with apache/php/mysql that is capable of interacting with the real world. Of course you can always interface via C/Python command line if you wanted to. But by using a webserver, you can write a really funky HTML5 GUI which could then run on a mobile/tablet/desktop from in your home, or anywhere on the internet.

It's built using Arduino, so if you want you can re program it to do anything you want, but you don't need to know anything about Arduino to use it out of the box, you just need to know HTML and the php above.

Right now it's just a prototype but if there's enough interest I can get the PCBs made up, there won't be a separate arduino board, all the components will be on 1 board with screw terminals for connecting up to your devices/sensors.

What do you guys think?


Looks good!

How are you talking to the Arduino? I've done some work there via the serial connection from Linux to Arduino using both USB serial and the Pi's on-board 3.3v serial. (To an ATmega running a 3.3v) and put together a very low-level "remote control" type thing for it to extend the Arduino's "Wiring" into Linux land.

I like the hand-crafted bit of stripboard though - very neat!

My testboard was a bit more "traditional" :-)

Image

There's some stuff about the remote control code I did here:

https://projects.drogon.net/drogon-remote-control/drc-protocol-arduino/

So webserver controlled toaster next then?

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1520
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by Deicist » Fri Jun 22, 2012 1:15 pm
Hi Gordon,

This is almost exactly what I bought a raspberry pi for. How much would a production version of your board cost?
Posts: 8
Joined: Fri Jun 22, 2012 1:11 pm
by domesday » Fri Jun 22, 2012 1:29 pm
Deicist wrote:Hi Gordon,

This is almost exactly what I bought a raspberry pi for. How much would a production version of your board cost?


Did you mean Gordon? Gordon is using an Arduino ready made board.
Posts: 258
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK
by gordon@drogon.net » Fri Jun 22, 2012 2:03 pm
domesday wrote:
Deicist wrote:Hi Gordon,

This is almost exactly what I bought a raspberry pi for. How much would a production version of your board cost?


Did you mean Gordon? Gordon is using an Arduino ready made board.


Yes, thats a standard arduino on a breadboard...

However if you want to do some of this stuff, then a lot will be possible on the Gertboard which I'm hoping will be on the market real soon now!

But if you want to engage me to build custom stuff, then do drop me an email ;-)

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1520
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by Deicist » Sat Jun 23, 2012 3:48 pm
Oops, sorry I meant steTommo's board / php interface thingy (That''ll teach me to pay attention when posting)

How much would a production version of one of those set me back?
Posts: 8
Joined: Fri Jun 22, 2012 1:11 pm
by SteTommo » Sun Jun 24, 2012 11:19 pm
I'm getting a PCD design drawn up ATM, I wouldn't of thought the final product will cost that much, it's just a handful of components. The 3 FETs and 2 Relays will be the most expensive.

I'll keep this thread up-to-date with my progress
Posts: 8
Joined: Tue Jun 19, 2012 7:27 pm
by Deicist » Mon Jun 25, 2012 8:11 am
Hi, I'll watch this thread with interest...

What sort of current / voltage would the relays you're using be rated for? I have a very limited knowledge of electronics, so bear with me. Is there any way this board could be used to control mains voltage applications (controlling lights or whatever) or would it need to be changed massively to support that?
Posts: 8
Joined: Fri Jun 22, 2012 1:11 pm
by gordon@drogon.net » Mon Jun 25, 2012 8:59 am
Deicist wrote:Hi, I'll watch this thread with interest...

What sort of current / voltage would the relays you're using be rated for? I have a very limited knowledge of electronics, so bear with me. Is there any way this board could be used to control mains voltage applications (controlling lights or whatever) or would it need to be changed massively to support that?


If you're playing with mains do be very careful - one mistake and not only will you fry the Pi, but you might end up frying yourself too...

You may even want to consider dedicated USB mains switching devices unless you are 100% confident about working with mains.

I've had a lot of good results with solid-state relays in the past though. (e.g. CX240D5 and similar) They have optically isolated inputs and zero switch detectors built in - maybe not as cheap as a transistor and a relay though, but no moving parts, no power on/off glitches and often take up less room on the board.

But I'd not put mains on a board sitting on-top of a Pi at all. Not unless you build a system with good mechanical properties and separation. All my mains stuff has the controller (arudino based for now) on a separate PCB to the power board and linked via ribbon cables with a physical separation between the 2.

-Gordon
--
Gordons projects: https://projects.drogon.net/
User avatar
Posts: 1520
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
by SteTommo » Mon Jun 25, 2012 11:27 am
I would agree with Gordon, you could in theory put 240v relays on there, but the pins with 240v on them would be mm away from the RasPi board and even if you isolated them because of the tiny scale of the add-on board they would still be right next to everything.

You could use either the PWMs (in digital mode) or the onboard relays to directly control a 12v relay that can switch 240v and as Gordon said, house this separately. This would be the simplest option.

Or you could build your own circuit to use the 5v digital I/O pins to switch 240v, either with traditional relays and transistors to drive them, or solid state relays that can be driven by the 5v I/O directly (more or less).

As it happens I'm actually building an Arduino based device to control a 240v air pump for a friend at the moment and I'm using 240v AC solid state relays.
Posts: 8
Joined: Tue Jun 19, 2012 7:27 pm
by nick.mccloud » Mon Jun 25, 2012 12:22 pm
What is the PHP module written in? Care to share?
User avatar
Posts: 795
Joined: Sat Feb 04, 2012 4:18 pm
by SteTommo » Mon Jun 25, 2012 6:22 pm
it's a php class written in php, but when it's complete I might compile it into a native module. It's not really finished yet, and it uses a proprietary syntax I'v made to communicate with the firmware on the Arduino, so it wouldn't really be much use to man nor beast at this point.

Even when it's finished it would only be any use talking to the add-on board I'm making.
Posts: 8
Joined: Tue Jun 19, 2012 7:27 pm
by G01d3ngypsy » Sat Sep 08, 2012 12:30 am
Did this ever get completed?

I'm really interested in this, either in this form or as a completed PCB.

Is there any way i can contact you by email about buying one made up? I'm after making it ring an alarm bell, based on a movement notification from my ip camera server.

Cheers!
Posts: 7
Joined: Sat Sep 08, 2012 12:29 am