david__
Posts: 4
Joined: Fri Apr 13, 2012 11:03 am

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 12:32 pm

I am taking part of a scientific project in which I need to take periodic measurements, once or a few times every day, for a period of months. I have no electric current available, so it will have to work on batteries. I was thinking of using a raspberry pi attached to the sensor (let's say the sensor is an usb camera), and program it to boot and take a shot. However I have to find a way to turn off the device between one shot and the next one, or the batteries will not last very long.

Basically I need a way to turn on the raspberry pi every day for a few seconds, and then turn it off. From what I understand, the raspberry pi does not have an internal clock, so there is no way he can do that on its own. Is that right?

If this is true, then I need a switch that automatically turns on for a few seconds every day, and that consumes nearly no battery. It should also be cheap. Do you have any suggestion?

thank you

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 12:50 pm

There is no clock on the RaspPi, but that does not mean there cannot be one. It is believed that there are drivers in the Linux kernel for most clock chips.Even if there isn't a driver, they are fairly simple devices.

I am thinking that most clock chips also have an alarm output. If this output fed the S input of an S-R flip-flop, and the output of that fed a low-power relay (or even just a transistor,) the clock could switch the RaspPi on. If a GPIO pin fed the R input, the RaspPi could switch itself off.

plugwash
Forum Moderator
Forum Moderator
Posts: 3475
Joined: Wed Dec 28, 2011 11:45 pm

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 1:31 pm

Relays are power hogs and a pain to drive, a P channel mosfet is probablly what you are looking for to switch the Pi's power.

Rest of rurwin's plan sounds fine though.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 1:48 pm

david__ said:


I need to take periodic measurements, once or a few times every day, for a period of months.


You might want to look into a small solar panel to keep the battery topped - it might not hold its charge that long unless it's a battery of large disposable cells.

How much data will each measurement be?  For a photo the Raspi would probably do it, but if it's just temperature sensors then you might be able to use something with even lower power demands.

Also, do you want one measurement at exactly the same time every day?

It would be possible to build a counter/timer that gives a 23 hour delay, so the computer does the measurement, sets that timer, powers down normally, then the timer switches on the power again 23 hours later.  The computer then reboots, uses an added real-time clock to wait for exactly noon (say), then takes the measurement and resets everything again until tomorrow.

So you'd need; to build a timer that can switch on the power and can be reset from the Pi; an interface to your sensors; a real-time clock circuit for the Pi (I think a few have been mentioned in the forum); and fourth you'd need a battery/solar charger system.

I think

daveismith
Posts: 2
Joined: Wed Nov 23, 2011 1:13 pm

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 1:48 pm

You probably want to compare putting the processor into a very deep sleep with actually turning if off. Most ARM core based chips can be put into an incredibly low power mode. You may find this uses less power than the boot sequence consumes.

david__
Posts: 4
Joined: Fri Apr 13, 2012 11:03 am

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 3:15 pm

@rurwin

@plugwash

I think I got it, but know nearly nothing about electronics. What do you mean by "clock chip"? I browsed a bit the forums and I found this chip mentioned

http://www.sparkfun.com/products/10079

Can I program it to send an "alarm" signal every x hours? From the datasheet it seems that I can, but I don't know how easy it would be to actually do it.

Would it be simpler to actually buy a cheap alarm clock, open it and use the cable that goes to the speaker to turn on the flip flop or directly the transistor? Is it too dumb to actually work?


@Ravenous

At the moment the data is the height of a river, which is measured by taking a photo to a stick on the ground with marks on it. It does not have to be taken at the same hour every day, just periodically. Also, part of the river (which I need to measure) is under a cave, so solar panels are not an option.

plugwash
Forum Moderator
Forum Moderator
Posts: 3475
Joined: Wed Dec 28, 2011 11:45 pm

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 3:29 pm

david__ said:


I think I got it, but know nearly nothing about electronics. What do you mean by "clock chip"?


I mean a real time clock chip with an alarm output there are many of them out there with slightly different features most of which could probablly do what is needed here.


I browsed a bit the forums and I found this chip mentioned

http://www.sparkfun.com/products/10079


Yeah something like that. One particually nice thing about that one is it has an integrated crystal.


Can I program it to send an "alarm" signal every x hours? From the datasheet it seems that I can, but I don't know how easy it would be to actually do it.


It looks like you have two alarms each of which is set to a time of day, so if you wanted an alarm every 4 hours from that chip you'd have to reset the alarm each time you woke up (which isn't a big deal but just something to be aware of).


Would it be simpler to actually buy a cheap alarm clock, open it and use the cable that goes to the speaker to turn on the flip flop or directly the transistor? Is it too dumb to actually work?


A line intended for driving a speaker will almost certainly not be suitable for digital logic.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 4:37 pm

This sounds like a fun project.

With no solar power, you'd probably just need to make sure someone checks it once a week to look at the battery voltage and if in doubt, replace.  That's a lot simpler electronically anyway, just more work to maintain.

By the way I assume you won't need a flash, it's not a real deep cave or anything...

Some electronics knowledge is going to be needed to make sure this contraption is reliable, in a cave at least it'll be protected from rain but there'll still be damp, the camera probably has to be outside the box so moisture might get in along the wires, etc.

Also taking the measure once a day is hopefully enough, unless the river's prone to flash flooding...

(Could even collect the pictures and animate them, if the exposure's even enough and the photos are taken at exactly the same time every day)

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 5:07 pm

Personally, for this use, assuming all you want to do is take a picture, I would not use a Raspberry Pi. I would get a camera with a remote shutter release and a microcontroller like the Atmel AVR (maybe an Arduino, it depends what else there is on the board.) The AVR can be put into a sleep state which can make one nine-volt battery last months. All it has to do is to wake up once a day and toggle a couple of outputs high and then low. The camera's SD card will be the data log, and each picture is numbered in sequence and has the time and date recorded (Not usually in the picture itself, but it's possible to post-process it so it does.)

You will probably have to modify the camera to get it to switch on and off remotely, as well as taking a picture, otherwise it will run out of battery in a few hours, but that can be bodged fairly easily.

david__
Posts: 4
Joined: Fri Apr 13, 2012 11:03 am

Re: Periodically turning on and off a raspberry pi

Fri Apr 13, 2012 7:05 pm

@Ravenous

for the photos deep inside the cave, we will not use a flash, but some led lights. They use nearly no electricity and with 4 AA batteries they produce more than enough light to take a picture. We already did that. It works, and the batteries can last nearly 10 hours, more than a raspberry pi can.

And yes, we will have to protect the whole system with some plastic container (maybe with a small hole to let the camera cable out).

@rurwin

I am looking for a system that is both

