Mycroft and GPIO Raspberry pi 3


#1

Hello,

Is anyone have managed to make picroft interact with raspberry pi 3 GPIO ? i have tried the skill here : (https://github.com/MycroftAI/picroft_example_skill_gpio). I have successfuly installed it in opt/mycroft/skills. But i doesnt seems like picroft can reconize it as a skill.

Is anyone has succeed it? or the skill is just not ready yet.

Thanks


GPIO pins working on Pi 3
Using Buttons to control a Skill
#2

I’ve actually installed GPIO skill and it is working as expected.

The common issue is to add mycroft user to gpio group with command

sudo useradd mycroft gpio

and install

python-rpi.gpio
python3-rpi.gpio


#3

There is a similar issue if you wish to use a PiCamera:

Picamera Use Issues
The python test script to access the picamera worked well from the start. When I integrated the picamera functionality into the skill’s init.py file, at first it didn’t work,then after some tweaking it did work, but only once!

The file /var/log/mycroft-speech-client.log and /var/log/mycroft-skill.log are very useful files to look at if your skill is not working. After some looking, I found an error dealing with a “vchiq instance”.

Having learned my lesson from past experience, I did a google search, and found that in order the access the camera, the user executing the Python program or Mycroft skill in this case needed to have a file permission to do this. In Linux most everything is a file, even a device. To access the picamera, a user needs access to a file called /dev/vchiq. So the user executing the python test script had access, but the user, called pi, executing the init.py did not. Hence the failure to take the picture at all. Following the directions from Raspberry Pi – failed to open vchiq instance [Solved] demonstrates how to change the user permissions for this file to allow access to the device. I’ve placed a pdf of this post in my github repository for this project in case the link goes stale.

You can see the full write up here(which will also provide the link to github mentioned above):


#4

awesome work, @Joy_Tribbiani


#5

Thanks @Joy_Tribbiani for that info, I’ve added it to our Picroft documentation:


#6

Hi Kathy,

I’ve just realized about the Picroft documentation that I made a mistake.The command sudo adduser mycroft gpio is incorrect. The user mycroft is already created so when you run that command an error occur.
The right command is
sudo usermod -g gpio mycroft

Sorry about that
Ciao
Srg


#7

No worries @Joy_Tribbiani I’ve updated the documentation to reflect this.


#8

Hay, i’ve some problem with my GPIO skills
Im trying to add user and run sudo make install.pi
but i got this error

scp: /home/pi/skills/picroft_skill_gpio4s/4relay_bb.png: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/GPIO.py: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/GPIO.pyc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/GPIO_Board.jpg: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/README.md: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/SainSmart-8-Channel-DC-5V-Relay-011.jpg: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/init.py: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/init.pyc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/kitchenblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/on.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/livingblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/livingroom.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/bathroomblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/lamp.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/kitchen.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/name.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/bedroom.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/fanblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/fan.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/modules.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/livingroomblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/check.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/ipparamrequired.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/living.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/lampblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/led.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/switchblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/switch.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/ledblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/path.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/bathroom.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/off.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/dialog/en-us/bedroomblink.dialog: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/source/index.rst: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/source/code.rst: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/source/conf.py: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/source/tutorial.rst: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/Makefile: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/docs/make.bat: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/makefile: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/requirements.txt: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/settings.json: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/test/intent/open.intent.json: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/test/intent/close.intent.json: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/vocab/en-us/ioobject.voc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/vocab/en-us/ioparam.voc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/vocab/en-us/systemobject.voc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/vocab/en-us/question.voc: Permission denied
scp: /home/pi/skills/picroft_skill_gpio4s/vocab/en-us/command.voc: Permission denied
makefile:15: recipe for target ‘install.pi’ failed
make: *** [install.pi] Error 1


#9

Hi there,

try with
msm install https://github.com/smolino/picroft_skill_gpio4s.git

no other steps are required

let me know if that works


#10

I’ve this massage(An error occurred while pocessing a request in GPIO_Control Skill)
and if try to run test.pi
{‘GPIO2’: ‘Off’, ‘GPIO3’: ‘Off’, ‘GPIO1’: ‘Off’, ‘GPIO4’: ‘Off’}
{‘GPIO2’: ‘Off’, ‘GPIO3’: ‘Off’, ‘GPIO1’: ‘Off’, ‘GPIO4’: ‘On’}
{‘GPIO2’: ‘Off’, ‘GPIO3’: ‘On’, ‘GPIO1’: ‘Off’, ‘GPIO4’: ‘On’}
{‘GPIO2’: ‘On’, ‘GPIO3’: ‘On’, ‘GPIO1’: ‘Off’, ‘GPIO4’: ‘On’}
{‘GPIO2’: ‘On’, ‘GPIO3’: ‘On’, ‘GPIO1’: ‘On’, ‘GPIO4’: ‘On’}
{‘GPIO2’: ‘On’, ‘GPIO3’: ‘On’, ‘GPIO1’: ‘On’, ‘GPIO4’: ‘Off’}
{‘GPIO2’: ‘On’, ‘GPIO3’: ‘Off’, ‘GPIO1’: ‘On’, ‘GPIO4’: ‘Off’}
{‘GPIO2’: ‘Off’, ‘GPIO3’: ‘Off’, ‘GPIO1’: ‘On’, ‘GPIO4’: ‘Off’}
{‘GPIO2’: ‘Off’, ‘GPIO3’: ‘Off’, ‘GPIO1’: ‘Off’, ‘GPIO4’: ‘Off’}


#11

yes. Just type this in command line:

  • mycroft-pip install RPi.GPIO
  • sudo usermod -g gpio pi
  • I have tried without this : - sudo apt-get install python-rpi.gpio && sudo apt-get
    install python3-rpi.gpio (But if Doesn’t Work for you you can run this)

ReSpeaker 4-Mic Array HAT Mycroft A.I. Skill
ReSpeaker 4-Mic Array HAT Mycroft A.I. Skill
#12

Hello all. I am struggling to get my Picroft to control the GPIO pins. Firstly, I have followed the instructions on the Picroft home page and have successfully set up the GPIO software on my RPi. I verified this by running a simple blink program, which worked. Next, I msm installed the Example skill. When following the instructions in the read me, I am able to successfully build the html using the “make docs.” However, when it directs me to navigate to the web page, I have no idea how to do so since this is a local file and the PiCroft image doesn’t seem to have a web browser. This step also seem unnecessary, as nothing seems to be done once the page has been navigated to. Then I change the makefile, create the skill-gpio folder, and run make install.pi. When I run make test.pi, everything seems to work. Upon launching the mycroft cli, the skill boots correctly and responds appropriately. However, no changes occur on the pins. I’ve verified this by changing the output pin. SOS

Jonah


#13

To answer my own question (evidently, I should have just waited 20 minutes to post), I went in and changed both GPIO.py files (there is one in the picroft_example_skill_gpio.mycroftai
folder and another in the skill-gpio folder). Here are the following edits (look at comments):

“”“This is the setup for the RPi GPIO”""
if pi_interface:
GPIO.setmode(GPIO.BOARD) #Changed from GPIO.BCM to GPIO.BOARD
GPIO.setup(8,GPIO.OUT)
GPIO.setup(10,GPIO.IN) #Changed from 17 to 10
GPIO.add_event_detect(10,GPIO.BOTH,ButtonHandeler) #Changed from 17 to 10

def set(key,value):
“”"This is used to set values for GPIO

This function is used to set values for each of GPIO's Will also call
the GPIO's function if it exisits.

Args:
    key(int or str): Used to identify the gpio to interface
    value(int or str): The value to set the gpio to.
"""
GPIO_STATE[key] = value
if (key=="GPIO1") and pi_interface:
    if value.upper()=="ON":
        GPIO.output(8,GPIO.HIGH)    #Changed from 17 to 8
    else:
        GPIO.output(8,GPIO.LOW)     #Changed from 17 to 8
if key in GPIO_ON:
    GPIO_ON[key]()

I also adjusted my wiring using a schematic I found on this website. I hope someone else finds this useful.