Qwiic GPIO and Motor Driver with Arduino Wifi R4

Hello!

I’ve trouble finding the information about compatibility between Arduino Wifi R4 and some Qwiic devices. I’ve seen the guide about some of them used with this Arduino but not the ones I want to use :

  • Qwiic GPIO

  • Qwiic Motor Driver

I guess it should be okay for the hardware part, but the library could not be compatible with the architecture and the serial ports?

Thanks in advance for your help!

The good and the bad news…

First the good news :

You can use the Wire1 on the Qwicc GPIO. In your sketch

Change Wire.begin() to Wire1.begin()

Change myGPIO.begin() to myGPIO.begin(Wire1).

Now the bad news :

In the QWIIC motor driver library ‘Wire’ is hardcoded. That was common in the past (the library is from 2015)

You have to manually replace in the motor driver library file ‘SCMD.cpp’ all the references from Wire to Wire1. It might be that Sparkfun will create a new version, but until then this is a workaround.

Thank you very much for your answer, I’ll buy them and try that :grinning:

Hi!

I tried to modify the SCMD library by following your workaround, but I still have these errors at compilation (of the MotorTest example) :

/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp: In member function 'uint8_t SCMD::begin()':
/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp:106:7: error: 'class arduino::ArduinoSPI' has no member named 'setClockDivider'
   SPI.setClockDivider(SPI_CLOCK_DIV32);
       ^~~~~~~~~~~~~~~
/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp:106:23: error: 'SPI_CLOCK_DIV32' was not declared in this scope
   SPI.setClockDivider(SPI_CLOCK_DIV32);
                       ^~~~~~~~~~~~~~~
/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp:106:23: note: suggested alternative: 'AGT_CLOCK_P403'
   SPI.setClockDivider(SPI_CLOCK_DIV32);
                       ^~~~~~~~~~~~~~~
                       AGT_CLOCK_P403
/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp:108:7: error: 'class arduino::ArduinoSPI' has no member named 'setBitOrder'
   SPI.setBitOrder(MSBFIRST);
       ^~~~~~~~~~~
/Users/arthur/Documents/Arduino/libraries/Serial_Controlled_Motor_Driver/src/SCMD.cpp:111:7: error: 'class arduino::ArduinoSPI' has no member named 'setDataMode'
   SPI.setDataMode(SPI_MODE0);
       ^~~~~~~~~~~

exit status 1

Compilation error: exit status 1

I don’t want to use SPI, only I2C, maybe there is a way to remove this part of the library that seems to create the issue?

Thanks in advance for your help :slight_smile:

SCMD.cpp (16 KB)

MotorTest.txt (3.22 KB)

These are old SPI calls indeed. I have not removed the code but added a #define USE_SPI to exclude/include SPI

SCMD.cpp (16.2 KB)

Thank you very much, the code does compile!

I’ll test that with the devices when they arrived :slight_smile:

Everything is working!

Thank you again for the answers :slight_smile: