There is no direct support for sensors on the GrovePi serial port. You’ll have to customize the firmware and the software to make use of the serial port.
Can you give some more information about what sensor are you already using with the RPISER port and what other sensor are you trying to use.
Thank you for your response but i will use one of the usb ports of the Raspberry to get a second serial port because i have not enough experience in C++ and time to customize the firmware.
But i have a different problem i often get IOError when i try to grovepi.digitalWrite or grovepi.digitalRead, is there a way to prevent that from happening.
I tried to swich digital pin 4 with your Grove_-_2-Coil_Latching_Relay.py script.
Sometimes it prints that the pin is switched on or off without changing the the state of the pin, looks like your exception handling doesn’t work correct.
I have to check the pin after i switched it to be sure it really switched.
#!/usr/bin/env python
import time
import grovepi
ON = 'on’
OFF = ‘off’
relay = 4
def readPin(args):
while True:
pinStatus = grovepi.digitalRead(args)
if pinStatus == 0 or pinStatus == 1: #print pinStatus
return pinStatus
break
else: #print 'IOError’
time.sleep(0.3)
def writePin(pin, args):
if args == ‘off’:
while True:
grovepi.digitalWrite(pin,0)
time.sleep(0.3)
y = readPin(pin) #print y
if y == 1:
print "IOError"
time.sleep(0.3)
elif y == 0:
print ‘pin:’, pin, args
break
elif args == ‘on’:
while True:
grovepi.digitalWrite(pin,1)
time.sleep(0.3)
y = readPin(pin) #print y
if y == 0:
print "IOError"
time.sleep(0.3)
elif y == 1:
print ‘pin:’, pin, args
break
a = raw_input(‘Type on or off to switch relay:n’)
if a == ON:
writePin(relay, ON)
elif a == OFF:
writePin(relay, OFF)