Dimmer – Reduce your computer screen brightness

It has started getting really hot in the UK and my flat is about 28 degrees at night. This means I have been sitting in a dark flat with all the windows and doors open.

This works well but If I want to work on my computer then the lowest brightness level is still too bright. I did some searching around and a quality piece of software “Dimmer“.

This is a really simple exe you unzip and run. Once running it will reduce the contrast of the screen. This in effect reduces the brightness by turning white colours greyer.

I have been using this for a couple days and had to recommend it as a quality piece of software. So here I am posting about it so I remember it for the future.

During this heatwave I have turned off the Raspberry PI cluster so it isn’t running while being exposed to this ambient heat and humidity. I have a couple weeks more blog posts about Raspberry Pi’s so this shouldn’t affect the weekly blog.

Overview of the Raspberry Pi Cluster

Now I have the power supply and built the stacking system I can show off the clusters initial state.

Every Raspberry Pi in the cluster

Here are the 7 initial Pi’s that are to become part of the cluster. Each have been given a codename to designate its position in the cluster. The Raspberry Pi designed “M” will be the initial master Raspberry Pi as this is a Raspberry Pi 1 B+. Nodes 1 to 4 are all Raspberry Pi 1 revision 1.2 (512 MB version). The unlabelled one with the blue SD card is “chewpi” the original Raspberry Pi I have been using. This is again a Raspberry Pi revision 1.2 (512 MB). The final node, Node 5, is an original Raspberry Pi 1 (256 MB) which wont sit in the cluster stack but will be joined eventually.

Shots of casing assembly

Here you can see the master node sitting in its casing. I have decided to mount this one at the top for ease of accessing its USB ports.

Here you can see the modifications to the casing means that I am able to easily stack the older Raspberry Pi’s with the newer ones with the mounting holes. I described how to modify the case in an earlier post.

The open sides of the case should allow for good ventilation as when the Raspberry Pi’s are running they are expected to generate some heat.

Here the final cluster sits in all its glory. In this configuration all the needed ports (power, USB and Ethernet) are accessible out the side of the case. If I want to access some of the GPIO ports I may convert the cluster into several stacks of 2 or 3. However I wont be doing this initially as this suites current my purposes fine.

Raspberry Pi Read-only file system Fix Solved

If you are getting “Read-only file system” on your Raspberry Pi when mounting drives there is a simple fix.

chewett@bunker-master2:/mnt/wd500$ touch test.txt
touch: cannot touch ‘test.txt’: Read-only file system

I noticed this happening when I tried to mount and work on my external hard drive. This is formatted with the NTFS filesystem.

I did some research and it turns out that by default Raspbian Jessie (as of 13/06/2017) does not include the ability to write to NTFS drives. To add this ability you can run the below command

sudo apt-get install ntfs-3g

This installs the NTFS driver which will allow you to also write to NTFS drives.

This issue will occur for anything using the underlying NTFS driver. I found this issue when I was mounting a veracrypt volume on the Raspberry Pi.

Veracrypt was installed by following my guide to install Veracrypt on the Rasperry Pi. Now I have resolved this problem I will be able to access my external drives on the Raspberry Pi.

Light Intensity Sensor Module 5528 Photo Resistor Arduino review and code

This post is a review of the “Light Intensity Sensor Module 5528 Photo Resistor” and includes code and images to use the sensor.

There are a couple variants of this light sensor sold by different companies but all have similar components and designs. This model is sold by HiLetgo CN and is available on amazon (link below).

Comments about the Sensor

Top down view of the sensor

This sensor is built around a light dependant resistor. This is a component whose resistances changes depending on the light level.

Normally if you are using a light dependant resistor you need to measure the current resistance of the component. However this isn’t required as the circuitry takes care of this.

Side view of the sensor

The sensor has three pins marked as GND, VCC and SIG. GND is where you would connect your ground signal. VCC will be your “high voltage”, the data sheet recommends 5 volts. SIG is the current value of the sensor in volts. With 5 volts provided to its VCC connection the range of SIG will be between 0 and 5 volts. 5 volts will represent a high light intensity and 0 volts will represent a low light intensity.

