Monday, 30 May 2016

NatureBytes Lite - bare bones build for Raspberry Pi A+


The NatureBytes Raspberry Pi camera kit is an excellent way to capture great photos of wildlife.



The lovely injection-moulded case is perfect for keeping everything nice and dry when deployed outside. the only problem I encountered was using the supplied Raspbian image: the GUI that ships is really nice and will be well suited to people using a Pi for the first time. But on a Raspberry Pi model A+ it can be quite resource intensive and I found myself getting frustrated with the performance.


Personally I wouldn't really consider using X-windows on an A+: it just doesn't have the muscle.

So I thought I'd put together a bare-bones installation that just runs the code necessary to detect motion with the PIR and take photos. I'm not bothered about saving onto a USB drive either: I'm happy to use the SD card and then connect the Pi to a network and extract using ssh.

So here is my recipe for building a quick, low profile image that works really well on an A+. Note that this does not include any windowing system so it's command line all the way!

1) Download the latest Jessie-Lite image and write it to an SD card.

2) Boot up and install the following stuff:

sudo apt-get update
audo apt-get upgrade -y
sudo apt-get install python3 python3-dev git i2c-tools python3-pip
sudo pip3 install gpiozero picamera RPi.GPIO spidev

3) Configure the Pi: run

sudo raspi-config

and enable the Camera and I2C interface (under advanced options). You might as well expand the filesystem to fill the whole disk too.

4) If you want to use the Real Time Clock, follow these excellent instructions from the Pi Hut.

5) Add the following code to a file (e.g. nblite.py). This makes use of the great gpiozero library to handle the PIR and starts a new logfile every time the code is run. Each image is date/timestamped and saved into /home/pi. The Pi will keep taking photos every half a second as long as motion continues to be detected.

from gpiozero import MotionSensor
import logging
from datetime import datetime
import picamera
import time
logfile = "/home/pi/nb-"+str(datetime.now().strftime("%Y%m%d-%H%M"))+".csv"
logging.basicConfig(filename=logfile, level=logging.DEBUG,
    format='%(asctime)s %(message)s',
    datefmt='%Y-%m-%d, %H:%M:%S,')

pir = MotionSensor(11)

print('Starting')
logging.info('Starting')
while True:

    pir.wait_for_motion()
    logging.info('Motion detected')
    print('Motion detected')
    while pir.motion_detected:
        print('Taking photo')
        ts  ='{:%H%M%S-%d%m%Y}'.format(datetime.now())
        logging.info('Taking photo: '+ str(ts)+'.jpg')
        with picamera.PiCamera() as cam:
            cam.resolution=(1024,768)
            cam.capture('/home/pi/'+str(ts)+'.jpg')
        time.sleep(0.5)
    print('Motion Ended')

    logging.info('Motion Ended')

6) Edit the /etc/rc.local to include the line

/usr/bin/python3 /home/pi/nblite.py &

before the exit 0 final line so that the code starts every time the Pi is booted.

That's it! All done.






