Tuesday, 27 November 2018

Why everyone should keep a Soldering iron (and wire stripper)


The children have a toy guitar which they played with for quite a lot, with plenty of dropping and banging before it disappeared in a cupboard for a few months. Here it is, plenty of buttons for playing tunes, LEDs and the like.

But horror, when it was found in the back of the cupboard and new batteries inserted absolutely nothing happened. Horror for the children I have to add, I didn't really miss the sound it made!

But given my geeky nature I had to see what was the problem.  Opening it proved to be tricky. Although not glued it was held together by 18 screws, some of which were very tight. Eventually the inside was revealed:


Fortunately, the reason nothing worked was immediately obvious.

The wire to the positive battery terminal had snapped off. So the fix was a quick strip of the insulation and soldering the wire back onto the terminal.

Finally, replacing 18 screws turned out to be a lot quicker and the guitar lit up and played as soon as it was turned back on!

I'm looking forward to years more play out of it !!

Tuesday, 13 November 2018

Bird Box Camera Failure

After 2 years of continuous filming. The BirdBox camera has finally failed.

The Raspberry Pi itself is fine, I could still log onto it but unfortunately, when I tried to start up the motion detector python it complained it couldn't find the camera and that I should try enabling the camera. Now, clearly I'd already done this so some more investigation was required.

I then tried to take a still picture with raspistill, but this returned the following:

mmal: Camera is not detected. Please check carefully the camera module is installed correctly

This didn't look good.

I decided to take the Birdbox down to investigate. Being November there are no issues around disturbing nesting birds and the box itself can be taken down and cleaned between September and January.

The Birdbox was showing signs of age but the Raspberry Pi and Power over Ethernet box both looked as good as new.


As for the camera, this was looking a bit worse for wear. It turns out a large spider had made a home under the camera and had made meals of a number of woodlice.



After getting the Camera IC indoors I could certainly now see some quite significant corrosion. This is clear in the image below taken with a microscope. In particular the C8 capacitor looks to have corroded completely. Notice also the droppings.


I have a spare camera so I'll be setting up a new installation. Next time I'll look at to seal it more thoroughly.

Some links I discovered while looking for what the corroded capacitor was for

Thursday, 30 August 2018

Quirky Old Technology


I'm sure most people who at into technology and gadgets have a whole heap of old stuff lurking around in the back of cupboards, in lofts or garages. Well here is one of mine, still with box:

Yes, a Casio PB-100

Pop in a couple of CR-2032 batteries and it still works, albeit with a very faint screen
So I fired it up and entered in the first program in the manual (yes, still in the box)

10 INPUT "N= ", N
20 S=0
30 FOR I=1 TO N
40 S=S+1
50 NEXT I
60 PRINT S
70 GOTO 10

Lovely BASIC nostalgia feeling aside, this doesn't really do much but when I ran it I got some very strange behaviour:

ERR6 P0-20

(Incidentally, Change to MODE 0 and SHIFT 0 to run)

P0 is the program in slot 0 and -20 is line 20. Now, line 20 is the rather innocuous assignment of S=0 and ERR6 from the separate technical manual is :

Variable error
  • Attempt was made to use the same memory for a numerical variable and a character variable at the same time
  • Do not use the same memory for a numerical variable and a character variable at the same time
This is interesting, a character variable is assigned with a $, for example A$. So the assignment S=0 should be fine.

Then If I change to from S to P, say, it all works fine and then changing back to S it worked again. Very mysterious.

Yes, I did make sure I didn't enter S=O !

So no real idea what's happening, probably some path in the internal circuitry is failing but at least I managed to get it working in the end.


Sunday, 27 May 2018

Stormy


Last night (2018-05-26) starting around 11pm we had a thunderstorm over London.

Now, we get a few thunderstorms over London but this one was pretty spectacular.  From our location, there was about 40 minutes of almost constant thunder and impressive lightning every few seconds.

And the technical angle? I took a video of a few seconds of the storm and uploaded it to YouTube.
This is my first YouTube upload, and second video only to watching an old multimeter.
 

Monday, 21 May 2018

Starting with Docker

Until now, I've not done any work with containers so for a bit of fun I decided to setup my RESTful web server to run with Docker.

As a reminder, this is a simple python server built using web.py running on my Raspberry Pi Zero.

Step 1: Install Docker on Raspberry Pi
First up, install Docker. To do this, run these commands:

curl -sSL https://get.docker.com/sh

Set it up to start automatically on a reboot 

sudo systemctl enable docker:

Now add the pi user to the docker group, this means there'll be no need to use sudo in future:

sudo usermod -aG docker pi

Reboot, and then run:

docker run hello-world

pi@raspberrypi:~/Server $ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.


Success!

Step 2: Build Web server Image
The directory where the Dockerfile and build files is contained is called the context. The Dockerfile is a simple text file that contains the commands necessary to build the customised image.

All files used to build the image must be in the directory tree with this folder at its root:

pi@raspberrypi:~/Server $ ls
data  Dockerfile  RestServer.py


