just another web log

14 May 2016:
GoPro Hero has some flaws but for free ...
Somebody bought me a GoPro Hero which is the cheapest GoPro at just £100 ;)

It comes with a fully water proof case and a couple of mounts. It has only a tiny grey LCD screen to tell you what mode you are in, so you can not know how the image is framed before downloading it. That said the 1080p 2592x1944 images are very good but distorted by the trademark(not officially) partially fish-eye lens.

There are a only a few modes and almost no settings, which is a pain. For instance the time-lapse happily filled a 32gb SD card with 26900 images but at the default resolution. The first thing I did is reduce then to 10% of their native size.

Another complaint is the microphone is very VERY weak, even with the non water proof case (also provided).

For some reason every time I go to use it the battery is almost dead, not sure if that's just me.

Lastly I have not found anyway to set the time and date with out using the two buttons on the body. They expect people to use a PC/Mac.
14 May 2016:
Window 7 update waiting woes
My son asked me to update his Windows 7 laptop that I had got as rubbish (and minus a hard drive) from work. He cannot do it himself because it only connects to Kidsspot my locked down Wifi network.

No problem just plug it in to an Ethernet cable and run Windows Update and wait a bit... Then a bit longer, still "checking for updates" ...

Four and half hours later and I cancel it try rebooting same issue :(

Then I promptly forgot about it until I need to update my Windows 7 laptop that originally came pre-installed with Vista and is only used for emergencies. Again after 4hrs still "checking for updates". did a bit of investigating and ran Microsoft's Update Fix It tool, but got no further.

It was late so I just left it checking for updates overnight. 8hrs later and it was complete! Still needed a reboot and then a couple more updates, but they were quick to detect and download.

So I went back to the original machine and this time left that for over 7hrs overnight and it worked also.

Finally got the youngest to hand over his Windows 7 laptop and ran the same procedure and this time as well as working it offered Windows 10. Which is odd because that machine is the worst of the bunch with the screen resolution maxing out at 1024x768

Windows 10 did worry me after the fun we had getting Windows 8 to work without a Microsoft account, but it came up and logged him in as the local user as it had in Windows 7

Not sure if I should go back and try and get the other two Windows 10 ...

Why Windows?
Well as I said I have my laptop to do emergency work related stuff, but that is obsolete because I now have a work machine (Surface Pro 4) that travels with me. The kids wanted Flash based games on the web and PC games so Windows was the easy option. I well might rethink that strategy, but at the moment it just works.
02 May 2016:
python script for pir raspberry pi camera
here is the code for my Pir camera including the periodic check from Dropbox

# Pir_camera.py
# Polling script to take and upload images when Pir sensor is triggered
# Rob Davis 2015
# major revision, checks state.txt on dropbox as to operational nature 2016/05/01

import RPi.GPIO as GPIO
import time
import sys
import os
import picamera
import datetime
import dropbox
#urllib3 added to fix ssl warnings when using the Dropbox libraries
import urllib3.contrib.pyopenssl

# Never upload your secret keys to github!
client = dropbox.client.DropboxClient('-------YOURSECRETKEYGOESHERE-------')

liveOutput = False
#Create a camera interface with the half the maximum 5MP resolution
cam = picamera.PiCamera()
cam.resolution = (1296, 972)

#Which GPIO pin are we using?
sensor = 4

#Set the GPIO pin ready for input
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)

#simple state variables
previous_state = False
current_state = False
state = "+"
capturing = False
captureCount = 0

#Upload a file name to a path on DropBox
def UploadFile(filename, uploadPath):
    fileHandle = open(filename, 'rb')
    response = client.put_file(uploadPath + filename, fileHandle)
    #really should check the response, but, it always works ;)

#Get a unique filename based on the datetime
def GetFileName(count):
    return datetime.datetime.now().strftime("%Y%m%d%H%M%S_" + str(count) + ".jpg")

#Get a path based on the date, so a new folder each day
def GetUploadPath():
    return datetime.datetime.now().strftime("%Y%m%d/")

#Get state flag from dropbox
def GetState():
    state = True
    value = "on"
    with client.get_file('/status.txt') as fileHandle:
        value = fileHandle.read(3)
    print "state",value
    state = value == "on"
    return state

#Get time plus check delay (in seconds)
def NewCheckTime(delay):
    return time.time()+delay

if len(sys.argv) >= 2 and sys.argv[1] == "-v" :
    liveOutput = True

isRecording = True
#seconds until next check
delayUntilNextCheck = 60
lastRecordingState = NewCheckTime(delayUntilNextCheck)

#Main loop in a try/catch to allow for CTRL+c termination
    while True:
        time.sleep(0.01)    # very short sleep, 100th of a second
        previous_state = current_state # back up current state
        current_state = GPIO.input(sensor) # get new 'current' state
        if current_state != previous_state:
            new_state = "HIGH" if current_state else "LOW"
            if new_state == "HIGH":
                state = "+"
                capturing = True
                state = "="
                capturing = False
                captureCount = 0
            state = "_"
        if capturing:
            state = "[o]"
            captureCount += 1    # allows for multiple frames per-second
            if time.time()>lastRecordingState:
                isRecording = GetState()
                lastRecordingState = NewCheckTime(delayUntilNextCheck)
            if isRecording:
                filename = GetFileName(captureCount)
                uploadPath = GetUploadPath()
                cam.annotate_background = picamera.Color('black')
                cam.annotate_text = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
                cam.capture(filename)    # get a photo from the camera
                UploadFile(filename, uploadPath)    # upload the photo to a 'todays' folder on DropBox
        if liveOutput :
            sys.stdout.write(state)    # print out the state without a LF
            sys.stdout.flush()    # flush to stdout or it will sit waiting for a LF
except KeyboardInterrupt:
    print "User Quit, doing GPIO clean up"

02 May 2016:
dropbox in ssl warning toilet roll pi caper
I wanted to revisit my PIR Pi security camera.

Pir sensor and Pi camera mounted in toilet roll attached to Raspberry Pi
(yes, that is a toilet roll tube) The Pi camera has a fish-eye lens clipped over it for a better field of view.

Firstly I wanted an on/off option and to be awkward I wanted to be able to change the state remotely.

As I had the code writing files to dropbox it was a small step to read a "status.txt" file.

Testing the code directly worked fine but gave me a SSL warning. Rebooting the Pi and letting the scripts run failed and the only thing in the logs was this warning.

/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:97: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

I tried installing the httpsclient upgrade
sudo pip install --upgrade ndg-httpsclient
but that lead to

sudo apt-get update
sudo apt-get install python-dev libffi-dev libssl-dev build-essential
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
sudo pip install --upgrade ndg-httpsclient
sudo pip install urllib3[secure]
sudo pip install --upgrade urllib3[secure]

and you can imagine those were not entered in that succinct order.

That did not fix the warning :(

In fact they got worse.

/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

Which lead to

sudo pip install --upgrade pyopenssl ndg-httpsclient pyasn1

I then added the suggested code to top of my Python script, even though I only use the Dropbox library not urllib3 directly.

import urllib3.contrib.pyopenssl

and it Worked!!

I can now use the Dropbox app on my phone and edit a text file to switch on or off the image uploading from the PIR camera.

boot note:
I wonder if it would have worked if I had just disabled the warnings!?
loading results, please wait loading animateloading animateloading animate
[More tags]
rss feed



flog archives

Disclaimer: This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk In fact I'm not responsible for anything ever, so there!

[Pay4Foss banner long]