0

Raspberry Pi Zero W with camera + battery
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Raspberry Pi Zero W with camera + battery

by eframe on Thu Aug 22, 2019 7:31 pm

I need some advice on a project. The overall premise is I want to live tweet pictures from a 4-H animal barn at a fair for a week. The hardware has to be battery powered as I want to mount it up high enough so it can't get messed with during the week so I wouldn't necessarily be able to get to it until the end of the week. The frequency that pictures would be taken could totally be dependent on the power options. I wouldn't take pictures 24 x 7 maybe like 6am to 10pm as before and after that there isn't much activity. Also the barn is rather large (250+ animals, pigs to be exact) but it has a roof only and no walls so light does get in but where the hardware would be mounted it wouldn't get direct sunlight.

I wanted to run a Raspberry Pi Zero W with a connected camera. Obviously I'd need a battery or batteries and some way to charge them or run them in some sort of series. Not sure if a solar panel would work in this scenario or not without direct sunlight. I've done several projects with Arduino's but not very much with RPi's and never with a camera. I see lots of batteries and power options here on Adafruit but I need some help to get pointed in the right direction as to what might work. Given the scenario I outlined if there is a better option than a RPi Zero W I'd be open to that as well.

eframe
 
Posts: 4
Joined: Thu Aug 22, 2019 6:59 pm

Re: Raspberry Pi Zero W with camera + battery

by kflmiami420 on Thu Aug 22, 2019 8:59 pm

Attachments
DSC_0628_1024x1024.jpg
DSC_0628_1024x1024.jpg (43.41 KiB) Viewed 105 times

kflmiami420
 
Posts: 92
Joined: Tue Aug 21, 2018 9:43 pm

Re: Raspberry Pi Zero W with camera + battery

by kflmiami420 on Thu Aug 22, 2019 9:01 pm

you could use this for battey power https://www.adafruit.com/product/1566





I just picked this one up from amazon Power Bank RAVPower 26800 Portable Charger 26800mAh Total 5.5A Output 3-Ports External Battery Packs (2.4A Input, iSmart 2.0 USB Power Pack) Portable Phone Charger iPhone, iPad Other Smart Devices
Attachments
1566-05.jpg
1566-05.jpg (75.13 KiB) Viewed 98 times
51fhRyvnQkL._SL1000_.jpg
51fhRyvnQkL._SL1000_.jpg (38.96 KiB) Viewed 98 times
Last edited by kflmiami420 on Thu Aug 22, 2019 9:41 pm, edited 2 times in total.

kflmiami420
 
Posts: 92
Joined: Tue Aug 21, 2018 9:43 pm

Re: Raspberry Pi Zero W with camera + battery

by kflmiami420 on Thu Aug 22, 2019 9:04 pm

you could use this code and adjust it to your needs

Code: Select all | TOGGLE FULL SIZE
from picamera import PiCamera
from datetime import datetime
from time import sleep
// We don't need the button
// from gpiozero import Button
from random import choice
import tweepy
import json
// We do need a timer
from threading import Timer

// Don't create the button
// btn = Button(17)
camera = PiCamera()

with open('twitterauth.json') as file:
    secrets = json.load(file)

auth = tweepy.OAuthHandler(secrets['consumer_key'], secrets['consumer_secret'])
auth.set_access_token(secrets['access_token'], secrets['access_token_secret'])

twitter = tweepy.API(auth)

status = ['Hey there peeps',
          'Check out my photo',
          'Babbage is coming at ya']

filename = ''

def take_photo():
    global filename
    now = datetime.now()
    filename = "{0:%Y}-{0:%m}-{0:%d}-{0:%H}-{0:%M}-{0:%S}.png".format(now)
    camera.start_preview(alpha=190)
    sleep(1)
    camera.capture("/home/pi/{0}".format(filename))
    camera.stop_preview()

def send_tweet():
    twitter.update_with_media('/home/pi/{0}'.format(filename), choice(status))

def main():
    take_photo()
    send_tweet()

// Don't activate the button
// btn.when_pressed = main

while True:
    t = Timer(30 * 60, main)
    t.start()
    t.join()




or this

Code: Select all | TOGGLE FULL SIZE
import pygame
import pygame.camera
from pygame.locals import *

pygame.init()
pygame.camera.init()
cam = pygame.camera.Camera("/dev/video0",(640,480))
cam.start()
image = cam.get_image()
pygame.image.save(image,'webcam.jpg')

