原始数据有时来自Python中的Arduino

时间:2017-08-18 20:19:34

标签: python python-3.x arduino

Port = input('enter valid port = ')
baudrate=input('enter valid baudrate = ')
arduino_Data = serial.Serial(Port, baudrate)               
    while True:
        adata=arduino_Data.readline().strip()
        print adata
        fdata=adata.split(",")

Arduino发送如下数据:

  

4.36625,0.08520

     

4.36625,0.08420

     

4.36625,0.08460

     

4.37250,0.08500

     

4.36750,0.08520

     

4.35500,0.08480

     

4.36000,0.08500

     

4.36250,0.08460

     

4.36250,0.08480

Python读取它但有时Python中的数据是这样的:

  

4.35250,750,0.08500

我该如何避免这种情况?我基本上准确地每秒需要20个读数,以便我可以绘制它们。如果这样的数据发生,它将在图中给出错误。

0 个答案:

没有答案