OK, finally decided to have a play with a Raspberry Pi. Installed the full version of Raspbian as I wanted a desktop to work with.
One of the first things I noticed was a little thermometer sign came up in the right hand corner after a short while. A quick Google revealed this meant that the temperature had risen to a level where it may start to affect performance. Decided to buy a case with fan and some heatsinks (about £11 from Amazon). The question was how to monitor the temperature. Knowing nothing about Linux at all led to a lot of googling and I've managed to cobble together something that works.For anyone that knows how to code - be kind I don't, but this works and is literally just a few lines that are easy enough to follow. All info is pulled straight from other peoples work, please don't ask me to explain any of it!
Create a Python script to monitor the temperature of the Raspberry Pi
In my previous post I showed the code I used to create a temperature monitor for my Raspberry Pi. All well and good but a bit messy when running from a terminal unless you alter the row and column it prints at or clear the screen first. What I wanted to do then was create a desktop shortcut. The following info applies to anything really that you need a shortcut to.
First thing to note is that when you create a shortcut and double click it that a popup appears saying the file seems to be an executable and asking what you want to do with it. Very annoying and took a lot of Googling to find, so lets straighten that out as a starting point.
There are so many examples of GPIO control available I just wanted to do a very simple example. I wanted to use a simple relay to trigger a device either manually or by scheduling using cron.
One thing I Iearned along the way was that not all the GPIO pins behave the same when rebooted. For example GPIO2 is set to high on boot, which meant that if my Raspberry Pi rebooted the relay I had set up would be triggered until I ran the script to switch it on/off.
GPIO18 on the other hand is set to low by default, so this is what I have used for this example.
Just a quick note on the Relay I used for my project.
Initially I thought I'd be clever and buy components to build my own relay - big mistake as its so much cheaper to buy ready made unless you intend setting up a factory! I bought a pack of 3 relays for under £7 from Amazon, so you're looking at just over £2 a relay that will switch up to 2A and has power and relay state LEDs built in.
There are 3 terminals to connect so you will need jumper wires (female to male, or just female as I stripped the ends that screw onto the relay).
Last thing I wanted to do was to set a automatic reboot for the Raspberry Pi to keep things refreshed and also to trigger my relay once a week to reset the device I had connected. The relay was just to cycle the power to the third party device, so could be set for any time/date really, I just chose to do it weekly. Adjust times to suit yourself.
There is a lot of info on how to set up cron, this is the method I chose.
One issue I found straight away is that, with the default settings, if your Pi boots without a monitor attached or switched on it cannot detect the appropriate settings and on a standard HDMI connection all you get is a blank screen.
There are loads of options that can be set, but I feel if you're going to use HDMI you may as well set the output to 1080p 60Hz and be sure it will work on any standard TV or monitor.
To do this I edited the config.txt file as follows:
The server initially runs on 0.0.0.0:8000 which is great if you are local to the box or have teamviewer installed. I wanted the server to run at boot and use the IP address of the Pi (eth0 or WLAN) Problem is that if you use the IP address of the Pi you need to set the Pi to wait for network on boot (just use sudo raspi-config and select boot options if you want to do that) or it just doesn't work. Also limits you to one interface that you can access it from. So after a bit of work this is what I came up with (googled, copied and pasted - I'm not that clever!)