RFLink and nano together
Posted: Sunday 07 February 2016 12:47
I am running domoticz on a RPi. Since yesterday I added a RFLink to it. I recently made also a arduino nano with 5 sensors on it which I read out serial and which values are pushed using json. Since I added the RFlink the system becomes unstable. Initially I thought it had something to do with the power consumption, so I added everything to a powered hub, but it stayed unstable. So I think It has to do something with the serial connection I made with the nano. The python script I use for the serial connection is:
The lines I get from arduino:
Code: Select all
#!/usr/bin/env python
import time
import serial
import sys
import urllib2
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
counter=0
humavg=0
tem1avg=0
tem2avg=0
tem3avg=0
lightavg=0
while 1:
x=ser.readline()
values = x.split(" ")
if len(values) == 14:
counter=counter+1
humavg = float(values[1])/3 + humavg
tem1avg = float(values[3])/3 + tem1avg
tem2avg = float(values[6])/3 + tem2avg
tem3avg = float(values[9])/3 + tem3avg
lightavg = float(values[12])/3 + lightavg
if counter ==3:
f=urllib2.urlopen('http://192.168.1.132:8080/json.htm?type=command¶m=udevice&idx=27&nvalue=0&svalue='+str(lightavg))
f=urllib2.urlopen('http://192.168.1.132:8080/json.htm?type=command¶m=udevice&idx=25&nvalue=0&svalue='+str(tem2avg))
f=urllib2.urlopen('http://192.168.1.132:8080/json.htm?type=command¶m=udevice&idx=26&nvalue=0&svalue='+str(tem3avg))
f=urllib2.urlopen('http://192.168.1.132:8080/json.htm?type=command¶m=udevice&idx=24&nvalue=0&svalue='+str(tem1avg)+';'+str(humavg)+';1')
sys.exit()
Code: Select all
Sensors at nano
Humidity: 35.70 % Temperature: 20.10 *C T1: 33.56 *C T2: 18.06 *C Light: 87.30 %
Humidity: 35.60 % Temperature: 20.20 *C T1: 33.63 *C T2: 18.06 *C Light: 85.16 %