/dev/ttyACM0 no serial monitor output Linux Debian ParrotOS

(Arduino UNO)

im developing an application where a list of RFID execute a list of media in html. The problem appeared when once i was able to read RFID UID i tried to catch it in my computer, so i tried the nodeJS module (serialport) and no worked, so i tried with python (pyserial) with python i was able write in the /dev/ttyACM0, but everytime i tried to read the content it displayed a blank space, rebooted the arduino and now Serial Monitor no shows up rfid data

(reinstalling arduinoIDE, deleting .config files/folders etc didnt help)

idk if this is nesecary but here is the code

.ino


#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.

void setup() {
  Serial.begin(9600);  // Initiate a serial communication
  SPI.begin();         // Initiate  SPI bus
  mfrc522.PCD_Init();  // Initiate MFRC522
}
void loop() {
  // Look for new cards
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return;
  }
  // Select one of the cards
  if (!mfrc522.PICC_ReadCardSerial()) {
    return;
  }
  //Show UID on serial monitor
  String content = "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.availableForWrite();
}

monitor-service INFO No port configuration changes have been detected. No need to send configure commands to the running monitor serial:/dev/ttyACM0.

The Arduino Uno has a circuit that causes it to reset whenever you open its serial port. So this result would be expected if you were opening the port before each read (as opposed to opening it only once and then reading from that previously opened port as needed).

When I'm having trouble with serial output, I like to do a quick check with the most simple possible sketch. If this works, then I know the problem has something to do with my real sketch. If it doesn't work, then I know the problem is not related to my sketch code. It seems maybe a little silly, but it allows me to be sure I'm focusing my troubleshooting efforts in the right direction.

Try uploading this sketch to your Arduino board:

  1. Copy and paste this code as a new sketch in Arduino IDE:
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      Serial.println("hello");
      delay(1000);
    }
    
  2. Upload the sketch to your Arduino board.
  3. Select Tools > Serial Monitor from the Arduino IDE menus to open the Serial Monitor view if it is not already open.
  4. Make sure the baud rate menu at the top right corner of the Serial Monitor panel is set to "9600".

Do you now see the word "hello" being printed in the Serial Monitor's output field once a second?

Serial.availableForWrite()

This call returns a number that is how many bytes are left in the serial buffer for you to write in.
However you are not doing anything with this number you are simply throwing it away, why?
This is the definition of that call:-

available for write

Now if you used:-

  byte n = Serial.availableForWrite();
  Serial.println(n);

It would make more sense because it would tell you how much of the buffer you have to write in.
However, you don't seem to be writing anything anyway?

What did you want to do with that call?

You see to be printing only 4 bytes anyway so this would make more sense

while(Serial.availableForWrite() < 4) {
  Serial.println("waiting for buffer to empty");
}
Serial.println("buffer now cleared")

But again there is absoloutly no reason to do this, because your serial buffer will empty faster than you can fill it. If you find it doesn't then simple set the baud rate to a much faster one.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.