[Dorset] Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Terry Coles
Hi,

Clive has recruited me to help him at the Wimborne Model Town Railway ( 
http://www.wimborne-modeltown.com/the-model-town/model-railway/[1] ).  His 
responsibility is controlling the lighting and 
we would like to use a Pi Zero to turn lights inside houses on and off at 
intervals and also to dim and 
brighten the main lights at 'dusk' and 'dawn'.

We have a physical solution and the code is fairly trivial, but my main concern 
is the fact that once 
implemented, the Pi would have to run unattended for most of the time and also 
withstand having the 
power removed without a formal shutdown every evening (or if there is a power 
cut).  Clearly, this would 
put the integrity of the data on the SD Card at risk.

I think we have a solution, but before we rush off to do it, I'd appreciate 
your comments.  The plan is to 
create a Live Tiny Core ( http://tinycorelinux.net/ports.html[2] ) distro 
containing the packages needed 
and the code to be run.  We would install this on the SD Card and then make it 
Read-only.  Each morning, 
the manager would then be able to power up the railway, which would bring up 
the Pi and start the 
program running.  At the end of the day, the manager would then be able to turn 
off the supply without 
any risk to the SD Card.

Can anyone see any problems with this approach or suggest a better way?

-- 

Terry Coles




[1] http://www.wimborne-modeltown.com/the-model-town/model-railway/
[2] http://tinycorelinux.net/ports.html
--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Simon P Smith
On 11/01/16 12:19, Terry Coles wrote:
> We have a physical solution and the code is fairly trivial, but my main 
> concern is the fact that once 
> implemented, the Pi would have to run unattended for most of the time and 
> also withstand having the 
> power removed without a formal shutdown every evening (or if there is a power 
> cut).  Clearly, this would 
> put the integrity of the data on the SD Card at risk.
>
>
> Can anyone see any problems with this approach or suggest a better way?
>

Terry, to be honest the description of the requirement suggests the Pi
is overkill (IMHO), in my "intelligent"
pump controller project I completed when my house was being assailed by
flood wher I started with this
approach but ended up with a v.cheap arduino board.  The code being in
on-board flash.

Opps that takes me off-topic for a Linux group :-)

Best regards,

Simon

--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Terry Coles
On Monday 11 January 2016 12:35:40 Simon P Smith wrote:
> On 11/01/16 12:19, Terry Coles wrote:
> > We have a physical solution and the code is fairly trivial, but my main
> > concern is the fact that once implemented, the Pi would have to run
> > unattended for most of the time and also withstand having the power
> > removed without a formal shutdown every evening (or if there is a power
> > cut).  Clearly, this would put the integrity of the data on the SD Card
> > at risk.
> > 
> > 
> > Can anyone see any problems with this approach or suggest a better way?
> 
> Terry, to be honest the description of the requirement suggests the Pi
> is overkill (IMHO),

Funnily enough, that is exactly what I said to Clive!  In fact his original 
solution consisted of a timer relay 
to just do the house lights and I thought that would be fine.  However, when he 
started talking about 
controlling 'daylight', I accepted that a bit of intelligence would make things 
easier and certainly more 
flexible to allow additions to the functionality in the future.

> in my "intelligent" pump controller project I completed when my house was
> being assailed by flood wher I started with this approach but ended up with
> a v.cheap arduino board.  The code being in on-board flash.

I also thought of Arduino, but I have no experience with it, whereas I have 
played around with the Pi.  
>From my recollection of the Arduino, from when we used one at work some years 
>ago, I think that we 
would need to buy some kit to interface to it.

The nice thing about the Pi is that even now, everything has been done before 
and we can buy the 
hardware quite cheaply from CPC / element 14

> Opps that takes me off-topic for a Linux group :-)

All comments gratefully received.

-- 

Terry Coles


--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Peter Merchant

On 11/01/16 12:35, Simon P Smith wrote:

On 11/01/16 12:19, Terry Coles wrote:

We have a physical solution and the code is fairly trivial, but my main concern 
is the fact that once
implemented, the Pi would have to run unattended for most of the time and also 
withstand having the
power removed without a formal shutdown every evening (or if there is a power 
cut).  Clearly, this would
put the integrity of the data on the SD Card at risk.


Can anyone see any problems with this approach or suggest a better way?


Terry, to be honest the description of the requirement suggests the Pi
is overkill (IMHO), in my "intelligent"
pump controller project I completed when my house was being assailed by
flood wher I started with this
approach but ended up with a v.cheap arduino board.  The code being in
on-board flash.

Opps that takes me off-topic for a Linux group :-)

Best regards,

Simon

--
I have a Stamp processor that could do it too, But Terry & Clive involved here 
know linux, and probably don't want to learn another language, and also want it 
supportable fo the future.


I have always understood that the way to power down the R-Pi is to 
unplug it, and I have never heard about problems with the memory cards. 
I suggest to always have a backup card available in case of failure in 
any case.


For headless operation it is advisable to use a fixed IP address in case 
you want to ssh into it, but on the basis of information given, it 
sounds like it is standalone and not networked.


Cheers,

Peter

--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Terry Coles
On Monday 11 January 2016 13:08:25 Peter Merchant wrote:
> I have always understood that the way to power down the R-Pi is to
> unplug it, and I have never heard about problems with the memory cards.

Hmm.  I'm fairly sure that the RPi Foundation recommend that you do a proper 
shutdown before pulling 
the plug.  I have actually had problems with corrupt SD Cards, although I 
haven't established why yet.

> I suggest to always have a backup card available in case of failure in
> any case.

There won't be anyone on site to swap the faulty card.

Obviously, we will have a backup (or two or three), just in case.

> For headless operation it is advisable to use a fixed IP address in case
> you want to ssh into it, but on the basis of information given, it
> sounds like it is standalone and not networked.

There is no accessible network on site.

-- 

Terry Coles


--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread tda

On 11/01/16 13:21, Terry Coles wrote:

On Monday 11 January 2016 13:08:25 Peter Merchant wrote:

I have always understood that the way to power down the R-Pi is to
unplug it, and I have never heard about problems with the memory cards.


Hmm.  I'm fairly sure that the RPi Foundation recommend that you do a proper 
shutdown before pulling
the plug.  I have actually had problems with corrupt SD Cards, although I 
haven't established why yet.



Yes, it needs a proper shutdown. Two or three years back I designed a 
UPS to work with a Pi for a backup server, communicating over IIC, only 
to discover that the Pi IIC didn't implement pulse stretching. In the 
end it wasn't worth the effort considering an extra £60 bought an HP 
Microserver.


So I agree the best way is any one of the embedded dev boards out there. 
 FRDM-KL25Z gives you an Arm Cortex M0+ on a little board for a tenner. 
gcc for Arm and the Segger utilities then give a complete FOC 
Linux-based development platform.


Cheers

Tim




--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Terry Coles
On Monday 11 January 2016 14:17:09 t...@ls83.eclipse.co.uk wrote:
> So I agree the best way is any one of the embedded dev boards out there.
>   FRDM-KL25Z gives you an Arm Cortex M0+ on a little board for a tenner.
> gcc for Arm and the Segger utilities then give a complete FOC
> Linux-based development platform.

The only problem with that for me would be that I'd probably have to develop 
all the interfaces from 
scratch and go up a fairly steep (for me) learning curve wrt development on the 
KL25Z.

As mentioned earlier, I am already familiar with the RPi and it comes with GPIO 
support out of the box 
with libraries for Python and C.  In addition, the aftermarket has every 
interface to the RPi needed for a 
few tens of pounds.