- cheap, so that we can build several sensors (of course we don't have plenty of raspberries right now, but if all goes well with the foundation one day we will)

- very easy to build (I have no trouble programming, but I know nearly nothing about electronic)

The raspberry pi seems like a good solution, if the powering problem can be addressed. Please correct me if I am wrong, but your solution is more difficult and expensive to set up. While I am willing to learn a few electronics, I don't know if I will be able to do it on my own, starting from scratch.

Furthermore, leaving a camera out in the open for many months is a good way to get it stolen. Leaving a raspberry pi with a very small webcam in a box is more bound to get left there by people who stumble on it while trekking... that is one of the reasons why I prefer this solution. Ok, I guess many of this forum (me included) would prefer to get their hands on a raspberry pi more than on a camera, but we represent a negligible part of the human population... and I won't tell you where I will put them

hzrnbgy
Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm

Re: Periodically turning on and off a raspberry pi

Sat Apr 14, 2012 7:13 am

Perfect!

I'm working on some project that involves a cheap camera sensor and a cheap development board.

I'm in the process of developing the driver for the embedded camera for my STM32F4 Discovery board

http://www.mouser.com/ProductD.....N%252b9qEw

I'm using one of those cheaper ebay embedded camera modules that should work seamlessly with the development board sans with the proper driver. This contraption should be able to be powered up by 2 D batteries for a year or so.

http://www.box.com/s/a91a4e0fc.....0b33333254

If you are interested with such undertaking, i'll be more than willing to share the code once I'm through with it. I am hoping that I can do something for the scientific community.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Periodically turning on and off a raspberry pi

Sat Apr 14, 2012 10:16 am

david__ said:


Please correct me if I am wrong, but your solution is more difficult and expensive to set up.


Difficult, yes, more expensive, probably not. You could probably source the camera from the cheap end of the market, but you would need to open it up and solder wires across the on/off and shutter release buttons. The microcontrolller board only needs to cost around £5. It would not require a huge knowledge of electronics – if you can follow example circuits on the datasheets for a diode, two resistors, four capacitors and a crystal, you could build the microcontroller board, and the rest is just a couple of reed relays and one IC. But it does have associated risks that the Raspberry Pi version doesn't, and it isn't as flexible.

A standard car battery is around 70Ah capacity. That would drive a RaspPi for 100 hours even with a cheap car charger. If you used a switched-mode power supply then you could extend that to maybe ten days (less efficiency losses etc, but a week should be safe.) Even without switching the RaspPi off at all.

If you used a car battery and a simple 24-hour plug-in timer, (you may have to search for one that can work off and switch 12V DC, but they do exist,) you could program a simple on-off for an hour a day. Then the lifetime of the battery would be (without anything else connected) 240 days. Make it 15 minutes a day and you should manage a whole year.

And the weight of the battery could be deployed to deter thieves.

User avatar
cowpat
Posts: 90
Joined: Sat Apr 14, 2012 12:13 pm
Location: London
Contact: Website

Re: Periodically turning on and off a raspberry pi

Sat Apr 14, 2012 2:27 pm

I agree that the digital camera might be the best solution here... or maybe just a Bushnell trail camera. The Bushnell has a dc input that will go straight onto a 6v lead acid battery.... the memory card will probably fill up before the battery runs out

I'm looking at remote motion detection* - using a guess of 700mA for the raspberry, 80mA for the camera and 100mA for the IR LED my sums/guesswork only give me 3 days out of a 100Ah battery. Hopefully I'm wrong, because 100Ah batteries are heavy.

From what little I have learned about batteries over the last few weeks, I don't think you want to be using a standard car battery though as they don't like being discharged. I've been looking at solar/AGM/GEL batteries.

*for animals too small for a trail camera PIR.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 12:46 am

If you get a Cannon camera you can hack it by "updating" the firmware via the SD card using CHDK (Canon Hack Development Kit) and then program it using LUA scripts to do things beyond the factory settings - google CHDK....
Ostendo ignarus addo scientia.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 1:14 am

david__

This is an interesting problem and provides plenty of opportunities for Murphy to mess with success. As an ocean engineer in an earlier career, you need to be positively paranoid about humidity and condensation throughout your system. Use a waterpoof enclosure and if there are any openings, even for a cable through a grommet/fitting, make sure they face _down_ to facilitate draining any condensation that might form. Put in as much dessicant as possible to soak up humidity and prevent condensation (like those little bags of resin that fall out of many product packages). Surround the enclosure with as thick a layer of foam or fiberglass insulation as possible to minimize temperature swings (especially downward when condensation forms) - of course, you also need to leave a hole for the camera and place the lighting where it makes sense. Also become very close friends with silicone sealant, lots of it.

As for batteries, lead-acid, advanced glass mat (AGM), and gel-cell batteries all must not be discharged beyond certain levels (60 ~ 70% for lead-acid, 40 ~ 50% for AGM/gel, depending on specific model) or permanent reduced ability or inability to recharge will occur. NiCd, NiMH, and LiPolymer can all be fully discharged and, in fact, should be, especially NiCd to minimize the "memory" effect (which also occurs in NiMH batteries to a lesser degree).

As for the parts of the system that perform the actual task at hand (what did we come in here for? ), taking photos, I would tend to go for Keep It Simple, Stupid. All you really need is a camera and a timer, period. Trying to depend on a Linux-based system on hardware that has no track record that has to boot up and power down without fail daily for many months, while it sounds good in theory, is a recipe for disaster. Yes, the components have each been used separately in other systems, but, this particular combination is barely in production (who knows when you can buy one, much less a backup?), the OS is still a work in progress, and it will remain so for months to come. Integration of successful components increases the odds of creating a successful system, but, it is far from a guarantee of success.

There are plenty of options and the first one Google listed is the TimelapseCam 8.0 at https://www.Wingscapes.com/timelapsecam for $109 (free shipping), which can use SD cards or downloads via USB, and lasts at least a month with 4 AA batteries. The specs suggest battery life of months with longer intervals between photos, which range from every 10 seconds to once every 24 hours. I"m guessing an auxiliary battery pack can be wired in for longer periods, even if a power jack isn"t built in. There are probably less expensive options, but, this is weatherproof, is equipped with a threaded tripod-style mount, etc. You"re going to need to spend close to this amount for a Pi, camera, case, batteries, etc., plus shipping, manhandling, etc.

I"d be interested to hear what you decide to use and how it turns out.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

david__
Posts: 4
Joined: Fri Apr 13, 2012 11:03 am

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 9:02 am

First of all, thank you all for your suggestions. I have been rethinking about using the raspberry pi for this project, and I am having some doubts (which is good, I guess). While, as you rightly pointed out, it do has many flaws, I am still convinced it is the best compromise between price and easiness to build. But I will keep an open mind to alternatives. Answering a few points:

@hzrnbgy

your project could be interesting, let me know if you get it working

@rurwin and othres

The system should be able to run with standard batteries, as I don't think I can bring a car battery inside a cave for environmental reasons (the water that flows there is the one that we drink, and we can't risk to have a big battery spill some liquid there. I will check that though).

