just another web log

29 Jul 2020:
pi powered toilet roll lights up the night
The Toilet-roll security camera is in the process of being rebuilt with a Pi Zero.

Previously I got the SD card built, the Pi setup headless and tested the camera (and fixed the PINKing). Now it is time to get all my code working with the PIR.

Installed the prerequisites.
sudo apt install python3-picamera
sudo apt install python3-pip
sudo pip3 install dropbox
sudo pip3 install RPi.GPIO

copied across the code and setup the root crontab and ...

My Under-shelf lighting came on :)

Now I need to mount it all back in a new toilet roll ;)
29 Jul 2020:
a very pink noir in a greyworld fix
The Toilet-roll security camera is in the process of being rebuilt with a Pi Zero.

First I get the correct image from Raspberrypi.org. Lite has no GUI and is perfect for a headless project like this.
wget https://downloads.raspberrypi.org/raspios_lite_armhf_latest

then to write to the SD card we either

unzip raspios_lite_armhf_latest
Archive: raspios_lite_armhf_latest
inflating: 2020-05-27-raspios-buster-lite-armhf.img

then, as root
dd bs=4M if=2020-05-27-raspios-buster-lite-armhf.img of=/dev/sdd status=progress conv=fsync
(where /dev/sdd is the SD card on my machine, may be different on yours)

unzip -p raspios_lite_armhf_latest | dd bs=4M of=/dev/sdd status=progress conv=fsync
(where /dev/sdd is the SD card on my machine, may be different on yours)

and you want to reference the drive/card not a partition on the drive.

once the image is written to the SD card
mount the boot partition and enable ssh

mount /mnt/sdd1
touch /mnt/sdd1/ssh
sync;umount /mnt/sdd1

(where sdd1 is the boot partition on the SD card on my machine, may be different on yours)

mount /mnt/sdd2
cp wpa_supplicant.conf /mnt/sdd2/etc/wpa_supplicant/wpa_supplicant.conf
echo "piserver" >> /mnt/sdd2/etc/hostname

Where piserver is the name for your new installation and the wpa_supplicant.conf is a copy of the wifi settings from another working machine.

put the card in Pi and power it up. Then from another machine
ssh pi@piserver.home
sudo raspi-config

Navigate to enable interfaces and camera

ssh into your pi and test the camera
raspistill -o cam.jpg
The light on the camera flashes when the picture is in the process of being taken.

I scp'd the file off the Pi to view it and ...
Pink, very pink !?

