Camera Uploading

This walkthrough explains how to set up a camera file uploader. For more information on the camera module and how to capture a picture to a file please see this guide on RaspberryPi.org.

Logging In

To log in go to https://electrocatstudios.com/dashboard. From here you can easily make an account and password to log in.

The log in screen can be used to sign in or generate a new login

Generate an API Key

We need to set up a device by clicking on the 'New Device' button. Give it a name and description. Select 'Camera' from the drop down menu. Save the new device. The API key will now be displayed on the dashboard front page - the area indicated in red in the image shows where it would appear. The API key is very sensitive, don't share it with anyone unless you trust them implicitly.

The location of the API key for your device, indicated in red

Setting up the device

If you've followed the RaspberryPi.org tutorial and have the camera all set up the following code should take a picture and upload the file to your dashboard for viewing. Please note you will need to replace 'xxxxxxxxxxxxxxxxxxxxxxxx' with your api key or this will fail.
from picamera import PiCamera
import requests
import time

camera = PiCamera()
camera.rotation = 180
while True:
camera.capture('/home/pi/temp.jpg')

with open('/home/pi/temp.jpg', 'rb') as f:
content = f.read()
r = requests.post(url, data={}, files={'temp.jpg':content}, headers={'X-Api-Key':'xxxxxxxxxxxxxxxxxxxxxxxx'})
print(r.text)
time.sleep(300)

You may need to play around with some of the variables - like rotation or file location etc in order to be able to get it to work. And if you call the server with any incorrect parameters the reason for the failure will be printed to the screen.

Viewing Images

From the dashboard click on the 'Readings' button next to the device name and you should be able to view any pictures captured by your camera. If no pictures appear it might be that the upload failed, in which case look in the output from your program to find out what went wrong.

Viewing images uploaded from the camera