How to open a serial connection w/daisyLib

I’m having trouble finding useful examples for really simple things with the Daisy Seed. I’m using VSCode for editing and compiling and uploading using make and make program-dfu on Linux using the non-Arduino daisylib.
My question is, are there any simple examples of how to open a serial port? There are some vague un-commented examples I found on serial messages over the USB port, but what about communicating to other devices over Serial?
Any help? Thanks.

You have examples in STM32Cube library (from STMicroelectronics) of two boards communicating through serial protocol using UARTs.

I’m bit late to the party , but this might help

Connect Daisy Usart 1 to a Host PC

You need to purchase a Serial to USB converter
In the UK I bourght one of these

And just wire the TX and Rx pin ( no need to wire up anything else) of this to the Daisy’s USART1 Rx & USART1 TX, remember swop TX and RX
TX ----> Rx
RX <— TX

On your PC you should then see the Serial Port to use ( gets added once
you connect) Daisy <—> USB/Serial convert <----> computer Port
On mine it presented itself as “Silicon Labs CP210x USB to Uart” on Port 9
This is what you’ll open in what ever Serial port monitor app you use.

Connect to another Serial Port e.g. another processors Uart
Then you will not need the USB/Uart converter.
just swop over Tx Rx

Daisy Code Example

Below is a very basic/simple serial port usage

In main.cpp define a method as follows

	SerialDebugWriteString( const char txBuffer[],  int bufferSize){ 
		PollTx((uint8_t *)&txBuffer[0],  bufferSize);

then instance the uart

uint8_t rxBuffer[16];

      UartHandler uart;
    	//set input buffer to 16 chars
        uart.StartRx(16) ;

    	// write something to the serial port
      SerialDebugWriteString("hello", 5);

To read the serial port

      //read bytes from the serial port
      size_t   rxCount = uart.Readable();
            if(rxCount > 0){
    			//ReadBlock is a method you have to add to per_uart.cpp
                uart.ReadBlock(rxBuffer, rxCount);

In libdaisy/src add the following , then recompile ( make )

in per_uart.h

void ReadBlock(uint8_t *destination, size_t num_elements);

in per_uart.cpp

void UartHandler::ReadBlock(uint8_t *destination, size_t num_elements){
    uhandle.queue_rx.ImmediateRead(destination, num_elements);

In per_uart.cpp you’ll see the baud rate etc set in the method void UartHandler::Init()
Make sure you have the correct baud, data bits, stop bits etc.

Hope this helps

Hi… After you unplug, plug within the dongle to the machine, do you see a serial harbour gadget show up within the /dev organizer? What is the title, read/write consents (ls -l /dev)? The prior pyOpenBCI mistake may have been due to a gadget title jumble or consents issue. The Nano runs what variation of Linux? In the event that it is Ubuntu as the look results suggest, you might have a record consents issue with the gadget. It should have both examined and type in authorizations for proprietor or gather. And in some cases those are as it were turned on for a specific gather by default.

Thank you for the informative guide. However, I’ve followed all of your instructions to read from the daisy on my computer, and yet I’m not receiving any messages when I use this python code:

from serial import Serial
from time import sleep

daisy = Serial('/dev/cu.usbserial-AB0NV0KR', 31250, timeout=1)

while True:

The first argument of Serial I found from my computer ports, the second is the baud rate found from per_uart.cpp.

My Seeds code simply loops writing a message:

#include "daisysp.h"
#include "daisy_petal.h"
#include "terrarium.h"

using namespace daisysp;
using namespace daisy;
using namespace terrarium;

static DaisyPetal petal;

bool passThruOn;

Led led1;

void ProcessControls() {

  if(petal.switches[Terrarium::FOOTSWITCH_1].RisingEdge()) // ON/OFF footswitch
      passThruOn = !passThruOn;
      led1.Set(passThruOn ? 0.0f : 1.0f);

void InitBoard() {
	led1.Init(petal.seed.GetPin(Terrarium::LED_1), false);

static void SerialDebugWriteString( const char txBuffer[],  int bufferSize){
		UartHandler::PollTx((uint8_t *)&txBuffer[0],  bufferSize);

static void AudioCallback(float **in, float **out, size_t size)
    SerialDebugWriteString("HELLO", 5);


int main(void)

    uint8_t rxBuffer[16];

    UartHandler uart;

    //set input buffer to 16 chars
    uart.StartRx() ;

    // write something to the serial port
    SerialDebugWriteString("hello", 5);

    // start callback

The only difference is you have 16 as an argument for uart.StartRx(), which doesn’t seem to take any arguments.

My pedal isn’t crashing as the LED is functional, and the only computer output I get is:
b’’ (an empty byte) every loop.

Do you have any ideas what I’m doing wrong or what methods I could use to debug this?

You may also have an easier time with the logger, for which there is an example here.