[Resolved] Code does not compile for Grove UART on WIO GPS Tracker

Simplify IoT Development.

Moderators: lily.li, violet, seth.welday

Post Reply
dan359
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Fri Oct 18, 2019 10:00 am

[Resolved] Code does not compile for Grove UART on WIO GPS Tracker

Post by dan359 » Sun Nov 10, 2019 3:31 am

Hello,

I am using the WIO GPS Tracker

and I am trying to use demo code for the Grove UART port

Code: Select all

#define GrovePowerPin   12

void setup() {
  pinMode(GrovePowerPin, OUTPUT);
  digitalWrite(GrovePowerPin, HIGH);    //power Grove
  //SerialUSB.begin(115200);
  SerialDBG.begin(115200);    //set Grove UART baud rate 115200
}

void loop() {  
  //SerialUSB.println("Grove UART is sending message");
  SerialDBG.println("This is Grove UART");
  delay(1000);
}
But this does not compile I get error: 'SerialDBG' was not declared in this scope

I do not find any instance of SerialDBG in any files in folder: Seeed_Wio_GPS_Board-master (nor the main Arduino library folders in the application path)

FYI, I am trying to use the port to interface with the Grove 12 Channel Capacitive Touch Keypad (ATtiny1616)

As an aside, I found that with the last update all of the references to SerialUSB must be changed to Serial or i get similar compile errors so perhaps the board files changed?

I have many of the other features of this board working successfully, obtaining GPS coordinates (and even added fetching UTC time to base library), send and receive of SMS messages, writing to a Seeed 0.96" OLED, reading and writing to the SD card, etc, so it doesn't seem to be a basic library problem. It seems to me the writer of the demo sketch has a dependency that defines that Grove uart that I don't have.

Can you offer any help?

Thank you
Last edited by dan359 on Thu Nov 14, 2019 12:07 pm, edited 1 time in total.

dan359
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Fri Oct 18, 2019 10:00 am

Re: Code does not compile for Grove UART on WIO GPS Tracker

Post by dan359 » Thu Nov 14, 2019 12:06 pm

I figured out how to get the Grove UART to work on the WIO GPS Tracker (I suspect it is the same for many Seeed boards), here is the code for it.
I also resolved the problem with Seeed demos for the same board not compiling because of error: SerialDBG' was not declared in this scope (#define SerialUSB Serial)

The secret to getting the Grove UART port to work was declaring the hardware uart on those pins and putting them into one of their alternative modes.

This demo assumes you have connected the Grove UART to something with a text display, I used a typical USB to serial cable and opened Tera Term to watch the output from the Grove serial port. Then I can type in the Serial Monitor in the Arduino IDE and type things out to the serial port and see that appear on my terminal to check all the connections.

Code: Select all


#include "wiring_private.h" // pinPeripheral() function

// Instantiate the Serial2 class
Uart Serial2(&sercom1, 31ul, 30ul, SERCOM_RX_PAD_3, UART_TX_PAD_2);

void SERCOM1_Handler()
{
  Serial2.IrqHandler();
}

void setup()
{
  Serial.begin(115200); // FYI: I fixed this scope error in some WIO libraries with: #define SerialUSB Serial

  //getting Grove UART port on WIO GPS Tracker
  //Power the port
  pinMode(12, OUTPUT);
  digitalWrite(12, HIGH);

  // Assign pins 44 & 45 SERCOM functionality
  pinPeripheral(44, PIO_SERCOM_ALT);
  pinPeripheral(45, PIO_SERCOM_ALT);

  Serial2.begin(9600);
}

void loop()
{

  if   (Serial2.available())
  {
    Serial.println(Serial2.read(), HEX);
  }
  if   (Serial.available())
  {
    Serial2.write(Serial.read());
  }
    Serial.println("Serial");
    Serial2.println("Serial2");
  delay(1000);
}

Post Reply