The image used to build for the Web server was a based on raspbian for Raspberry pi loaded from the docker hub. So starting from this point, the Dockerfile can be created:

FROM resin/rpi-raspbian:latest
ENTRYPOINT []

RUN apt-get -q update && \
    apt-get -qy install \
    python python-pip

RUN pip install web.py

WORKDIR /app

COPY RestServer.py /app

COPY data /home/pi/data/

CMD ["python", "RestServer.py"]


The script updates and installs python & python-pip before then using that to install web-py. It then setups the necessary directories and copies the python file along with the data folder for local storage.
Finally the CMD starts up the script using python.

This was then built with:

docker build -t rest-server .

Step 4: Run the Web server Container

Now to run the rest-server use this command

docker run -p 8080:8080 rest-server 

The -p argument exposes the 8080 port to external clients

This will start the container in the foreground and attach to stdout.

To run in "Detached" mode, use the -d flag. When starting this will return the long id of the container

Useful commands
Docker documents can be found here


To list the running containers:
docker ps

Open a bash shell into the image:
docker run -t -u rest-server /bin/bash 

List local docker images:
docker image ls

Delete a docker image
docker rmi <image id>

Tuesday, 10 April 2018

The pain of hours long downloads ... failing

I have a TomTom SatNav with which I use the MyDrive Connect Application on Windows 10 to download and update maps.

A Western Europe map comes in at around 3GB but when I attempted to upload this last week the time to complete indicator unfortunately went rapidly up to 12 hours. (This with a 50Mbit broadband connection which was otherwise working perfectly)

So, with that in mind I started investigations. First, the Windows task manager showed the biggest hog of network was Delivery Optimisation Service. Now this was interesting, because I'd already disabled it using the options under:

Settings > Update & security > Windows Update > Advanced options

I've only got one Windows 10 machine so this is a service I don't need. However, there is another instance of the service running using the Microsoft Store. I disabled this by turning off automatic app updates in the Windows Store Settings. Now the downside is I'll have to manually update Store apps so this won't work for everyone. However, given the number of updates pending already, and for some apps I'd never use (Groove Music for example), I'm not too upset. One thing that might be useful though, instead of often vague "What's new in this version", it might also be nice to show exactly what version I've got installed.

Back to the download. This did eventually speed up and ended up taking around 3hours. But when it said complete I got a dreaded no-maps found on my TomTom device, which is an indication the install was corrupted.

For some reason, it came to my mind that the USB cable I'd been using had shown some strange behaviour when I'd been developing with my Android phone so I decided to replace it and try again and, as if by magic, the update completed successfully in minutes.

You never can tell where a bad USB cable takes you.



Saturday, 30 December 2017

Setting up a new Raspberry Pi (2017 Edition)

Last post of the year and admittedly not all that many in 2017. This one is more of a personal reference of the steps taken to setup a new Raspberry Pi. In this case using the Raspbian Jessie OS.

The version of the Pi used here, the Zero W, includes built-in WiFi.

First steps were performed using a Windows 10 machine.

1. Download image. The one I'm using is the 10th April 2017 Raspbian Jessie image.
2. Get a new Micro SD card and plug into the PC. I have an external USB card reader for this. It should appear as a newly mounted drive.
3. Unzip and flash the .img file to the SD card. I use Etcher. Follow the workflow to select the image, select the drive corresponding to the SD card and then Flash.
4. Disconnect the external drive and insert the Micro SD into the Raspberry Pi.

Now I plugged the Raspberry Pi into a TV via HDMI (an HDMI to Micro HDMI connector is required for the Zero) and switched on. At this point you should see it boot and start the windows.

5. Next, the important step, change the default password. Open a command window and use the pwd command.
6. From the same command prompt, enter sudo raspi-config. Select the Advanced Options and Expand Filesystem. This ensures the whole of the SD card is available to the Pi.
7. In the same tool, enable SSH and VNC. This is because I want to remotely logon to the machine from elsewhere on my network.
8. Now reboot.
9. After the machine has restarted I connect to the network using WiFi. I used the UI from Raspbian to do this.
10. Now I can get the latest updates of the OS, sudo apt-get update followed by sudo apt-get upgrade.
11. For the purposes of my network, I want to use a static IP address, rather than use one assigned by DHCP. To do this edit /etc/dhcpcd.conf and add the following lines to the bottom, assuming the router IP is 192.168.0.1 and we want to setup our static IP to 129.168.0.207

   interface wlan0

   static ip_address=192.168.0.207/24
   static routers=192.168.0.1
   static domain_name_servers=192.168.0.1
 
12. Connect to the network share. From the command line it's possible to do this using:

    sudo mount -t cifs -o guest //ip.of.nas/Public /home/pi/NAS

I want to be able to connect automatically on start up. To do this requires a couple of steps, first add the following to the end of /etc/fstab

  //ip.of.nas/Public /home/pi/NAS cifs guest 0 0

However the problem with this as it stands is this step is run before connection to the network at boot time. To fix, open raspi-config, select boot options and Wait for network at boot.
13. Finally reboot. The Raspberry Pi setup is now complete.