@pygmy_giant

I know about CHDK (I have on my camera too!), but like the rasp. pi it has the same problem of turning itself on once a day. And I think also the cheapest canon cameras cost more than a rasb. plus a 5$ usb camera.

@Jim Manley

You are right about all the protections. We will have to be careful.

TimelapseCam is just what I need, however it is a bit expensive (I was hoping to keep the system cost under 50$).

Right now I will try to find someone that can help me with the electronics part and see if we can build some of the first solutions you proposed. I will keep you updated.

User avatar
cowpat
Posts: 90
Joined: Sat Apr 14, 2012 12:13 pm
Location: London
Contact: Website

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 1:18 pm

Regarding the environmental hazard of lead acid batteries - the 'maintenance free' glass matt and gel technologies are safer.

However, one of the solar power companies i've been talking to (i think it was sunstore.co.uk but i've been in discussion with a couple) didn't recommend gel batteries over winter as their insides can break up.

I believe Alkaline and NiMh batteries aren't fond of the cold.

If you're talking about the difference between the price of a digital camera and a Raspberry Pi - this probably won't be of great interest, but Steatite make a 100Ah lithium battery sealed in a peli case and weighing in at 16kg. They quoted about £1300 over the phone.

On that note, regarding Jim Manley's points on enclosures and protection - peli  cases are great. I've used them to house fibre optic links on ski slopes, which is pretty cold and wet. The only caveat being - they can make £30 of hardware look much more desirable than it really is.

I'm planning to use a video encoder and a B/W bullet camera.... mainly because I don't have to time to research a suitable webcam, build an IP68 enclosure and convert it for IR.

http://www.rfconcepts.co.uk/ca.....let-bw.htm

The cameras have decent lenses and are really tough...

...that said, the video encoder is much less exciting and ultimately might not work, so if someone has a good webcam working in IR on the RPi I would be interested to know.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 2:11 pm

re: CHDK - I think some Canon models have a low power standby mode which you could switch in and out of between photos (bummer if you don"t have one of those models). You"re right about Canon cameras not being cheap.

Or... how about an olden fashioned film camera with motor wind and shutter release socket plus an external purpose built low power timer circuit?

Good luck whatever way you do it....
Ostendo ignarus addo scientia.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12400
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Periodically turning on and off a raspberry pi

Sun Apr 15, 2012 2:38 pm

Sounds like a job for an MC4060 12 stage ripple counter with oscillator. Set it up with a RC time of say 1 second, and it will count up to 4096 seconds that is a bit more than an hour. Connect the upper four bits to a four input AND port and its output will go high every hour for four minutes. Use the signal to turn on the power supply to the system, and every hour the R-PI will have four minutes to boot up, get a picture and do a regular shutdown waiting for the next time it will be turned on again.

Return to “Other projects”