GPIO pins working on Pi 3

I downloaded the new image of Picroft from the Mycroft website, and have been able to use it smoothly. However, recently I have been attempting to run GPIO pins in my custom skill and have had no success. For testing purposes, I decided to try downloading and running the Picroft_example_skill_gpio skill from GitHub - MycroftAI/picroft_example_skill_gpio: Mycroft AI demonstration Skill for using GPIO pins with the RPi 3 which I found from some documentation here: Documentation - Mycroft AI

I installed the skill by running the command msm install

However, when I tried running the skill there was no output coming from the GPIO27 pin (or pin 13 if you use the GPIO.BOARD layout). Specifically, I have been using the ‘Turn LED ON’ command, which is supposed to send a high signal out of the GPIO27 pin, however I am only getting a low signal coming out of that pin no matter what command I use. I have a Raspberry Pi 3, and noticed there was an unanswered post about this same issue in the Mycroft forums (Mycroft and GPIO Raspberry pi 3).

Has anyone been able to use the GPIO pins with their Picroft? Or gotten this example skill working?

I have been able to figure out that I am unable to locate a module named RPi.GPIO

I have made a python file called that contains the lines:

import RPi.GPIO as GPIO
print a

When I attempt running this script that should simply tell me what GPIO version I have, I get the following as a result:

Traceback (most recent call last):
File "", line 1, in <module>
import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO'

I tried adding a PYTHONPATH to my ‘env’, and made this path the same as my original PATH…this did not work

Any ideas?


I was able to install pip, and use pip to install python-rpi.gpio, and now my simple version script is working. However, the example skill I downloaded does not recognize the intent anymore. For example, when I say “Turn LED ON” Mycroft responds with “Sorry I didn’t catch that, please rephrase your request”. It seems like installing the ‘rpi.gpio’ module or pip itself has caused this mycroft skill to not recognize its intent, but that does not seem like a likely cause to me.

Any ideas are appriciated

Hi @dleweyiv, thanks for posting this - and thanks for having a go hacking around the GPIO pins! I’m going to tag my colleagues @forslund and @steve.penrod, who are more knowledgeable about RPi and pip and python dependencies.

Kind regards,


following in your steps installing the GPIO module I also ran into trouble. Checking the /var/mycroft-skills.log I found

  File "/usr/local/lib/python2.7/site-packages/mycroft_core-0.9.7-py2.7.egg/mycroft/skills/", line 126, in load_skill
    skill_descriptor["name"] + MainModule, *skill_descriptor["info"])
  File "/opt/mycroft/skills/picroft_example_skill_gpio/", line 41, in <module>
    import GPIO
  File "/opt/mycroft/skills/picroft_example_skill_gpio/", line 57, in <module>
RuntimeError: No access to /dev/mem.  Try running as root!

This was fixed by adding the mycroft user to the gpio group:

sudo useradd mycroft gpio

and then restarting the skills service

/etc/init.d/mycroft-skills stop
/etc/init.d/mycroft-skills start

(This was done using the GPIO example skill on the latest picroft image)

Hope this helps!


1 Like

Hello again @forslund ,

Thank you for your original reply, that solved my issue with that example skill. However, I seem to be running into another. I have a custom skill made (located here: The goal of this custom skill is to be able to answer all questions pertaining to our university that a tour guide would be willing to answer. I thought that once I got the example skill working, I could easily implement it in my custom skill.

The issue I am running into is when I change the header of my file to include the import GPIO then nothing inside the skill works anymore. For example, with import GPIO being commented out I could say “Hey Mycroft, what is the retention rate here?” and it would respond accordingly. However, when I try to add the import GPIO line at the top to attempt to import the GPIO to my init file, everything stops working (aka when I ask about the retention rate, it asks me to rephrase my request.

To be clear, I am trying to set certain GPIO pins in the handlers of some of the intents, but I cannot seem to import the GPIO. If you have any insights again, I would greatly appreciate it

The thing here I think is that the file is in the local directory (which is not in the path). In the example skill, the skill directory is added to the path before import GPIO

See for how it’s done in the example skill.

basically what you need would be

import sys
from os.path import abspath, dirname
import GPIO

Let me know if this works, if not I’ll continue to troubleshoot.



You are the best. Thank you for all your help, I cannot promise I won’t be reaching out again.

Thanks again!

Glad to be of help, feel free to reach out if you hit more trouble. :slight_smile:

1 Like


Conceptual question for you: When running a self.speak_dialog command, there always is a delay before the speech starts. Are there already flags that exist that mark when the actual speech starts and stops? If not, do you know of any way to retrieve these timings?

It’s a slight delay while the audio is generated and then speech starts but there is no way to get the times reliably right now.

There is however a function called wait_while_speaking that can be imported from which will wait until speech is complete. Not sure if it’s something like that you’re interested in?

Hello again Åke,

I am working more on my custom skill and cannot seem to figure out some of the strange issues I am having.

When running my custom skill, inside a intent handler I set GPIO pins(sometimes I set them multiple times). However, the states of the GPIO pins do not always stay constant when I am reading them in using another pi and its GPIO pins. When I test this by hooking the outputs of my first pi’s GPIO pins to LEDs on a breadboard, the LEDs never flicker, causing me to be uncertain whether the output signals are actually fluctuating. Do you believe (I know you probably cannot know for sure) the output states of the GPIO are fluctuating when I have not changed them? If so, ifs there any way to stop this fluctuation without implementing hardware such as pull-down resistors?

Any insights will be appreciated immensely

I have very little experience of the raspberry Pi GPIO so I’m just guessing (and googling) here.

I would probably recommend having a pull up or pull down resistor between the devices. There seem to be a GPIO.setup function that can set the internal pull up/down of the Pi.

To really see what’s going on the best would be to use an oscilloscope and monitor the signal.

Sorry for not being more helpful.

I have done as you told but it is also not working for me. I am not getting Led to turn on. It shows and speaks that led is on but still it’s not on.

Hi Raj,

Have you got the code you are working on in a public repo somewhere like Github? If people can have a look at what you’re trying to do, they might be able to give some suggestions.

I am Just Using Picroft gpio example. Nothing More. It got SOlved but got new Issues like It automatic takes wakeup word Even If I am not Saying It and starts recording. when I adjusted the Threshold to “1e-20” it took time to load new wake up word then started again Looping but with few minutes gap and it than doesn’t take voice commands

hi , I followed ( ) tutorial but I stopped in " make docs " step I don’t know how to figure this out ot how to write this command can anybody help me please?
thank you