kflmiami420
 
Posts: 92
Joined: Tue Aug 21, 2018 9:43 pm

Re: Raspberry Pi Zero W with camera + battery

by eframe on Thu Aug 22, 2019 9:58 pm

Thanks for the reply but not sure this answers the main challenge I'm trying to address. The code for calling the Twitter API is certainly informative, just not the problem I'm looking for advice on. I'm looking for a power solution that will work for 6-7 days for the given scenario in my OP and that was really the main problem I'm trying to solve. I apologize if giving the other details made it confusing on what I'm asking for help with, I was just trying to give some context and might have caused confusion.

Thanks for the battery suggestions. Looking at them I don't think they'll last for 6-7 days, any suggestions on how to recharge them given the conditions I mentioned where they won't be accessible to remove and recharge during that time period?

eframe
 
Posts: 4
Joined: Thu Aug 22, 2019 6:59 pm

Re: Raspberry Pi Zero W with camera + battery

by kflmiami420 on Thu Aug 22, 2019 10:28 pm

here you go 6-7 days 12volt apc-ups battery - usb car charger -
Attachments
IMG_0584.JPG
IMG_0584.JPG (47.23 KiB) Viewed 94 times

kflmiami420
 
Posts: 92
Joined: Tue Aug 21, 2018 9:43 pm

Re: Raspberry Pi Zero W with camera + battery

by eframe on Thu Aug 22, 2019 10:39 pm

Thanks. Any more details on the usb car charger? Do you have a link to that and the battery you used?

eframe
 
Posts: 4
Joined: Thu Aug 22, 2019 6:59 pm

Re: Raspberry Pi Zero W with camera + battery

by mindwave65 on Fri Aug 23, 2019 11:57 am

I just finished a project like the one you want, sort of.

My wife gets aggrevated because 90% of the time when someones at the door its a delivery.

Course the dogs lose theior minds and act like the mongol hordes are waiting for a handout

"Cant we get one of those video doorbells?" so I take her to home depot and introduce her to the CHEAPEST one $139, and demonstrate the most expensive $700+

and my 12yo says, yeah but cant you make one!

Since I have a sign outside that says DONT RING THE BELL, a video doorbell is a losing proposition, so a RASPI0, camera, motion sensor and Tupperware sandwich box from target gets me what I need.

It only takes pix when someone is on the porch, it then sends the pix to an internal webserver, or the TV HTPC, and everyone is happy.

but when I went to mount it, there was no AC on the roofs I had a choice, the first was to use one of these:
https://www.amazon.com/GE-Adapter-Polar ... lp_pl_dp_2

But its FL and it OFTEN rains sideways, so having ANY exposed wiring was a BAD idea

so I went w/ a battery bank. Now I would LOVE to show you some cool math that determines EXACT:Y what I needed and how I got there.... but Im still working on that myself.

So essentially I found THIS

https://www.amazon.com/Simpiz-5000mAh-p ... 84&sr=8-35

and it lasts me from Sat to Sat. I actually bought 2 of them so I just swap them out.

I DID consider solar recharging, but getting GOOD parts is WAY too expensive for me

mindwave65
 
Posts: 23
Joined: Thu Aug 08, 2019 9:37 am

Re: Raspberry Pi Zero W with camera + battery

by kflmiami420 on Fri Aug 23, 2019 1:13 pm

mindwave65 Don't be afraid of exposed electronics when you have this https://www.homedepot.com/p/Plasti-Dip- ... /202196703

All you have to do is dip or coat it all up and you have weather proof gear. LOL

I also use a product called corrosionX is smells but it works great. https://www.youtube.com/watch?v=kjpzV6I54FQ i got it at westmarine

also in FL here.
Attachments
black-matte-plasti-dip-rubberized-coatings-11603-6-64_1000.jpg
black-matte-plasti-dip-rubberized-coatings-11603-6-64_1000.jpg (93.58 KiB) Viewed 52 times

kflmiami420
 
Posts: 92
Joined: Tue Aug 21, 2018 9:43 pm

Re: Raspberry Pi Zero W with camera + battery

by eframe on Fri Aug 23, 2019 5:23 pm

mindwave65 wrote:I just finished a project like the one you want, sort of.



That's great to hear about your experience and yes it does sound like a similar type scenario. Would love to see a picture of the project if you have one.

eframe
 
Posts: 4
Joined: Thu Aug 22, 2019 6:59 pm

Please be positive and constructive with your questions and comments.