The light readings obtained from this are only relative light levels. This means that if you read 3 volts at one time, and 4 volts later you know that the light intensity has gone up. However you cannot turn this into a specific light intensity (typically measured in lumens).

Testing the light sensor

To test the sensor I wired it up to an Arduino Uno as shown below in the schematic  and image.

Wiring the sensor up to an arduino

Once it has been wired up I wrote the below code to read the value of the sensor every 2 seconds and print it out on the serial port. This was logged by my computer and stored in a file.

#define ANALOG_IN_PIN 0
int sensorVal = 0;

void setup() {

void loop() {
  sensorVal = analogRead(ANALOG_IN_PIN);

Once I had stored the data I was able to process it into a graph for better review. On the graph below I plotted the sensor value in red. In addition to this I plotted the maximum sensor value (1023) and the minimum sensor value (0). The final line plotted is the base sensor light level. When testing the sensor it was placed in a room with LED lights at a constant brightness. This ensured that the light level would not change due to outside interference.

By reviewing the graph above you can see that the base light level remains stable during the experiment. The sensor quickly returned to the initial light level after changing the brightness it was exposed to. This also shows that the sensor is reliable at returning to the same values after changing light levels.

I was able to easily reach quite close to the maximum and minimum by using a strong light source and covering the sensor completely. In addition by changing the amount of light the sensor was exposed to I was able to reach a variety of different light levels.

When maintaining the same light level the sensor appears quite stable and there is a minimum amount of noise in the readings. I have observed that it is also very fast to return to normal light readings.

Overall Review – Would buy again

For the price of the sensor this is a great pick to measure relative light levels. The circuitry to provide a simple signal wire to read the light level  eases the implementation of the sensor. This also reduces the requirements compared to a standard light dependant resistor. The range of values the sensor can produce is definitely sufficient for general light level monitoring. Although it cannot measure a specific lumen value no sensors at this price range can so this is not a great loss.

Overall I would definitely recommend this sensor to use it in your project.

The product I purchased to test is available on Amazon.


Encryption using Veracrypt on the Raspberry Pi Cluster

One of the  objectives for the Raspberry Pi cluster is to manage a number of servers including syncing their contents and backing up databases. The data included may contain personal information so they are always backed up to an encrypted drive. This means I need to be able to access the encrypted content on the Raspberry Pi Cluster.

What is Veracrypt?

Veracrypt is a piece of software that allows on the fly encryption. This means that while you are writing to a veracrypt volume the file is immediately encrypted. In addition to this when reading files from a veracrypt volume they are decrypted as they are read.

To encrypt your data, Veracrypt allows encrypting full disk partitions or creating an encrypted file. Both of these act like a partition once opened and provide transparent encryption. The volumes can be protected by a number of methods including passwords and keyfiles.

However on the fly encryption adds additional slowdown when writing or reading data since it must be encrypted/decrypted first. For systems that support this at the hardware layer this slowdown can be very minor.

Veracrypt is based on the popular encryption software Truecrypt that was discontinued on the 28th of May, 2014. A number of improvements have been made to the software since being forked and is my chosen method of full disk encryption.

The Raspberry Pi’s do not appear to have hardware crypto support so it is likely to be slow encrypting files. This is something that I am going to need to be aware of.

Installing Veracrypt on a Raspberry Pi

Veracrypt includes a binary compiled for Raspbian which can be downloaded from their website.

To install the downloaded files you can run:

tar -xf veracrypt-1.19-raspbian-setup.tar.bz2
chmod u+x veracrypt-1.19-setup-console-armv7
sudo ./veracrypt-1.19-setup-console-armv7

The first line uncompressed the file. Once it has been extracted it needs to be made executable by running chmod. Since I only want to run the program on the command line I have made the command line program executable. The final line then runs the installer.

Pressing 1 during the installer will install veracrypt. This will prompt you to read the terms and conditions. Once they have been read q will quit out and then entering yes will accept the terms.

Once this has been done running veracrypt should give a prompt explaining its usage.

However if when running this command you get the below error:

error while loading shared libraries: libwx_baseu-3.0.so.0: cannot open shared object file: No such file or directory

You will need to install libwxbase 3.0 which can be done by running the below command:

sudo apt-get install libwxbase3.0-0

Once this has been done Veracrypt should be ready to use.

I wont be documenting its use in this blog post but once you have an encrypted volume or file you can mount and decrypt it using

veracrypt test_encrypted.veracrypt /mnt/test

Where test_encrypted.veracrypt is the file or volume (e.g. mounting a partition can be done using /dev/sda1) and /mnt/test is the location to mount the encrypted volume. Once it has been mounted you can access the files as normal files.

Now I am able to mount my encrypted drives I can work on setting up backups.

Stacking Raspberry Pi’s

The stackable Raspberry Pi case purchased allows stacking Raspberry Pi B+ and Raspberry Pi 2/3 but I was planning to modify this to stack older Pi’s.

Stacking the Raspberry Pi (256 MB)

The original Raspberry Pi does not have any mounting points. This makes it quite hard to stack using my chosen stacking solution. Therefore for the time being I have chosen not to stack this Raspberry Pi.

Stacking the Raspberry Pi (512 MB)

Mounting holes shown in red

Revision 1.2 of the Raspberry Pi increased the amount of memory to 512 MB and added mounting holes among other changes. These two holes (highlighted above) allow easy mounting of the Pi to a surface. However the product I purchased isn’t designed for these mounting holes.

Newly drilled mounting points shown in red

To mount them to my product I drilled new mounting holes in the acrylic. I used a hole mount guide produced by Raspberry Pi Spy. After printing out the guide I overlaid this on the case and drilled through the mounting guides.

Stacking the Raspberry PI B+, 2, and 3

Mounting holes shown in red

The later Raspberry Pi’s added two additional mounting holes and moved the original two. This made the mounting points more uniform. Since my case has been designed for these mounting holes I didn’t need to add any more.

Final 6 Cluster Stack

Here is an image of the final 6 cluster stack I will be using to start testing the cluster.

This 6 cluster tower is formed of one Raspberry Pi 1 B+ and five Raspberry Pi 1 (512MB version).

By stacking them this allows easier cable management for the power and ethernet cables. It also allows me to reduce their ground footprint to be able to more easily store them.

Next post I will share some images of the cluster with all its cables attached.

RaspberryPiVcgencmd A python library to access Raspberry Pi vcgencmd command

To access some of the lower level aspects of the Raspberry Pi’s config you can use the built in command vcgencmd. This is a useful on the command line but to easily access it in a program you need to parse the output.

I am planning to use this command to store data like the temperature of the Raspberry Pi in python. Therefore to easily access the data I decided to make a small python module to do this.

RaspberryPiVcgencmd Python Module

This python module is a wrapper around the vcgencmd command to allow easy access to some of the internal data of the Raspberry Pi.

To include this module in your git based project you can run

git submodule add https://github.com/chewett/RaspberryPiVcgencmd
git commit

Now I have run the above command the library is installed as a git submodule. This means I can now use it in my python script.

So that I can use the library in my current script I need to import the submodule. To import this module I can add the below import statement to my script.

from RaspberryPiVcgencmd.RaspberryPiVcgencmd import RaspberryPiVcgencmd

This will make the RaspberryPiVcgencmd class available to be used in the current python file. Once I have imported it I can use the library to get the firmware version adding the below to the script.

vcgencmd = RaspberryPiVcgencmd()
print vcgencmd.get_version()

Using the vcgencmd object you can now call any of the functions available in the library.

Full details of what vcgencmd can do is available on elinux.

Current exposed functions

The majority of the useful output from vcgencmd is exposed in the class with the below functions

  • get_cpu_temp – Gets the system temperature of the soc in Celsius or Fahrenheit
  • get_ram_split – Gets the memory split between the gpu and cpu
  • measure_volts – Measures the voltage of various internal components
  • measure_clock – Mesures the clock frequency of various internal components
  • is_codec_available – Returns whether the codec specificed video/audio codec is available on the Raspberry Pi
  • get_version – Gets the version of the firmware installed on the Raspberry Pi
  • set_display_power – Allows turning off/on the video output of the Raspberry Pi

The RaspberryPiVcgencmd module is available on github and is licensed under the MIT licence. If you have any comments, suggestions or improvements you can comment below or raise a github issue.