Seriel1 not declared basic uart_rvc

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
Oeuf
 
Posts: 1
Joined: Tue Apr 18, 2023 12:30 pm

Seriel1 not declared basic uart_rvc

Post by Oeuf »

Hey, new member here, I recently tried out the UART-RVC setup on the Arduino UNO shell, and when I tried to run it gave me this error message:

Code: Select all

C:\Users\User\BANNED\Documents\Arduino\uart_rvc\uart_rvc.ino: In function 'void setup()':
uart_rvc:17:3: error: 'Serial1' was not declared in this scope
   Serial1.begin(115200); // This is the baud rate specified by the datasheet
   ^~~~~~~
C:\Users\User\BANNED\Documents\Arduino\uart_rvc\uart_rvc.ino:17:3: note: suggested alternative: 'Serial'
   Serial1.begin(115200); // This is the baud rate specified by the datasheet
   ^~~~~~~
   Serial
exit status 1
'Serial1' was not declared in this scope
The code is :

Code: Select all

#include <Adafruit_BNO08x_RVC.h>

/* Test sketch for Adafruit BNO08x sensor in UART-RVC mode */



Adafruit_BNO08x_RVC rvc = Adafruit_BNO08x_RVC();

void setup() {
  // Wait for serial monitor to open
  Serial.begin(115200);
  while (!Serial)
    delay(1);

  Serial.println("Adafruit BNO08x IMU - UART-RVC mode");

  Serial1.begin(115200); // This is the baud rate specified by the datasheet
  while (!Serial1)
    delay(10);

  if (!rvc.begin(&Serial1)) { // connect to the sensor over hardware serial
    Serial1.println("Could not find BNO08x!");
    while (1)
      delay(10);
  }


  Serial.println("BNO08x found!");
}

void loop() {
  BNO08x_RVC_Data heading;

  if (!rvc.read(&heading)) {
    return;
  }

  Serial.println();
  Serial.println(F("---------------------------------------"));
  Serial.println(F("Principal Axes:"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("Yaw: "));
  Serial.print(heading.yaw);
  Serial.print(F("\tPitch: "));
  Serial.print(heading.pitch);
  Serial.print(F("\tRoll: "));
  Serial.println(heading.roll);
  Serial.println(F("---------------------------------------"));
  Serial.println(F("Acceleration"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("X: "));
  Serial.print(heading.x_accel);
  Serial.print(F("\tY: "));
  Serial.print(heading.y_accel);
  Serial.print(F("\tZ: "));
  Serial.println(heading.z_accel);
  Serial.println(F("---------------------------------------"));


  //  delay(200);
}
The website source:
https://learn.adafruit.com/adafruit-9-d ... or-arduino

Does it mean that: The UNO shell is incapable? Or there is something missing in the code?

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: Seriel1 not declared basic uart_rvc

Post by adafruit_support_carter »

For the UNO, will need to use SoftwareSerial.
https://docs.arduino.cc/learn/built-in- ... are-serial

Try this wiring:
  • UNO 5V to BNO VIN
  • UNO GND to BNO GND
  • UNO #2 to BNO SDA
  • BNO P0 to BNO 3Vo (this sets RVC mode)
And this sketch:

Code: Select all

/* Test sketch for Adafruit BNO08x sensor in UART-RVC mode */

#include <SoftwareSerial.h>
#include "Adafruit_BNO08x_RVC.h"

Adafruit_BNO08x_RVC rvc = Adafruit_BNO08x_RVC();

const byte rxPin = 2;
const byte txPin = 3;

// Set up a new SoftwareSerial object
SoftwareSerial mySerial (rxPin, txPin);

void setup() {
  // Wait for serial monitor to open
  Serial.begin(115200);
  while (!Serial)
    delay(10);

  Serial.println("Adafruit BNO08x IMU - UART-RVC mode");

  mySerial.begin(115200); // This is the baud rate specified by the datasheet

  if (!rvc.begin(&mySerial)) {
    Serial.println("Could not find BNO08x!");
    while (1)
      delay(10);
  }

  Serial.println("BNO08x found!");
}

void loop() {
  BNO08x_RVC_Data heading;

  if (!rvc.read(&heading)) {
    return;
  }

  Serial.println();
  Serial.println(F("---------------------------------------"));
  Serial.println(F("Principal Axes:"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("Yaw: "));
  Serial.print(heading.yaw);
  Serial.print(F("\tPitch: "));
  Serial.print(heading.pitch);
  Serial.print(F("\tRoll: "));
  Serial.println(heading.roll);
  Serial.println(F("---------------------------------------"));
  Serial.println(F("Acceleration"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("X: "));
  Serial.print(heading.x_accel);
  Serial.print(F("\tY: "));
  Serial.print(heading.y_accel);
  Serial.print(F("\tZ: "));
  Serial.println(heading.z_accel);
  Serial.println(F("---------------------------------------"));


  //  delay(200);
}

User avatar
gammaburst
 
Posts: 1015
Joined: Thu Dec 31, 2015 12:06 pm

Re: Seriel1 not declared basic uart_rvc

Post by gammaburst »

That SoftwareSerial sketch will kinda run on an Uno, but you'll probably see some data glitches and less than the full 100 readings per second.

The Uno has has only one hardware UART, and it's connected to the USB interface.
You'll have better luck using a different processor that has an extra hardware UART.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”