Monday, 17 September 2018

Floureon Pan Tilt IP Camera

Why?

A floureon Pan Tilt wifi ipcam only costs £20 on eBay.  I was intrigued whether it would be any good and whether I could control it from RPi based software.  It echoes my first linux project challenge from 2002 when I had a logitech webcam controlled by an Eagle Pan Tilt mechanism and used it at work to see whether my program to turn a  home light on and off was working.
I am not sure what I would use this for - I think I will just experiment with it and see what I can make it do.

Installation

A short but helpful pamphlet tells you how to set up the webcam.  You download the CamHi app to an iPad or Android device first.  You then add a camera.  The install procedure can find the webcam through wifi and you then put your phone next to the camera and it has an audio hand-shaking procedure to link the app with the phone - it sounds somewhat like old modems talking to eachother.
The app shows you a webcam feed and you can swipe up / down / left / right to move it - however it is very ungainly.

Documentation on the floureon website is rather sparse but contains useful info on features.
Motion tracking, IR and two-way sound all should be investigated.  It says that the movement controls have no lag but that was not my experience.  
It says that the windows client is CMS software.  I downloaded what seemed the appropriate software from the website but I couldn't get either utility, DeviceViewer or SriCam, to see the web cam.

There is an option to check for firmware upgrades, so I upgraded firmware.

Extra Software

I looked briefly at ISpyConnect to see if that would work on windows.  It has some good documentation and I managed to get the URL rtsp://hostname:554/11 to view the video feed.  It seemed a bit cumbersome to use so I installed a nice utility anycam instead.  I could also see the video feed using vlc with this url.

Other URLs which work are rtsp://hostname:554/1/h264major (in VLC) and http://hostname/tmpfs/auto.jpg in Chrome.  The directory tmpfd/* is visible in chrome but doesn't have much of interest in it.  However it does confirm that the webcam contains an embedded linux server.

In fact I found that http://hostname/ gives access to an inbuilt webserver and also allows pan / tilt control.  The buttons remain pressed whilst you click down on them.  Unfortunately there is a 2 second lag on the picture update so it isn't practical to adjust the camera this way.  However there are 8 presets which can be used to set positions and you then "call" them.  In practice this should be enough.

Using Chrome Developer tools you can look at the programs used on the webserver.  I managed to copy all the files I could find down to a Windows folder to see whether they would work locally.    The server uses flash to show video in the browser and I couldn't (easily) get flash to work locally on my Windows PC running video from the IPCAM.  However I did see that the site is written in html/css/javascript.
In particular the commands to control the webcam work through cgi.  Thus I can move the camera left a bit using http://hostname/cgi-bin/hi3510/ptzctrl.cgi?-step=1&-act=left.  This would allow me to set up webcam control very easily.  Googling hi3510 gave me a list of commands that can be used.

Verdict

The camera gives a very nice picture but the lag is quite irritating when you are in the same room.  It would be simple to setup a web page to control the camera and keep the image in a separate session in vlc or anycam.
It would also be easy to setup periodic room scans.
It is also an amazing package a pan-tilt camera accessed via in built webserver for £20.


Tuesday, 11 September 2018

NODEMCU ESP8266 plus OLED

Introduction

I was looking to buy some more ESP8266 boards and my attention was attracted by an ESP8266 ESP-12F NODEMCU Wemos Development Board CP2102 + 0.96” OLED for £5.50. This looked to be an ESP8266 with a small OLED display.  I have noticed NODEMCU and Lua before and thought I would try it out.  There is a great attraction in having a display on your MCU rather than arsing around with LEDs all the time.
A quick investigation told me that NODEMCU is firmware written to allow eLua programs to be loaded onto ESP8266 boards.  Lua is a language developed in Brazil as a small, fast, simple interpreter which is suitable for embedded systems.  It is written in ANSI C and has a C API, programs are compiled into bytecode then run on a processor.
In fact the nodemcu firmware is compatible with the Arduino IDE so you can write Arduino ESP8266 sketches and run them on a the board.
The other nice feature of the development board is that I don’t have to press reset / flash buttons to load programs.  This saves a huge amount of irritation.

Installation

The board plugs directly into my PC and is visible to the Arduino IDE.  It is a standard ESP-12F so you use GPIO2 for the blink program.  I found a suitable OLED library on github and only needed to change SDA(D1) and SCL(D2) to run the demo program.

The verdict is that this is amazing, a wifi enabled arduino with a screen for less than £6.

HTTPS

Now that Google puts "not secure" against http:// web-sites there is an incentive to move to https.  I thought it might require significant technical work or money but it turned out to be quite simple and free.
Firstly you need a web server.  In my case this was an RPI running lighttpd and accessible on t'internet via port forwarding.
Secondly you need a certificate.  These can cost money by letsencrypt provides free certificates which are suitable.
You need certain application software on RPI, I am using Raspbian Stretch which has all the necessary pre-requisites so I just needed to install certbot.
Now you just need to retrieve the certificate from letsencrypt.com using certbot and configure lighttpd and your firewall to use port 443.
https URLs now work which means you no longer have to look at "not secure" messages.
Altogether a very pleasant experience :)