Serial Communication from Arduino to Daisy Seed

Hi All! I would like to control DS with my Arduino Nano 33 IOT through Serial. After searching and testing codes from the other forum posts, I was unable to get any readings from the RX on DS. Attached is my wiring diagram:

My code for Arduino Nano 33 IOT in Arduino IDE:

void setup() {
  Serial.begin(9600);

}

void loop() {
  Serial.write("hello");
  delay(500);
}

My Code for DS in VS Code:

#include "daisy_seed.h"
using namespace daisy;
DaisySeed hw;
int main(void)
{
    hw.Configure();
    hw.Init();
    hw.StartLog(false);
    System::Delay(3000);
    hw.PrintLine("Starting Read-test");
    UartHandler         uart;
    UartHandler::Config config;
    config.baudrate = 9600 ;
     config.periph   = UartHandler::Config::Peripheral::USART_1;
    config.stopbits      = UartHandler::Config::StopBits::BITS_1;
    config.parity        = UartHandler::Config::Parity::NONE;
    config.mode          = UartHandler::Config::Mode::TX_RX;
    config.wordlength    = UartHandler::Config::WordLength::BITS_8;
    config.pin_config.rx = {DSY_GPIOB, 7};  // (USART_1 RX) Daisy pin 15
    config.pin_config.tx = {DSY_GPIOB, 6};  // (USART_1 TX) Daisy pin 14
    
    uart.Init(config);
    uart.StartRx();

    for(;;)
    {
        uint8_t mybuffer;
       int ret = uart.PollReceive(&mybuffer, 1, 1);
        if(ret == 0) {
            hw.PrintLine("%c", mybuffer);
        }
    }
}

The VS Code serial Monitor Extension works fine when simply printing from DS (For example hw.PrintLine("hello)), so that’s not the problem.

Did I miss anything in the code that I’m not aware of? I thought Serial would be the most straightforward way to communicate between Nano 33 IOT and DS and it’s still very hard for me to get it to work. Any advice would be greatly appreciated!

Thx in advance!!

I’d try a loopback test, connect tx to rx, and send something from the Daisy to itself. If it works, it tells you that something’s right about your setup, though it wouldn’t tell you why the Arduino isn’t heard.

EDIT: I copied your code into a file name uart.cpp, make returned:
uart.cpp: In function ‘int main()’:
uart.cpp:23:10: error: ‘class daisy::UartHandler’ has no member named ‘StartRx’
23 | uart.StartRx();
| ^~~~~~~
make: *** [build/uart.o] Error 1

My libDaisy install is recent - is this code building correctly for you?

Hey thank you for the reply!!

I believe my libDaisy is from a year ago and it’s building successfully. However, you are RIGHT about ‘startRX’. After commenting on that line with adding a couple of lines to ‘pollTX’, I was able to get the loopback test working!

On the Arduino side, I should have used this predefined instance named “Serial1” instead of Serial. Now everything works. wohooo!

Thank you so much for your help!

1 Like

Excellent - I still haven’t gotten loopback working correctly here - though I did receive one character.

If it helps, here’s my code for sending an increasing int and it works in the loopback setting.

#include "daisy_seed.h"
using namespace daisy;
DaisySeed hw;
int main(void)
{
    hw.Configure();
    hw.Init();
    hw.StartLog(false);
    System::Delay(3000);
    hw.PrintLine("Starting Read-test");
    UartHandler         uart;
    UartHandler::Config config;
    config.baudrate = 9600 ;
     config.periph   = UartHandler::Config::Peripheral::USART_1;
    config.stopbits      = UartHandler::Config::StopBits::BITS_1;
    config.parity        = UartHandler::Config::Parity::NONE;
    config.mode          = UartHandler::Config::Mode::TX_RX;
    config.wordlength    = UartHandler::Config::WordLength::BITS_8;
    config.pin_config.rx = {DSY_GPIOB, 7};  // (USART_1 RX) Daisy pin 15
    config.pin_config.tx = {DSY_GPIOB, 6};  // (USART_1 TX) Daisy pin 14

    uart.Init(config);
    
    

uint8_t tx = 0;
uint8_t mybuffer = 0;
    for(;;)
    {
        
        uart.BlockingTransmit(&tx, 1, 1000);
        tx++;
        
        uart.BlockingReceive(&mybuffer,1,1000);
        hw.PrintLine("%d", mybuffer);

        System::Delay(1000);
        

    }
}

Works for one byte send/receive. Haven’t got it working for strings yet.