some measurement that needs a long The first byte after the start symbol is the identifier byte. Start & stop symbols help to get the datastream in sync again if connection loses a byteĮ.g. With binary data it is good practice to send delimiters with the stream. Python must read 2 bytes and merge them import serial What am I doing wrong ?Īrduino sends 2 bytes. This return values that doesn’t make sense, whereas it is correct if I just use Serial.print() on the Arduino. I just made a test that gradually increases the speed of the motor, and measure the speed with the Python interface. Motor_speed_mean = (int)(motor_speed_meas/10) Īnd then the code I am using on Python : import serial Motor_speed_meas = motor_speed_meas + 500000/(float)pulseIn(7, HIGH) Here is the part of the code on the Arduino : // Return the motor speed It works well if I just pring the value on the serial monitor, but when I try to read it with Python is returns weirds hexadecimal values. I am currently trying to read the speed of a DC motor with pySerial.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |