ZymKey problem when reading MCP3008

Using the latest Raspberry Pi OS 32bit, fully updated on a Pi4 2GB.

Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l GNU/Linux

The ZymKey appears to work fine with the slow blue led blinking. Within a few seconds of starting code that reads MCP3008 over SPI the ZymKey flashes rapidly then gives 8 flashes which I believe is i2c comms problem.

The ZymKey port is configured to GPIO24.

from gpiozero import MCP3008
import time

voltages = []
while True:
    for voltage in voltages:
        print(str(voltage.value)+' ',end='')

@rpiMike - Yes the 8 flashes is a comm problem on i2c.

The first question we always have to ask is do you have a good power supply?

Next, can you try changing the PI CPU scaling governor from ondemand to performance to see if that makes a difference? Details here:


And one more question on your setup: How is your MCP3008 wired up? Is it on a standard HAT, or are you wiring up yourself on a breadboard?


I’m using an official Pi 2.5 Amp power supply into a PiJuice UPS mounted onto the Pi4. I’m not seeing any low power warnings.

I will try the governor change.

The MCP3008 is mounted onto a custom made PCB.

The Pi4 recommended power is at least 3.0A. If you have a better Power Supply, you may want to also give that a try.


Tested with an official Pi 3.0Amp power supply direct into Pi4, same issue.

First command on your governor change fails:

pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
bash: /sys/devices/system/cpu/cpufreq/policy0/scaling_governor: Permission denied
pi@raspberrypi:~ $ sudo echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
bash: /sys/devices/system/cpu/cpufreq/policy0/scaling_governor: Permission denied
pi@raspberrypi:~ $

It requires “sudo su”. Thanks for pointing that out. We added that note to our instructions.

I’ve still got the same issue with this.

Created a service called ‘myservice’ as suggested. Using official 3.0A power supply.

pi@raspberrypi:~ $ sudo systemctl status myservice
● myservice.service - Set scaling governor to performance
   Loaded: loaded (/etc/systemd/system/myservice.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Fri 2020-12-04 12:25:09 GMT; 35s ago
  Process: 809 ExecStart=/bin/sh -c echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor (code=exited, status=
 Main PID: 809 (code=exited, status=0/SUCCESS)

Dec 04 12:25:09 raspberrypi systemd[1]: Starting Set scaling governor to performance...
Dec 04 12:25:09 raspberrypi systemd[1]: myservice.service: Succeeded.
Dec 04 12:25:09 raspberrypi systemd[1]: Started Set scaling governor to performance.
pi@raspberrypi:~ $ more /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
pi@raspberrypi:~ $ 

Run my MCP3008 code from first post. Working ok so far.

Then try querying ZymKey:

import zymkey,time

zymkey.client.set_perimeter_event_actions(1, action_notify=True, action_self_destruct=False)

while True:
        perim_status_str = ""
        idx = 0
        plst = zymkey.client.get_perimeter_detect_info()
        for p in plst:
            if p:
                perim_status_str += " perim%d timestamp = %d" % (plst.index(p), p)
        print("Perimeter event detected!" + perim_status_str)
    except zymkey.exceptions.ZymkeyTimeoutError:
        print("Nothing going on")
    except Exception as e:

Then get 8 flashes followed by just rapid flashes.

@rpiMike - I’d like to find out a little more about your project. I’ll send you a DM from support outside the Community.


@Bob_of_Zymbit don’t seem to have received DM yet?