Inky pHAT causes a shutdown

Hi,

Whenever I run any of the python code examples my Pi shuts down, ie as if I had executed a sudo poweroff:

simon@basic-pi:~/Pimoroni/inkyphat/examples$ ls
cal-ics.py cal.py clean.py hello.py InkyPhat-212x104-bw.png InkyPhat-212x104.png list-ics.py logo.py qr.py resources test.py weather.py
simon@basic-pi:~/Pimoroni/inkyphat/examples$ python hello.py “simon” red
Inky pHAT: Hello… my name is:

Use Inky pHAT as a personalised name badge!

Broadcast message from root@basic-pi (somewhere) (Thu Jan 10 20:08:36 2019):

BCM 17 held low, system shutdown in 0 minutes

Connection to 192.168.1.200 closed by remote host.
Connection to 192.168.1.200 closed.
simon@chromebook-asus:~$

It does this on models:
Pi 3b+
Zero WH

The only difference being on the 3b+ the image gets written to the display before shutdown, whereas with the Zero it doesn’t process the code fast enough (I think).

Any ideas?

it never used to behave like this.

Cheers,

Simon.

You didn’t happen to have an on off shim connected to that pi? It uses GPIO 17 as the power button.

Hi,

Thanks for the reply.

No, nothing connected.

I agree, it does feel like a short, but it’s the same effect in:

  • The Pi in and out of a case
  • Different SD cards
  • Differing Pi models

The thing is, it used to work OK, being refreshed every 15 minutes by a cron job as a weather station.

Bit puzzled as to what has changed.

You should probably post the code your running. in code tags.

The BCM 17 held low, system shutdown in 0 minutes line is what caught my attention, and made me think maybe another pHat of Hat had been attached at some point. Just a wild guess to be honest.

Hi,

It’s a completely fresh install of the Pimoroni inky-phat library from git

New card, new download, fresh burn.

#!/usr/bin/env python

import sys

from PIL import ImageFont

import inkyphat

print("""Inky pHAT: Hello... my name is:

Use Inky pHAT as a personalised name badge!

""")

#inkyphat.set_rotation(180)

USAGE = """Usage: {} "<your name>" <colour>
       Valid colours for v2 are: red, yellow or black
       Inky pHAT v1 is only available in red.
""".format(sys.argv[0])

if len(sys.argv) < 3:
    print(USAGE)
    sys.exit(1)

colour = sys.argv[2]

try:
    inkyphat.set_colour(colour)
except ValueError:
    print('Invalid colour "{}" for V{}\n'.format(sys.argv[2], inkyphat.get_version()))
    if inkyphat.get_version() == 2:
        print(USAGE)
        sys.exit(1)
    print('Defaulting to "red"')

# Show the backdrop image

inkyphat.set_border(inkyphat.RED)
inkyphat.set_image("resources/hello-badge.png")

# Partial update if using Inky pHAT display v1

if inkyphat.get_version() == 1:
    inkyphat.show()

# Add the text

font = ImageFont.truetype(inkyphat.fonts.AmaticSCBold, 38)

name = sys.argv[1]

w, h = font.getsize(name)

# Center the text and align it with the name strip

x = (inkyphat.WIDTH / 2) - (w / 2)
y = 71 - (h / 2)

inkyphat.text((x, y), name, inkyphat.BLACK, font)

# Partial update if using Inky pHAT display v1

if inkyphat.get_version() == 1:
    inkyphat.set_partial_mode(56, 96, 0, inkyphat.WIDTH)

inkyphat.show()

The only code differences that I can see are that there was an update a few months ago by @gadgetoid but I don’t think that is causing this issue.

Maybe I can use an older library ?

What version inky pHat do you have, and what library did you use?
A search found 3 different GitHub libraries.

Had a bit of spare time to look at this.

I was using the old inky-phat library, as I was following my previous installation documentation.

curl https://get.pimoroni.com/inkyphat | bash

Once I had deleted this (no point in keeping it) and installed the ‘inky’ library:

curl https://get.pimoroni.com/inky | bash

There were a few installation errors:

Apt failed to install python-fonts!
Falling back on pypi…

But everything seems to work.

No idea why the old examples didn’t work, but all good now.

This thread can be closed.

Cheers,

Simon.

A fresh start with a new clean Raspbian install would likely install everything with no errors. I’m glad its now working though. Enjoy. :)

That’s the head scratcher.

It was a brand new SD card with a fresh installation and fully updated.

Ah well, all good now.

A new install with the new library maybe? As you say though, working now. ;)