0
votes

I'm trying to dump signal data over the arduino's channel using a Processing script. Currently my arduino code reads the data over COM3 and I'm running into an within the Processing code that looks like ;"Error opening Serial Port COM3: Port not found". The arduino code for the accelerometer/gyroscope signal and Processing script were found from Sparkfun's site:

https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/discuss

Below are the code segments I am working on:

Arduino Signal Reading-

    #include "SparkFunLSM6DS3.h"
    #include "Wire.h"
    #include "SPI.h"

    LSM6DS3 myIMU; //Default constructor is I2C, addr 0x6B

    void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      delay(1000); //relax...
      Serial.println("Processor came out of reset.\n");
    //  Serial.println(value);

      //Call .begin() to configure the IMU
      myIMU.begin();
      //Over-ride default settings if desired
      myIMU.settings.gyroEnabled = 1;  //Can be 0 or 1
      myIMU.settings.gyroRange = 2000;   //Max deg/s.  Can be: 125, 245
      myIMU.settings.gyroSampleRate = 833;   //Hz.  Can be: 13, 26, 52, 104,  208, 416, 833, 1666
      myIMU.settings.gyroBandWidth = 200;  //Hz.  Can be: 50, 100, 200, 400;
      myIMU.settings.gyroFifoEnabled = 1;  //Set to include gyro in FIFO  
      myIMU.settings.gyroFifoDecimation = 1;  //set 1 for on /1

    myIMU.settings.accelEnabled = 1;
    myIMU.settings.accelRange = 16;      //Max G force readable.  Can be: 2, 4, 8, 16
    myIMU.settings.accelSampleRate = 833;  //Hz.  Can be: 13, 26, 52, 104, 208, 416, 833, 1666, 3332, 6664, 13330
    myIMU.settings.accelBandWidth = 200;  //Hz.  Can be: 50, 100, 200, 400;
    myIMU.settings.accelFifoEnabled = 1;  //Set to include accelerometer in the FIFO
    myIMU.settings.accelFifoDecimation = 1;  //set 1 for on /1
    myIMU.settings.tempEnabled = 1;

    //Non-basic mode settings
    myIMU.settings.commMode = 1;

    //FIFO control settings
    myIMU.settings.fifoThreshold = 100;  //Can be 0 to 4096 (16 bit bytes)
    myIMU.settings.fifoSampleRate = 50;  //Hz.  Can be: 10, 25, 50, 100, 200, 400, 800, 1600, 3300, 6600
    myIMU.settings.fifoModeWord = 6;  //FIFO mode.
    //FIFO mode.  Can be:
    //  0 (Bypass mode, FIFO off)
    //  1 (Stop when full)
    //  3 (Continuous during trigger)
    //  4 (Bypass until trigger)
    //  6 (Continous mode)
    }

    void loop()
    {
      //Get all parameters
      Serial.print("\nAccelerometer:\n");
      Serial.print(" X = ");
      Serial.println(myIMU.readFloatAccelX(), 4);
      Serial.print(" Y = ");
      Serial.println(myIMU.readFloatAccelY(), 4);
      Serial.print(" Z = ");
      Serial.println(myIMU.readFloatAccelZ(), 4);

      Serial.print("\nGyroscope:\n");
      Serial.print(" X = ");
      Serial.println(myIMU.readFloatGyroX(), 4);
      Serial.print(" Y = ");
      Serial.println(myIMU.readFloatGyroY(), 4);
      Serial.print(" Z = ");
      Serial.println(myIMU.readFloatGyroZ(), 4);

      Serial.print("\nThermometer:\n");
      Serial.print(" Degrees C = ");
      Serial.println(myIMU.readTempC(), 4);
      Serial.print(" Degrees F = ");
      Serial.println(myIMU.readTempF(), 4);

      delay(1000);
    }

Processing Script-

    import processing.serial.*;
    Serial myPort;
    String val;

    void setup() {


      size(500,500);
      //String portName = Serial.list()[2];

      myPort = new Serial(this , "COM3", 9600);

    }
    void draw()
    {
      if (myPort.available() > 0)
      {val = myPort.readStringUntil('\n');}
      println(val);
    }

Not sure if there is something wrong with my code implementation or if I'm missing channel compatibility. Any help offered would be greatly appreciated.

2
Are you sure that your arduino is connected to COM3? can you check it in the control panel or in the Arduino IDE when you program it?frarugi87

2 Answers

0
votes

Try the following I am writing out of experiance :

  1. Try Plugging the USB into a different Port
  2. Restart your PC
  3. Make sure other software's (like Processing) are not active with the arduino
  4. Try a different wire
  5. try a different pc
  6. your arduino is probably burnt (unfortunately)

Good Luck

0
votes

OK So I managed to resolve the issue by realizing that this issue only occured while Serial Monitor was running on the machine. With it off, Processing is able to use the channel.