I can find a number of discussions around IR filters, but I have not changed anything since this camera was taking pictures with the previous Pi.
Turns out that in the process of enabling the new GPU in the Pi 4 Pi Noir broke :( - well, became overly pink.

I tested with the special parameter -awb greyworld
raspistill -awb greyworld -o cam.jpg

Which worked perfectly
and then fixed it permanently by adding
to /boot/config.txt and rebooting

and now
raspistill -o cam.jpg
produces the expected, not so pink image.

The Pi Noir camera images are always a little off in colour, due to their sensitivity to IR light.

Next add the PIR sensor...
25 Jul 2020:
old pi retiring after unpowering toilet roll
The Toilet-roll security camera is really not happy. I dismantled the rather wonky frame connecting it to an old desk lamp and started work diagnosing the issue.

With everything connected (Pi Camera, IR sensor, Ethernet) I get a solid Red PWR LED and one brief Green flash from the ACT LED.
Disconnecting the Pi Camera, IR sensor and Ethernet, I get a solid Red PWR LED and a few brief Green flash from the ACT LED, that continues for a few seconds. This also stuck on the Rainbow screen.

The awesome Raspberry Pi Forum Cannot boot STICKY has a lot of information about possible remedies.
Thing is, this a 2012 Raspberry Pi model B Rev 2.0. (i.e. has mounting holes). That means it is 8+ years old and I can get a Wifi enabled Pi Zero W for less than half the price of the original.

It could just be the SD Card is knackered...

/me scrounges another Raspberry Pi model B Rev 2.0.

Same result with SD Card.

So the SD Card was affected by the power-cut and possibly by the under voltage situation that followed.
(I have not had a good experience with the full sized SD card since the Raspberry Pi was released)
18 Jul 2020:
Powercut pi pi pi madness hub
Had a power-cut last week and a number of things were affected

1: Main machine down. I always a set the BIOS to default to OFF in the even of a power-cut after an unfortunate incident involving a cable modem. All my firewall scripts had to be run manually after logging in. So the power went off while I was at work, the power came on and the cable modem routed internet hackers directly to my unprotected machine for many hours before I got home. It was hosed, had to wipe everything and restore from backup. I know things are different now, but this really sticks in my brain.
2: I noticed that directly after the power came back on the Under-shelf lighting WAS working, so all the power networking was alive and well. The next day, no lights and glance at the Toilet-roll security camera showed it was not sending any pings to the Undershelf lighting Pi.
3: The Pi4 slideshow server had stopped.

2 and 3 are significant as they are both powered off an original Pi Hub USB hub. I love the look of these things, shaped like the official Raspberry Pi logo. The strange thing is it was still supplying a little power to both Pis, just not enough for them to boot. Luckily I had an unused spare and after swapping them over the Pi4 roared back to life, but the Toilet-roll security camera pi sits with a solid Red LED. Will investigate later.

The funny thing is I can Ping the Under-shelf lighting Pi Zero from my main machine and the lights come on. Of course, by design, they fade after a short while. Does show the auto-start script works there.

Maybe I should replace the Toilet-roll security camera pi with a more reliable Pi Zero. Pretty sure I have knackered the SD card, which was the way of old Pis with full sized SD cards.

Note to self: Check if PSU is the bad component of the Pi Hub, rather than the unit itself.

There was another situation. In the process of replacing the Pi Hub, I took the opportunity to dust, clean and tidy the gang plug powering everything. I made sure I did not touch the Router or the Ubiquity WiFi access point. But got a number of complaints the internet was down. Oops. I had unplugged the mini Ethernet hub that connected everything together :)
04 Jul 2020:
once more into the vga breach dear pi
Time for another SV-3 Raspberry Pi vga update.

Powering everything off and on again with the last working settings of

Gets me a relatively stable desktop. There are some issues.

No Blue. This will be my wiring :(
Slight ghosting at the top of the screen. The top 5th of the screen contains a ghost of the bottom 5th of the screen and is really noticeable when moving the mouse down there.

Good news is that my 640x480 display is running at a true 800x600

Next steps are to try and replicate this on the Pi Zero I soldered pins onto and to find something worthwhile to run on it.
04 Jul 2020:
you tried to scam the bank of englands manager
Been getting a lot a scam calls the last few weeks. Most have started with an automated message that Amazon is about to auto-renew your Prime account and you have to press "1" to speak to an operator to cancel. The script is always the same, they need remote access to your device to confirm the bank details.

I strung one along for a while by reading out Google Image results for the TeamViewer connection app. A number had such bad lines they gave up. But one wanted me to install TeamViewer Remote on my phone. This was easy to keep on the line, as I just kept finding other things on the App/Play store and fumbling the install.

Then today I got a good old classic "We are from BT, you have hackers on your internet, we will disconnect you". The first agent I spoke to could barely hear me and nor I him, but about 20 mins later I get another call. This one starts with the same spiel but is an automated message, "Press 1 to speak to an operator".

This conversation got a bit surreal as I got more and more frantic that the hackers had accessed my computer while I was VPN'd into work. A fictional job, where I had direct control of the Bank of England's computers. I got more and more agitated, stating that the police would need to be called as the hackers would have been able to access my account at the bank. The strange thing was that the agent kept steering call back to he needing remote connection and my bank details.

I got so flustered that I started to have panic attack, repeating that, this was major security breach and I needed to speak to my manager and police. I could hear the exasperation in his voice as he repeated that if I was not going to turn on my computer he could not get rid of the hackers :D

All these calls have been reported directly to BT.

BT scam call reporting page
01 Jul 2020:
what the resolution is that
Normal programming can return now.

We last left the Raspberry Pi Gert VGA 666 SV-3 project waiting for the battery to charge.

This is going to all be about the settings in the Pi's config.txt


as before, no signal and it was the same for modes 6 and 7, both 640x480 resolutions. Then I tried 4 (my preferred mode previously) and then and 3. 3 actually showed a signal, but the bottom portion (about a 5th) was just static.

But, hang on, mode 3 is 720x400, time to try all the modes and groups.
dpi_mode resolution Freq. signal notes
1 640x350 85Hz No
2 640x400 85Hz Yes Bottom 5th of screen is static(*1)
3 720x400 85Hz Yes Bottom 5th of screen is static(*1)
4 640x480 60Hz No This was expected to work(*2)
5 640x480 72Hz No
6 640x480 75Hz No
7 640x480 85Hz No
8 800x600 56Hz Yes Flickery(*3)
9 800x600 60Hz Yes Flickery(*3)
10 800x600 72Hz Yes No flicker and image correctly centered
11 800x600 75Hz Yes No flicker, but image shifted to right(and lost)
12 800x600 85Hz Yes 4 copies of the mouse cursor(*4)
13 800x600 120Hz No
14 848x480 60Hz Yes Display shifted right and then wraps

(*1) Looks like about 80 pixels, rest of the display is correctly shown.
(*2) Matched what the manual said it wanted.
(*3) only on the bright whites
(*4) this is what I remember with bad resolutions and VGA monitors

dpi_mode resolution Freq. signal notes
1 VGA(*1) 60Hz No thought this would work
2 480p 60Hz No
3 480p 60Hz No (*2)
4 720p 60Hz Yes squished and shifted right
5 1080i 60Hz Yes heavy flickering and shifted bottom and left with wrap
6 480i 60Hz No
7 480i 60Hz No (*2)
8 240p 60Hz No
9 240p 60Hz No (*2)
10 480i 60Hz No
11 480i 60Hz No (*2)
12 240p 60Hz No
13 240p 60Hz No (*2)
14 480p 60Hz No
15 480p 60Hz No (*2)
16 1080p 60Hz Yes all static

(*1) VGA = 640x480
(*2) same as previous mode but 16:9 aspect ratio

OK. So it is not all the modes in both groups. There are 86 in the DMT list and another 107 in the CGA (over half of those are marked Pi 4)

So that is the end of the story to get the SV-3 to work ?

Not quite. My son asked about the SV-3 on my desk and I turned it on expecting him to see the working, but oddly coloured, desktop. Instead he saw the vertical lines.

Not sure what to do now and could non-640x480 resolutions have worked previously?
01 Jul 2020:
another test stand by
one more test
01 Jul 2020:
testing flog please stand by
So that last testing post was needed to fix the previous mess up. Where I encoded < in to &lt; but then immediately encoded that into &amp;lt;

I think I have it fixed now.
01 Jul 2020:
testing please stand by
1 < 2 && 3 > 2
01 Jul 2020:
oops up side your character encoding entity
Oops! what happened in that last post ?

The f-log is still held together by random shell scripts and even a bit of Perl. This "just works" (most of the time) and I rarely touch it.

But I wanted a way of catching some of my common mistakes. Including forgetting to encode greater than, less than signs and the ampersand symbol. To add URLs and bold text I cobbled together a basic BBCode syntax.

[url title="what user sees"]actual url[/url]

A bit of regex would then rearrange that into

<a href="actual url">what the user sees</a>

Which leads us to the latest changes. I moved all html code to BBCode (-ish) for URLs, and img, code, output and em. Then I added a counting script that detects when an open tag has the accompanying closing tag.
All this allowed me to convert greater than, less than signs and the ampersand symbols into their html entities. It worked for a few posts.

The last post had a number of &nsbp; entities and they unfortunately got encoded when they should not have.

There were also some other bad encoding issues, but they were caught by the tag counting script.

Confusingly in sed the substitution part of the expression has to escape & with a backslash \& otherwise it is interpreted as a \0 (match all). All very confusing

echo "banana > orange but < tea & cake" | sed -re 's/</&lt;/gi' -e 's/>/&gt;/gi' -e 's/&/&amp;/gi'
banana >gt; orange but <lt; tea &amp; cake

which is so close

echo "banana > orange but < tea & cake" | sed -re 's/</\&lt;/gi' -e 's/>/\&gt;/gi' -e 's/&/\&amp;/gi'
banana &gt; orange but &lt; tea &amp; cake

Now this post contains a lot of <, >, and & characters so lets see how it fares.
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!