34 comments:

  1. Richard

    Thanks for doing the work and writing it up - the thought was beginning to form in my mind that the config for an A+ needed lightening, but it hadn't really registered.

    I think I've spotted a typo above, the line
    pir = MotionSensor(11)
    should really be
    pir = MotionSensor(17)
    if one has wired up the box according to the NB instructions.

    Also, I like my photos with a completely hierarchical name, so I've changed the line with ts = to:

    ts ='{:%Y%m%d-%H%M%S}'.format(datetime.now())

    Thanks again...

    Peter

    ReplyDelete
  2. Thanks for this, I did add a loop so it would take 3 photos one second apart but found the minimum separation was almost 3 seconds. The slow usb stick was part of the problem. Your suggestion should also speed things up.

    ReplyDelete
  3. This is great, I wondered why they didn't use PiCamera, and yes choosing a better (faster) USB drive really helps the speed on the standard kit, the supplied Kingston drive is SLOWWWWW. I am writing to a RAM disk and scp'ing each image to network storage now. I am working to replace their overlay implementation as it appears to stomp over the EXIF data.

    ReplyDelete
  4. I've been meaning to try this out for ages and have finally got round to it. Compared to the NatureBytes software this is a vast improvement and I've managed to capture some great shots of the birds that come to our back garden. Thank you for publishing this blog.

    ReplyDelete
  5. Hi Richard, thanks for your addition to the project. I've modified my program to record video but find that after two or three videos the Pi only creates empty video files i.e. 0kb.

    Have you encountered this before? I don't know whether this has to do with the pir polling too frequently?

    ReplyDelete
  6. The Home Fix has been providing first-rate home appliances repair services and maintenance. We provide excellent home appliances repair, maintenance and electrician services.

    ReplyDelete
  7. Our company is a well known Electrical maintenance company Dubai and specialized in electronics. So, if you are looking for someone to maintain Electrical Appliances or something else then your worries are over. We will give the services like Electrical Services Dubai with the certified Electrician in Dubai. Our electrical contractor will construct the work related to the design, installation and maintenance of electrical items. So, if you are interested to take our services then contact Green Astro Pools & Landscape L.L.C or visit our website for more information.

    ReplyDelete
  8. Eagle Technical services are the best painting service provider company in Dubai. Our company is the best company for Dubai professional painter service, Professional Painters Dubai, Building painting service Dubai, Dubai painting service, professional painting company Dubai, Interior Exterior painting service Dubai, painting service Dubai, and Exterior painting work Dubai.

    ReplyDelete
  9. Get the best interior renovation company in Dubai from Fix Hub Technical Services LLC. We have workers, who have years of experience in this renovation field, and also they are experts in other fields Like, Interior fit-out, Gypsum work, bathroom Renovation, Office renovation dubai, Villa Renovation, Kitchen Renovation, etc. So if You want our services Then just contact Fix Hub Technical Services LLC fast or you can visit our Website for more information.

    ReplyDelete
  10. we have the best printer repair shop in dubai
    , we can repair all types of printers at very effective cost, to know more about our service just contact us.

    ReplyDelete
  11. If You Want Your Own Cheapest Visa at a low cost and if you are looking for a company that can provide you with these services, then you have come to the right place. We give a lot of services here like, freelance visa, freelancer visa Dubai, freelance visa Dubai, own visa in UAE, freelance visa UAE, freelance work permit Dubai.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Thanks for sharing valuable info..........

    High fiber foods

    ReplyDelete
  15. Students are continuously on the look-out for premium quality assignment help. Our psychology homework help specialists are highly experienced and knowledgeable experts having earned PhD in their respective domains.

    ReplyDelete
  16. The Cam Case design provides space for battery upgrades for those wanting extra juice to power your kit for even longer. data recovery dubai Millennium Plaza Hotel Tower, Office: 1504, Sheikh Zayed Road, Dubai, United Arab Emirates.
    Contact number - 045864033
    For help Free Pickup & Delivery

    ReplyDelete
  17. Exter Networks is not new to meeting the challenges of Managed Technology Services such as Network Operations Center Services (NOC), Security Operations Center Services (SOC) etc. Since 2001 we've exceeded expectations using our Full Technology Lifecycle Support Model that provides end-to-end solutions featuring Design, Deployment and 24/7/365 support.
    Managed DDOS Service
    Managed Desktop Services

    ReplyDelete
  18. Excellent post. I had been looking for this information for quite some time. Thank you for your contribution. . Oracle Fusion HCM Training

    ReplyDelete
  19. Fly Ash Blends in Houston, Texas are commonly used in construction to improve concrete strength and soil stability. These blends, which incorporate fly ash with materials like cement or lime, offer environmental benefits by recycling industrial byproducts and reducing the need for traditional cement.

    ReplyDelete
  20. For those who enjoy technology, NatureBytes Lite provides a simplified, effective build for the Raspberry Pi A+. Its understated style preserves accessibility while showcasing the Pi's capabilities. Use first-rate catering services for your upcoming tech workshop Catering services Pecos Texas to keep attendees motivated and on task.

    ReplyDelete
  21. Future Style By Nida Faysal embodies contemporary Pakistani fashion with a fusion of traditional elegance. Known for its exquisite craftsmanship and unique designs, the brand offers sophisticated apparel that resonates with modern trends. It caters to individuals seeking timeless yet innovative fashion statements.

    ReplyDelete
  22. At Relax Massage Center in Karachi, discover a sanctuary of tranquility where skilled therapists pamper you with rejuvenating treatments. Let go of tension and stress as you indulge in a blissful escape, leaving you refreshed and revitalized.

    ReplyDelete
  23. Experience the epitome of luxury and relaxation at themassage and spa Karachi, offering a blissful fusion of traditional therapies and modern techniques. Rejuvenate your mind, body, and spirit in a serene oasis, where expert therapists cater to your every need, leaving you feeling replenished and renewed.

    ReplyDelete
  24. For the Raspberry Pi A+, NatureBytes Lite provides a simplified, effective build that is ideal for DIY projects and tech enthusiasts. It's a great option for people looking for functionality and simplicity. Remember that you can place an order coffee online in dubai to stay motivated as you work on your assignments!

    ReplyDelete
  25. Taking amazing pictures of animals is made possible with the help of the NatureBytes Raspberry Pi camera package. For those who love the outdoors and want to learn about photography, it's ideal. Make sure your car looks as nice as it does while you're out taking those amazing pictures by using Ottawa Auto Detailing.

    ReplyDelete
  26. With its simplified build for Raspberry Pi A+, NatureBytes Lite is ideal for individuals who value functionality and ease of use in their projects. It's a fantastic approach to start using tech without getting bogged down in details. A Minority Business Enterprise Certification can be a great resource for minority-owned companies looking to expand and open doors to new prospects.

    ReplyDelete
  27. It appears that the injection-molded case is perfect for outdoor use because it keeps everything dry. Despite being user-friendly, the pre-installed Raspbian GUI proved to be too resource-intensive for my Raspberry Pi model A+. This resulted in annoying problems with performance when using the system. In light of this, visit Car Detailing Ottawa for fine detailing services.

    ReplyDelete
  28. With its stripped-down design for the Raspberry Pi A+, NatureBytes Lite provides a simplified method for using technology to explore nature. Enjoy a delightful break with decadent chocolates from the متجر شوكليت الأحساءand elevate your coding experience with this small setup.

    ReplyDelete
  29. ILFORNO is ranked among the top Italian restaurants in Dubai celebrated for its authentic, flavorful Italian cuisine. With a focus on fresh ingredients and homemade pasta, it offers a delightful menu that captures the essence of Italy.

    ReplyDelete
  30. Edmonton cracked basement wall repair is essential to prevent water infiltration and structural damage. Addressing cracks promptly can stop leaks and reinforce the foundation, ensuring long-term stability. Professional repair services can effectively seal cracks and protect your home from further issues.

    ReplyDelete
  31. Italian kitchen design dubai combines elegant craftsmanship with modern functionality, featuring sleek cabinetry, premium materials, and minimalist aesthetics. These designs emphasize open spaces, high-end finishes, and a timeless, sophisticated look, tailored for luxurious yet practical living.

    ReplyDelete