Robert Cudmore    archive    tags    search    software

Raspberry Pi video controller

This is a video server running on a raspberry Pi Linux computer. It provides a web interface to stream and record video.

What it does


<IMG SRC=”/images/example-iosserver.png” width=700 align=CENTER>

How it works

The server is pure python running on the Pi. It uses the web framework Flask. Once the web page is loaded by a client browser(you), any objects within the webpage can be updated in real-time using flask-socket-io. This can be done without refreshing the entire webpage. The layout and interface objects are using Bootstrap.

Required Hardware


Running the server

sudo python

This will tell you the IP adress you use to login to the server.

Connecting to the server

Just point any browser to the server address.

Extra Details

The internet of things

Python code running on any other internet-connected device can ‘inject’ values into the iosserver and they will show up in real-time inside all client browsers. Here is example code on another Pi that has its own temperature and humidity sensor.

# send to iosserver
import requests
	payload = {'timestamp': thisTimestamp, 'insideTemp': temp, 'insideHum': hum, 'outsideTemp' : outsidetemp, 'outsideHum' : outsidehumidity}
	r=requests.get('', params=payload)
	print 'sent to !!!'
	print payload
	print '-------- error sending to iosserver ---------'

The iosserver receives this GET request with a little function decorator.

def add_numbers():
    timestamp = request.args.get('timestamp', '') # defaults to ''
    insideTemp = request.args.get('insideTemp', '')
    insideHum = request.args.get('insideHum', '')
    outsideTemp = request.args.get('outsideTemp', '')
    outsideHum = request.args.get('outsideHum', '')
    print 'timestamp=', timestamp
    # myVideo is another python class that handles all runtime
    # it is not detailed in this example
    myVideo.insideTemp = timestamp + ' ' + insideTemp
    myVideo.insideHum = insideHum
    myVideo.outsideTemp = outsideTemp
    myVideo.outsideHum = outsideHum
    print 'add_nummbers() received ', timestamp, ' ', insideTemp, ' ', insideHum, ' ', outsideTemp, ' ', outsideHum
    return ''

There are a few more steps including some javascript and html. This is not a Flask or Socket-IO tutorial. Have a look a socket-io for Flask.

Tags: raspberry pi, data acquisition

©2019. Robert Cudmore.