Wait on Arduino auto-reset using pySerial

前端 未结 3 1123
礼貌的吻别
礼貌的吻别 2021-02-08 05:54

I\'m trying to read lines from an Arduino board with a very simple code (for the sake of showcasing the problem) on Linux.

Python code:

# arduino.py
impo         


        
3条回答
  •  别那么骄傲
    2021-02-08 06:28

    you need to set your var , try:

    unsigned long ii = 0;
    

    but pay attention that this is a 32 bit var and when it is full ,cause overflow and reboot. for me work. As suggested by @Kobi K add a minimal delay time, for load real data at 9600 boud each char has a duration of 2 ms,

        void loop() {
    
          Serial.println(ii);
          delay(20);
          ii++;
        }
    

    And in python you need to declare a Pyserial like this:

    arduino=serial.Serial('/dev/ttyACM0',9600,timeout=0.0001)
    

    hope this help you

提交回复
热议问题