php - python overlapping values from serial -


i have arduino connected pi via usb , sending readings dht sensor using simple program below (this bit works expected in arduino serial monitor):

int chk = dht.read11(dht_pin); serial.println(dht.temperature,1); delay(2000); 

i have python program should data serial port:

import serial conn = serial.serial('/dev/ttyacm0',9600) temp = conn.readline()  print temp 

this script called in php using $temp = shell_exec('python temp.py 2>&1'); works fine values serial wrong.

the expected output should 23.0 when refresh page (or run python script in terminal) values 2323.0, 23.023.0, 22..0 , 2. these change time , come out in desired format.

it seems if data serial overlapping, though serial.println() function puts on new line. if tell me how correct appreciated.

try print repr(temp) ... or print temp.strip()+" . "

i stronly suspect when read get

"23.0\r" 

\r returns cursor start of line

if print "23.0\rb" see "b3.0"

(ie think seeing overlap because printing it...)


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -