Mycroft Community Forum

Trying to get Mycroft to speak Arduino-sent data

I am new to Mycroft. I am running picroft on a Raspberry Pi 4 Model B Rev 1.2 with mycroft-core: 20.2.4 and using Python 3.7.3.

I have connected an Arduino Uno to the Raspi via USB cable and created a “stupid simple” device that has a single pot (short for potentiometer aka a dial). The Arduino code reads the analog input and sends over serial. The Raspi successfully reads the serial information (see screenshot and code). That’s not what I need help with. (NOTE: the “p3” command is just a bash alias I setup for ‘python3’)

The code being run is:


    import serial

    ser = serial.Serial('/dev/ttyUSB0', 115200)


Here is where I am stuck: I want to be able to say “Hey Mycroft, what is the sensor reading?” and have it reply (i.e. verbalize) the current reading at that moment. I have two problems here:

  1. I have “What is the sensor reading?”, “Read the sensor.” And “What is the sensor level?” in the /opt/mycroft/skills/read-arduino-pot-skill/locale/en-us/ file but Mycroft does not associate the utterances with this skill. I even tried mycroft-say-to “What is the sensor reading?” from the command line but it doesn’t know what I mean. I have read up on the Adapt Intents ( but from the examples on the page, I am not certain how that would help here. Perhaps the noobie is wrong. Wouldn’t be the first time.

  2. Let’s assume that Problem #1 is solved. How do I code the skill’s to actually speak the reading? If I assign the current value from the serial stream to a variable, how do I get Mycroft to say “The sensor reads $VALUE” where $VALUE is the variable storing the current reading? Right now, I have the following. If only I could test it but I still have Problem #1.

from mycroft import MycroftSkill, intent_file_handler
import serial

class ReadArduinoPot(MycroftSkill):
    def __init__(self):

    def initialize(self)
        ser = serial.Serial('/dev/ttyUSB0', 115200)

    def handle_pot_arduino_read(self, message):
        self.speak_dialog('' + read_uno)

def create_skill():
    return ReadArduinoPot()

Thanks to all for your help.

EDIT: I corrected the markdown above to use a code block instead of a blockquote so the indentation and formatting is corrected now.

First off, use an existing skill ( lots of folks use the weather skill ). Copy it, rename it and tweak it to use your intents. Respond with a static response “The reading is 42 Dave. The answer is always 42”.

Once you have that working, tweak the weather skill actions to query your local sensor rather than the external weather API.

Docs here:.

1 Like