Once upon a time...

Once upon a time...
Christmas 2016

Friday 24 April 2020

Adding a power button & LED to my Raspberry PI

  • There are many posts and articles out there about this topic, this post is record the approach I took and which of the posts I followed.

As previously mentioned, I bought a couple of Rev 1 Raspberry PI Model B's when they first came out and I touched on the fact that I was using one to run my Mendel 90 using OctoPrint in this post.

What I haven't blogged about it is the fact that I since built a 2nd Mendel 90 and sent the first one to my brother in South Africa along with the RasPi.

Well, mine has stood up to the test of time and the good old Rev 1 RasPi is still running my Mendel 90 with OctoPrint (leveraging OctoPi).

I decided I wanted to be able to safely power down as I run the RasPi in headless mode, so Googled about adding a power button, this led me to this article on howchoo, which links to another article about adding a power LED.

Anyway, I experimented using the RasPi 3 that I bought for my daughter's (failed) media centre project which worked great, so I created a switch and LED assembly pictured below (the astute/curious amongst you will note that the RasPi in the picture is actually yet another one that I have, a Rev 2).

When I then tried this on my Rev 1 board I discovered it didn't work, so some Googling later and I found an excellent resource in the form of this page by Matthijs Kooijman. It turns out that he devised a devicetree overlay (yes, I didn't know about this stuff before myself) which has been merged into the official Raspbian kernel repository from 2017.08.16 onwards. This means that you can achieve a powerbutton (same pins as the howchoo article) without the Python daemon, simply a boot config change, so I implemented this. (As per his page I had to tweak the setup for the Rev 1 as the GPIO on pin 5 is GPIO1 as opposed to it being GPIO2 on later RasPi's).

 So in summary, I used:

  • Matthijs Kooijman's instructions to add the powerbutton on pins 5 & 6
    • Coded added to /boot/config.txt
      • For Rev 1 RasPi: dtoverlay=gpio-shutdown,gpio_pin=1
      • For later RasPi's: dtoverlay=gpio-shutdown,gpio_pin=3
  • howchoo's instructions to add the LED on pins 6 & 8
    • Coded added (if LED doesn't light up) to /boot/config.txt: enable_uart=1

Creating a Raspberry Pi Media Centre

NOTE: I'm catching up on Blogger and decided to post these draft posts that I've had partially written. I'm not completing them at this point and probably won't revisit them, but as a big part of the reason for blogging is to remind myself of what I was thinking/doing, they're still valid in this sense. This draft was dated 04/01/2017.

This article is all about the approach I took to attempt to create a Raspberry Pi based Media Centre for my daughter.  It assumes some knowledge of Raspberry Pi's  (What they are, how to find information about them, etc) and is more a record for my own purposes than a step-by-step how-to guide.

There are numerous resources out there, even pre-installed SD cards to get you going.  One of the most common current bits of Media Centre software is Kodi, so I will be going with that.

What I realised though was that I would need a lot more storage and would prefer something self-contained.  I stumbled upon the WD PiDrive. This is a harddrive which is designed to work with the Pi.

What I have ended up with is the following (purchased from The Pi Hut):

  • Raspberry Pi 3 Media Centre Kit - 16GB
    • Latest Raspberry Pi 3 Model B (64bit Quad Core, 1GB RAM)
    • 16GB Sandisk Ultra Class 10 MicroSD (pre-imaged with Kodi)
    • Official Raspberry Pi 5.1V 2.5A International Power Supply (for UK, EU, USA & AUS)
    • Black Raspberry Pi 3 Case
    • 2M HDMI cable
    • 2M Ethernet Cable
  •  375GB Western Digital PiDrive - Foundation Edition
    • Native USB 7mm HDD
    • microSD™ card (preloaded)
    • WD PiDrive Cable
    • 2-year Limited Warranty
First, I backed up the SD cards using Win32DiskImager, just in case.

Next up I did a bit of reading, and wasn't sure if I would be using the 16GB Kodi SD card as I wanted things to run on the HDD.  Reading the PiDrive FAQ, I could see that the idea is that you normally install multiple OS's allowing you to keep messing around with different configs for different purposes.  That's not what I wanted.  What I did note however is the instructions for expanding a Raspian partition to use the entire drive. (FAQ #5)

Feeling I was ready to start, I dug out a keyboard, screen, etc to allow me to start setting up the basic system.

Step 1:
Installed Raspberry Pi into case, inserted PiDrive SD Card, connected up keyboard, mouse, screen and HDD as per the PiDrive instructions, and then finally turned on the power.

Step 2:
The Pi booted into the PiDrive NOOBS options, I realised that I couldn't install OSMC from there, so I figured I would try the 16GB pre-installed Kodi card.  FAIL!  It wouldn't boot, so, lots more reading and then I downloaded the latest OSMC image from Osmc.tv/download/ and booted from that.

Step 3:
Connected up the WiFi and went through the various settings to change these to things that made sense.

Trying out the Filawinder

NOTE: I'm catching up on Blogger and decided to post these draft posts that I've had partially written. I'm not completing them at this point and probably won't revisit them, but as a big part of the reason for blogging is to remind myself of what I was thinking/doing, they're still valid in this sense. This draft was dated 28/12/2015.

In a previous post (and the one before) I mentioned the plan to get a Filastruder.  Well, I've had that for a while, but not really used it for a multitude of reasons.  One being the space it needs for the filament to self spool on the ground.

I then ordered a Filawinder in the hope this would allow me the consign the entire system to fixed working space.

The Filawinder is assembled, but I am trying to play nice which is the topic of this article.  As much a place for me to remember what I did as anything.

Key points:

Initial results are the same as the ones experienced in this post (http://www.soliforum.com/topic/5088/filawinder-documentation/), so I am trying Ian's suggest mod in the responding post.

Raspberry Pi initalisation

NOTE: I'm catching up on Blogger and decided to post these draft posts that I've had partially written. I'm not completing them at this point and probably won't revisit them, but as a big part of the reason for blogging is to remind myself of what I was thinking/doing, they're still valid in this sense. This draft was dated 28/11/2015.

It's been a long time since I blogged.  Family life will do that to you.

Things on all fronts (Camper, RepRap, etc) have moved on, I'll catch up with the details as these and when I get a chance, however, for now, I'm starting something new.  The aim of the blog posts are as much to remind myself what I did as to be helpful to others in the future, so...

I bought some Raspberry Pi's when they first came out, and have been using one to run my Mendel 90 using OctoPrint which is great (more on that later).

However, some of you will recall that I also have an Armdoid robot arm which I intended to get working.  Well recently developments in the household unearthed the arm and I did some Googling which led to the discovery of Richard Morris's great Armdroid Blog.  Reading through this re-inspired me to get "Ron" the robot working, which I will do as a joint project with my son (now 13), who claims to want to be a software developer (like dad), but seems more intent on consumption than creation right now.

So, I will be setting up the Raspberry Pi and then using this to ultimately control Ron through an Arduino.  This may all sound like overkill, but all will be revealed in good time.  Besides it means learning about all this great kit!!

Initialising the Raspberry Pi

Hardware used:

  • Raspberry Pi Model B Rev 1 (As ordered in the first week they were announced)
    • Fuses removed ages ago due to issues when using with OctoPrint
    • I also happen to have at least one Raspberry Pi 2 Model B's at my disposal, but we'll start with the Rev 1 and re-assign it back to printer duties later.
  • Raspberry Pi Camera Rev 1.3
  • Edimax Wifi Dongle
  • Temporary:
    • 7 inch composite 12v screen (lying around from the Camper project)
    • Keyboard
    • Mouse

I followed these steps to get my RaspPi working:

  • Downloaded the Raspbian Jessie image from https://www.raspberrypi.org/ and wrote to an SD card using Win32DiskImager
  • Initial config
    • Booted up the RaspPi
    • Switched to command line
    • Ran "sudo raspi-config" to enter the config utility and ran through these...
      • Enlarged file system
      • Changed password
      • Boot Options - Console (I will run the GUI as and when I want it)
      • Enabled Camera
      • Rebooted
    • Connected to Wifi
      • Used GUI (easier)
      • Connected to RaspPi using SSH (I use PuTTY on my PC) as this is easier than constantly switching devices.  (Checked the IP by looking at my router for connected devices)
      • Update settings to static IP (I run my home network with a reserved range for the devices I need to access by IP).  For detailed instructions follow this tutorial.  Simplified steps follow below (as I know my network settings):
        • sudo nano /etc/network/interfaces
        • Find the line with wlan0 and change the manual or auto to static
        • Add these lines (replacing values where neccessary):
          • address 192.168.x.y
          • netmask
          • network 192.168.x.y
          • broadcast 192.168.x.y
          • gateway 192.168.x.y
        • Ctrl-X, Y to Exit and Save  (This will probably cause a reboot and you will need to change your PuTTY config if you SSH'd in).
      • At this point I backed up the image (using Win32DiskImager) to make it easier to start new configs if I mess things up.  (I learnt the hard way last night...)
      • Ensure all patches are up to date
        • sudo apt-get update
        • sudo apt-get upgrade
    • My Pi seems to go to "sleep" after some time and I can't connect to it without rebooting, so trying this:
      • Disable power management on WiFI (Pi seems to go to "sleep" after some time
        • Link to source of this information.
        • Create new config file: sudo nano /etc/modprobe.d/8192cu.conf
          • # Disable power management
          • options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
        • Save and reboot.
        • Check settings using: cat /sys/module/8192cu/parameters/rtw_power_mgnt
      • If it doesn't work, try this:  Fix for Ethernet Connection Drop on Raspberry Pi
  • Setting up the camera based on www.raspberrypi.org

Following the Wiki calibration page

NOTE: I'm catching up on Blogger and decided to post these draft posts that I've had partially written. I'm not completing them at this point and probably won't revisit them, but as a big part of the reason for blogging is to remind myself of what I was thinking/doing, they're still valid in this sense. This draft was dated April 2012. 

As the title says, I am following the wiki's calibration page.

Bed levelling
I mentioned this in my last post.  The bed is now perfectly level thanks to the conversion to a 3-bolt structure instead of 4.  I did however discover on printing the calibration object (bedleveling.stl) that the one corner was sitting high.  Closer inspection revealed that I must have knocked the Dibond bed plate in the past as the corresponding corner has a small dent.  I managed to salvage the situation by adding some washers to the spacers I used to mount the PCB heated bed.  In other words the PCB is now at an angle to the Dibond, but square to the x-axis (which is what counts).

While we're on this topic, the bed specific page on the wiki suggests the use of thumbscrews for the bed.  I like the idea, but will be designing my own as my bed bolts (and z-axis end stop adjuster) use M4 bolts.  The thread pitch on these is 0.7mm.  i.e. each full revolution of the bolt results in an adjustment of 0.7mm.  So, instead of having a thumbscrew with 6 "bumps", why not make one with 7.  That way it is easy to gauge by eye if you are adjusting by 0.1mm (or even 0.05mm if you move it halfway).  Think about it!! Pure genius!!

Ooh Boy!! just when you think everything is going swimmingly!!!  Have a look at this!!

Layer Height

Sunday 9 June 2013

What's Now... Mendel 90 in progress

First, a quick recap on my last post, projects planned:

  • Filament extruder: I backed the filastruder Kickstarter so am just waiting for my kit to arrive so I can start experimenting with making my own filament.
  • Plastic shredder/grinder: No progress - Marcus Thymark is now focussed on his extruder, and his shredder although done is appears to be temporarily shelved.
  • Mendel90:  I've started work on this.  A colleague from work also wants one, so I have started collecting parts and printing.
With trying to print the parts of the Mendel90's, I have been following Nophead's recommended settings, but find the print quality isn't so great.  Some Googling has suggested that moving to Marlin from Sprinter would be a good idea, so today I am tackling this:

  1. Download the latest Marlin from GitHub
  2. Update the configuration.h file to suit my printer.  See these links for further info:
    1. 3d Printing update: Sprinter versus Marlin firmware & more
    2. Forum Topic
  3. Verify/Compile & Upload as per normal
    1. I found this didn't work as I used the new Hardware (Sanguinololu) definitions included with Marlin.  When I reverted to the Sprinter Hardware files it worked.
  4. PID Tuning
    1. One of the things I wanted to switch on in Marlin is PID control of the HotEnd.  I found this blog article by Lincomatic well written and helpful.
  5. Test and re-calibrate.
    1. I created my own stepped piece for use with Triffid Hunter's Calibration Guide as I found the 5x5 was a bit difficult to see while the printer is moving.
So, I now have Marlin running and a re-calibrated printer, so we will see if this helps with the Mendel90 Plastics printing...

Monday 18 March 2013

What's next...

Having been absent from the RepRap scene for a while (well work and new baby seem to take a lot of time), I have managed to get my printer dusted off and running again.

I've done a lot of reading the last couple of weeks, together with some tinkering and decided on some future projects which I am watching.  These are (no order of importance or action intended):

  • Filament extruder: I always intended to recycle plastic, so am watching the "filastruder" developments with interest.  This has a number of similarities to the "Lyman Extruder" which won the desktop factory competition.  I suspect I may go for a mix of the two in the end.  Depends what the filastruder guys come up with by the time I am ready to progress.
  • Plastic shredder/grinder: Marcus Thymark is creating the "Filamaker", which will shred plastic and then extrude filament.  His initial focus is on the shredder which I think is great, but currently out of my budget, so ill keep an eye on developments.  He doesn't seem to have done much work on the extruder element yet.
  • Mendel90:  The most important thing any RepRap owner seems to need is: Another RepRap.  As mentioned in my last post, I will be making one of nophead's Mendel90s.  I do however want to make some changes (and need to keep costs down by recycling stuff I have), so will not be using a kit.  The main change is that I want a 300x300 build area and am thinking of dual extruders (with all the issues those bring).
Wish me luck....