Serial.write out of Snips-based Relay&Temperature&Humidity app

Applications/questions using Raspberry Pi with Seeed products, please post it here.

Moderators: lily.li, violet, salmanfarisvp

Post Reply
frankhermes
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Tue Jun 11, 2019 10:36 am

Serial.write out of Snips-based Relay&Temperature&Humidity app

Post by frankhermes » Fri Jun 28, 2019 8:25 am

I am using the SEEED Relay&Temperature&Humidity app in my RPi snips device...

The app works fine when I ask it to perform the various intents, such as "turn relay on"...

I want to add a data packet serial write in the action-code, i.e., when the relay turns on I also want to send a packet to a USB-connected device...I cannot seem to effect this - I cannot get past simply importing the serial library and trying to open the port, without even trying to do the data write...

If I put in the import statement [import serial], that's OK, but when I add the line to open the port:

ser = serial.Serial(port = '/dev/ttyUSB0', baudrate = 57600, timeout = 1)

it breaks the snips app after recognizing the wake-word and going to implement the activity - see attached screenshot...

If I run a simple python script while I am running the working or broken snips app, such as:

Code: Select all

import RPi.GPIO as GPIO
import time
import serial

BUTTON = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(BUTTON, GPIO.IN)

ser = serial.Serial(port = '/dev/ttyUSB0', baudrate = 57600, timeout=1)

while True:
    state = GPIO.input(BUTTON)
    if state:
        print("off")
    else:
        print("on")
        ser.write ("\xFF\x55\x21\xDE\x00\xFF")
    time.sleep(.5)
things run fine and the data is sent to the device...

I have tried placing the serial open line at various places within the app (I am not proficient on classes and such) but the result is always essentially the same...

Is there something in the snips code that is in my way? I see in their (snips) Coffee Machine app they write data out to an Arduino...

Confused and could use some advice please...

Thanks, Frank

Post Reply