For example, CPC and others stock a relay card specifically designed to 
interface to the RPI.  This could 
be used to turn the lights on and off.   To dim the LEDs a PWM script will run 
a low power LED straight 
off the GPIO pins or for higher powers, the aftermarket can supply there too 
with a MOSFET interface 
driven by the same GPIO pin.

I have to think about whoever picks this up in the future and the RPi makes 
knowledge transfer so much 
easier (especially with the rising generation who are now using them in schools 
:-)  )

-- 

Terry Coles


--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR


Re: [Dorset] {Spam?} Using a Raspberry Pi 'Headless' and Unattended

2016-01-11 Thread Paul Tansom
** Terry Coles  [2016-01-11 18:53]:
> On Monday 11 January 2016 14:17:09 t...@ls83.eclipse.co.uk wrote:
> > So I agree the best way is any one of the embedded dev boards out there.
> >   FRDM-KL25Z gives you an Arm Cortex M0+ on a little board for a tenner.
> > gcc for Arm and the Segger utilities then give a complete FOC
> > Linux-based development platform.
> 
> The only problem with that for me would be that I'd probably have to develop 
> all the interfaces from 
> scratch and go up a fairly steep (for me) learning curve wrt development on 
> the KL25Z.
> 
> As mentioned earlier, I am already familiar with the RPi and it comes with 
> GPIO support out of the box 
> with libraries for Python and C.  In addition, the aftermarket has every 
> interface to the RPi needed for a 
> few tens of pounds.
> 
> For example, CPC and others stock a relay card specifically designed to 
> interface to the RPI.  This could 
> be used to turn the lights on and off.   To dim the LEDs a PWM script will 
> run a low power LED straight 
> off the GPIO pins or for higher powers, the aftermarket can supply there too 
> with a MOSFET interface 
> driven by the same GPIO pin.
> 
> I have to think about whoever picks this up in the future and the RPi makes 
> knowledge transfer so much 
> easier (especially with the rising generation who are now using them in 
> schools :-)  )
** end quote [Terry Coles]

I'm in pretty much the same position, I'm familiar with PCs and hence the
Raspberry Pi, but haven't had the time to get my head around the Arduino more
electronics oriented way of doing things. It probably wouldn't take too long,
but with so much else to do I haven't found the time yet - even my Pi projects
aren't progressing at the moment!

Anyway, working on the basis of using a Raspberry Pi, it seems to me that the
key requirement would be to detect the loss of power and shutdown. Clearly this
needs some form of battery or capacitor to provide enough time before complete
loss of power. There are a number of similar projects out there if you are
wanting to do some soldering, etc., but an easier alternative might me
something like the UPS PIco (1) or the Pi UPS (2).

(1) http://www.modmypi.com/raspberry-pi/breakout-boards/pi-modules/ups-pico
(2) 
https://www.pi-supply.com/product/pi-ups-uninterrupted-power-supply-raspberry-pi/?v=79cba1185463

I've not used either, but they look interesting:

The UPS PIco is a standard Hat format, includes a battery, has a stackable
header for other addons, software based RTC and supports auto power down on
power loss, so looks to have everything ready to go. It also charges the
battery.

The Pi UPS is a bit more expensive and uses standard batteries (not supplied)
and looks to require a bit of coding to read the GPIO to do the shutdown. I
can't find anything about charging, although using a standard battery may be
easier to replace - but then they'd need replacing more frequently I guess.

Actually the UPS PIco looks quite interesting - I mustn't add to my Pi
collection, I've already got plenty to play with that hasn't been explored yet!

-- 
 Paul Tansom  |  Aptanet Ltd.  |  https://www.aptanet.com/  |  023 9238 0001
 Vice Chair, FSB Portsmouth & SE Hampshire Branch  |  http://www.fsb.org.uk/
=
Registered in England | Company No: 4905028 | Registered Office: Ralls House,
Parklands Business Park, Forrest Road, Denmead, Waterlooville, Hants, PO7 6XP

--
Next meeting:  Bournemouth, Tuesday, 2016-02-02 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR