edit

Using the Grove Digital Port on Wio Terminal

This repo demonstrates how to use the Grove Ports on Wio Terminal as Digital Ports. You can simply use this functionality to play with the Grove Ecosystem!

RPI Digital Pins

The Raspberry Pi pinouts are defined as:

  • RPI_D0 -> RPI_D8

Grove Port Configurations

To use the Grove configurable A/D Port as Digital port, simply define it as follow:

1
2
3
void setup() {
    pinMode(D0, INPUT); //Configure UART TX as Digital port
}

Using the Grove I2C Port as Digital Port

The Grove I2C port can also be used as Digital Port on Wio Terminal:

1
2
void setup() {
    pinMode(PIN_WIRE_SCL, INPUT); //Defined SCL of I2C port as Digital Input

Now, connect your Grove sensor to the physical Grove Port!

Note: For more defined variant pin name, please check Schematic and variant.h

Example Code

In this example, a Grove Button and Grove LED are used to demonstrate:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define BUTTON D0 //Button to Grove UART Port
#define LED PIN_WIRE_SCL //LED to Grove I2C Port

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON, INPUT);
  pinMode(LED, OUTPUT);
}

void loop() {
  int buttonState = digitalRead(BUTTON);
  Serial.print("Button State: ");
  Serial.println(buttonState);

  if (buttonState == HIGH) {
    digitalWrite(LED, HIGH);
  }
  else {
    digitalWrite(LED, LOW);
  }
  delay(50);
}

PWM Output Example Code (Servo)

In this example, a Grove Servo is used to demonstrate PWM output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <Servo.h>
Servo myservo;

int pos = 0;

void setup() {
  myservo.attach(D0); //Connect servo to Grove Digital Port
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) {
    // in steps of 1 degree
    myservo.write(pos);
    delay(15);
  }
  for (pos = 180; pos >= 0; pos -= 1) {
    myservo.write(pos);
    delay(15);
  }
}

Note: To use the Servo library with Wio Terminal, please include Adafruit's version for SAMD51 capability.

UART Serial

  • The USB Serial in Wio Terminal: Serial

  • The broken out UART port: Serial1