Timothy Lovett
Published © CC BY-NC-SA

Level Up Xiao Level Shift PCB

A PCB to handle level shifting via the use of jumpers between 3V3 and 5V for UART and i2c with Grove ports for ease of use

IntermediateShowcase (no instructions)8 hours147
Level Up Xiao Level Shift PCB

Things used in this project

Story

Read more

Schematics

Xiao Level Up Board

Code

Serial Example - Xiao

C/C++
const int buttonPin = D5;
const String triggerMessage = "BUZZER_ON";
bool buttonState = LOW;
bool lastButtonState = LOW;
HardwareSerial SerialOut(0);

void setup() {
  pinMode(buttonPin, INPUT);
  SerialOut.begin(9600, SERIAL_8N1, -1, -1);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && lastButtonState == LOW) {
    SerialOut.println(triggerMessage);
  }

  lastButtonState = buttonState;
  delay(50);
}

Serial Example - Uno

C/C++
#include <NeoSWSerial.h>

// Define the software serial pins
const int rxPin = 6; // RX pin
const int txPin = 5; // TX pin

NeoSWSerial mySerial(rxPin, txPin);

const int buzzerPin = A0;
const String triggerMessage = "BUZZER_ON";

void setup() {
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(buzzerPin, LOW); 

  mySerial.begin(9600);
}

void loop() {
  if (mySerial.available() > 0) {
    
    String message = mySerial.readStringUntil('\n');
    message.trim();
    if (message == triggerMessage) {
      digitalWrite(buzzerPin, HIGH);
      delay(1000);
      digitalWrite(buzzerPin, LOW);
    }
  }
}

Credits

Timothy Lovett
22 projects • 18 followers
Maker. I spent over a decade working on backend systems in various languages.

Comments