Motor Controller with new Nano IOT

I am wondering how I can get my Nano 33 IOT to use this motor controller, which is used with this driver.

I know the 33 IOT doesn't have a SoftwareSerial equivalent, but the motor driver uses SoftwareSerial.

Is there any workaround that will allow me to use the 33 IOT with this motor controller? For context, I built a robot using the older Nano that supported SoftwareSerial and am wanting to switch out the Nano, but keep everything else.

The Nano 33 IOT has 2 Serial ports

Serial1 is connected to pins 0 and 1, so you can use them instead of SoftwareSerial

Post your code for more help

Ok so I've attached my code here. Basically, I connected the logic pins on the motor controller to D0 and D1 on the Nano 33 IOT.

However, the serial communication doesn't seem to be working, because if I read from the connection (mySerial) or ask how many bytes are available to read, I get -1 (no data on serial) or 0 (no bytes to read) when I should be receiving a response from the board.

I know my board isn't dead because it works with the older Nano (using SoftwareSerial).

I also get the same results if I don't explicitly define the Serial UART and just use Serial1.

#include <Arduino.h>
#include "wiring_private.h"

Uart mySerial (&sercom0, 0, 1, SERCOM_RX_PAD_1, UART_TX_PAD_0);

//###################################################################
void setup() {
  // Reassign pins 0 and 1 to SERCOM alt
  pinPeripheral(0, PIO_SERCOM_ALT);
  pinPeripheral(1, PIO_SERCOM_ALT);

  // Start my new hardware serial
  // reset the qik
  digitalWrite(4, LOW);
  pinMode(4, OUTPUT); // drive low
  delay(1);
  pinMode(4, INPUT); // return to high-impedance input (reset is internally pulled up on qik)
  delay(10);

  mySerial.begin(9600);
  // Initialization command
  mySerial.write(0xAA);

  Serial.begin(9600);
  while (!Serial);
  Serial.println("Started");
}


//###################################################################
void loop() {
  if (mySerial.available()) {
    Serial.println(mySerial.read());
  }

  // Command to get firmware version
  mySerial.write(0x81);
  Serial.println(mySerial.available());
  Serial.println(mySerial.read());

  delay(1000);
}


//###################################################################
// Attach the interrupt handler to the SERCOM
void SERCOM0_Handler()
{
  mySerial.IrqHandler();
}

If I were you I would stick to the much simpler Serial1 syntax

Are you sure that you have got the Serial1 interface connected correctly, ie pin 1 is Tx and pin 0 is Rx

1 Like

Thank you! I had the RX and TX pins switched. All the other sources I found had the opposite.

That's good news

Good luck with your project

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.