ESP32 ODrive communication [SOLVED]

I have been trying for a week to get an ESP32 working with odrive. I saw it does work here

I am using the example in ODriveArduino library.
I got it to work very easily with the Arduino Uno.
Once I set the board to “Esp32 Dev Module” (or any esp32) I get errors.

Multiple libraries were found for "SoftwareSerial.h"
 Used: C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial
Multiple libraries were found for "ODriveArduino.h"
 Used: C:\Users\<user>\Documents\Arduino\libraries\ODriveArduino
exit status 1 

If I prune through any libs that would have SoftwareSerial.h I end up getting errors that there is no override for how the example calls the code.

I tried modifying the libraries to have working constructors and the code will compile, but nothing can communicate with the ODrive board.

I have tried using different pins, looked through the source and can see which pins are allowed. I am connecting them into pins 1 and 2 of the ODrive board along with the GND of both boards together.

All help greatly appreciated.

Make sure your ESP32 works with other Arduino examples, like the SoftwareSerial example, first. Those errors are pretty clearly on the Arduino side.

I wrote a very simple blink script and as soon as I add
#define <SoftwareSerial.h>
I get errors: It actually looks like somehow the board settings are not setting some values or the libs are not prepared for board definitions. I am pretty new to arduino and esp32 so not sure how this part works.

Below is a simple blink example code and errors below.

----[ ESP32_ODrive_Test01.ino ]-----

#include <SoftwareSerial.h>
#include <ODriveArduino.h>

// Serial to the ODrive
//SoftwareSerial odrive_serial(8, 9); //RX (ODrive TX), TX (ODrive RX)
// Note: you must also connect GND on ODrive to GND on Arduino!

// ODrive object
//ODriveArduino odrive(odrive_serial);

// use first channel of 16 channels (started from zero)
#define LEDC_CHANNEL_0      0

// use 13 bit precission for LEDC timer
#define LEDC_TIMER_13_BIT   13
#define LED_MAX             8191

// use 5000 Hz as a LEDC base frequency
#define LEDC_BASE_FREQ      5000

// LED PIN (replace with LED_BUILTIN constant for built-in LED)
#define LED_PIN             2

// Globals
unsigned long   t0        = micros();
unsigned long   tSwitch   = 1000000;
bool            onOff     = false;


void setup() {

  // Serial to PC
  Serial.begin(115200);
  while (!Serial) ; // wait for Arduino Serial Monitor to open

  Serial.println("Setup: Init...");
  
  // Setup timer and attach timer to a led pin
  Serial.println("Setup Led/PWM/Timer ...");
  ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_TIMER_13_BIT);
  ledcAttachPin(LED_PIN, LEDC_CHANNEL_0);
  
  //Serial.println("ODriveArduino");

  Serial.println("Setup: Starting Blink Sequence ...");
  // Blink 3x in setup to make sure it works
  for(int i=0;i<3;++i){
    Serial.println((String) "Setup: Flashing: [" + i + "]  time: " + micros());
    ledcWrite(LEDC_CHANNEL_0,LED_MAX);
      delay(250);
    ledcWrite(LEDC_CHANNEL_0,0);
      delay(250);
   }
  Serial.println("...Setup: Complete");
}
void loop() {
  static unsigned long ledModifyCount = 0;
  
    if( (micros()-t0) > tSwitch){
      t0 = micros();
      onOff = !onOff;
      ledcWrite(LEDC_CHANNEL_0,LED_MAX*onOff); 
      Serial.println((String) "Loop: [" + ledModifyCount + "]  time: " + micros());
    }
    
}

-----------[ Errors: ]---------

Arduino: 1.8.10 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/interrupt.h:38:0,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:41:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/io.h:541:6: warning: #warning "device type not defined" [-Wcpp]

 #    warning "device type not defined"

      ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:76:0: warning: "sei" redefined

 #define sei()

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:41:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/interrupt.h:81:0: note: this is the location of the previous definition

 # define sei()  __asm__ __volatile__ ("sei" ::: "memory")

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:77:0: warning: "cli" redefined

 #define cli()

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:41:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/interrupt.h:99:0: note: this is the location of the previous definition

 # define cli()  __asm__ __volatile__ ("cli" ::: "memory")

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:99:0: warning: "_BV" redefined

 #define _BV(b) (1UL << (b))

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/io.h:99:0,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/interrupt.h:38,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:41:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/sfr_defs.h:208:0: note: this is the location of the previous definition

 #define _BV(bit) (1 << (bit))

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:32:0: warning: "PROGMEM" redefined

 #define PROGMEM

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:109:0: note: this is the location of the previous definition

 #define PROGMEM __ATTR_PROGMEM__

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:35:0: warning: "PSTR" redefined

 #define PSTR(s)       (s)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:404:0: note: this is the location of the previous definition

 # define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:36:0: warning: "_SFR_BYTE" redefined

 #define _SFR_BYTE(n)  (n)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/io.h:99:0,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/interrupt.h:38,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:41:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/sfr_defs.h:190:0: note: this is the location of the previous definition

 #define _SFR_BYTE(sfr) _MMIO_BYTE(_SFR_ADDR(sfr))

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:38:0: warning: "pgm_read_byte" redefined

 #define pgm_read_byte(addr)   (*(const unsigned char *)(addr))

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:973:0: note: this is the location of the previous definition

 #define pgm_read_byte(address_short)    pgm_read_byte_near(address_short)

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:39:0: warning: "pgm_read_word" redefined

 #define pgm_read_word(addr) ({ \

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:982:0: note: this is the location of the previous definition

 #define pgm_read_word(address_short)    pgm_read_word_near(address_short)

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:43:0: warning: "pgm_read_dword" redefined

 #define pgm_read_dword(addr) ({ \

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:991:0: note: this is the location of the previous definition

 #define pgm_read_dword(address_short)   pgm_read_dword_near(address_short)

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:47:0: warning: "pgm_read_float" redefined

 #define pgm_read_float(addr) ({ \

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1000:0: note: this is the location of the previous definition

 #define pgm_read_float(address_short)   pgm_read_float_near(address_short)

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:51:0: warning: "pgm_read_ptr" redefined

 #define pgm_read_ptr(addr) ({ \

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1009:0: note: this is the location of the previous definition

 #define pgm_read_ptr(address_short)     pgm_read_ptr_near(address_short)

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:56:0: warning: "pgm_read_byte_near" redefined

 #define pgm_read_byte_near(addr)  pgm_read_byte(addr)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:565:0: note: this is the location of the previous definition

 #define pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short))

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:57:0: warning: "pgm_read_word_near" redefined

 #define pgm_read_word_near(addr)  pgm_read_word(addr)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:573:0: note: this is the location of the previous definition

 #define pgm_read_word_near(address_short) __LPM_word((uint16_t)(address_short))

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:58:0: warning: "pgm_read_dword_near" redefined

 #define pgm_read_dword_near(addr) pgm_read_dword(addr)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:581:0: note: this is the location of the previous definition

 #define pgm_read_dword_near(address_short) \

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:59:0: warning: "pgm_read_float_near" redefined

 #define pgm_read_float_near(addr) pgm_read_float(addr)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:590:0: note: this is the location of the previous definition

 #define pgm_read_float_near(address_short) \

 ^

In file included from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/WString.h:29:0,

                 from C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:146,

                 from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/pgmspace.h:60:0: warning: "pgm_read_ptr_near" redefined

 #define pgm_read_ptr_near(addr)   pgm_read_ptr(addr)

 ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:599:0: note: this is the location of the previous definition

 #define pgm_read_ptr_near(address_short) \

 ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:288:2: error: #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

 #error This version of SoftwareSerial supports only 20, 16 and 8MHz processors

  ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:42:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1094:26: warning: 'strlen_PF' initialized and declared 'extern'

 extern size_t strlen_PF (uint_farptr_t src) __ATTR_CONST__; /* program memory can't change */

                          ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1094:26: error: 'uint_farptr_t' was not declared in this scope

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:91:49: warning: attributes after parenthesized initializer ignored [-Wattributes]

 #define __ATTR_CONST__ __attribute__((__const__))

                                                 ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1094:45: note: in expansion of macro '__ATTR_CONST__'

 extern size_t strlen_PF (uint_farptr_t src) __ATTR_CONST__; /* program memory can't change */

                                             ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1095:27: warning: 'strnlen_PF' initialized and declared 'extern'

 extern size_t strnlen_PF (uint_farptr_t src, size_t len) __ATTR_CONST__; /* program memory can't change */

                           ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1095:27: error: 'uint_farptr_t' was not declared in this scope

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1095:53: error: expected primary-expression before 'len'

 extern size_t strnlen_PF (uint_farptr_t src, size_t len) __ATTR_CONST__; /* program memory can't change */

                                                     ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:91:49: warning: attributes after parenthesized initializer ignored [-Wattributes]

 #define __ATTR_CONST__ __attribute__((__const__))

                                                 ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1095:58: note: in expansion of macro '__ATTR_CONST__'

 extern size_t strnlen_PF (uint_farptr_t src, size_t len) __ATTR_CONST__; /* program memory can't change */

                                                          ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:91:49: error: expression list treated as compound expression in initializer [-fpermissive]

 #define __ATTR_CONST__ __attribute__((__const__))

                                                 ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1095:58: note: in expansion of macro '__ATTR_CONST__'

 extern size_t strnlen_PF (uint_farptr_t src, size_t len) __ATTR_CONST__; /* program memory can't change */

                                                          ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1096:37: error: 'uint_farptr_t' has not been declared

 extern void *memcpy_PF (void *dest, uint_farptr_t src, size_t len);

                                     ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1097:37: error: 'uint_farptr_t' has not been declared

 extern char *strcpy_PF (char *dest, uint_farptr_t src);

                                     ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1098:38: error: 'uint_farptr_t' has not been declared

 extern char *strncpy_PF (char *dest, uint_farptr_t src, size_t len);

                                      ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1099:37: error: 'uint_farptr_t' has not been declared

 extern char *strcat_PF (char *dest, uint_farptr_t src);

                                     ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1100:38: error: 'uint_farptr_t' has not been declared

 extern size_t strlcat_PF (char *dst, uint_farptr_t src, size_t siz);

                                      ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1101:38: error: 'uint_farptr_t' has not been declared

 extern char *strncat_PF (char *dest, uint_farptr_t src, size_t len);

                                      ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1102:39: error: 'uint_farptr_t' has not been declared

 extern int strcmp_PF (const char *s1, uint_farptr_t s2) __ATTR_PURE__;

                                       ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1103:40: error: 'uint_farptr_t' has not been declared

 extern int strncmp_PF (const char *s1, uint_farptr_t s2, size_t n) __ATTR_PURE__;

                                        ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1104:43: error: 'uint_farptr_t' has not been declared

 extern int strcasecmp_PF (const char *s1, uint_farptr_t s2) __ATTR_PURE__;

                                           ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1105:44: error: 'uint_farptr_t' has not been declared

 extern int strncasecmp_PF (const char *s1, uint_farptr_t s2, size_t n) __ATTR_PURE__;

                                            ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1106:41: error: 'uint_farptr_t' has not been declared

 extern char *strstr_PF (const char *s1, uint_farptr_t s2);

                                         ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1107:38: error: 'uint_farptr_t' has not been declared

 extern size_t strlcpy_PF (char *dst, uint_farptr_t src, size_t siz);

                                      ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial/avr/pgmspace.h:1108:36: error: 'uint_farptr_t' has not been declared

 extern int memcmp_PF(const void *, uint_farptr_t, size_t) __ATTR_PURE__;

                                    ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setTX(uint8_t)':

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:521:25: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment

   _transmitPortRegister = portOutputRegister(port);

                         ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::setRX(uint8_t)':

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:532:24: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment

   _receivePortRegister = portInputRegister(port);

                        ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:543:31: error: 'table' was not declared in this scope

   for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)

                               ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:559:38: error: 'digitalPinToPCICR' was not declared in this scope

     if (digitalPinToPCICR(_receivePin))

                                      ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:561:78: error: 'digitalPinToPCICRbit' was not declared in this scope

       *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));

                                                                              ^

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:99:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:562:37: error: 'digitalPinToPCMSK' was not declared in this scope

       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));

                                     ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:562:78: error: 'digitalPinToPCMSKbit' was not declared in this scope

       *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));

                                                                              ^

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:99:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:577:36: error: 'digitalPinToPCMSK' was not declared in this scope

   if (digitalPinToPCMSK(_receivePin))

                                    ^

In file included from C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:43:0:

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:578:77: error: 'digitalPinToPCMSKbit' was not declared in this scope

     *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));

                                                                             ^

C:\Users\<user>\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32/Arduino.h:99:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'virtual size_t SoftwareSerial::write(uint8_t)':

C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp:618:26: error: 'XMIT_START_ADJUSTMENT' was not declared in this scope

   tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);

                          ^

Multiple libraries were found for "ODriveArduino.h"
 Used: C:\Users\<user>\Documents\Arduino\libraries\ODriveArduino
Multiple libraries were found for "SoftwareSerial.h"
 Used: C:\Users\<user>\Documents\Arduino\libraries\SoftwareSerial
exit status 1
Error compiling for board ESP32 Dev Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

------[ Board Settings (arduino IDE) ]-------

You don’t have to use SoftwareSerial at all.
ESP32 has 3 builtin Serials UART[0-2]

I used HardwareSerial::Serial1 with PINS 16 & 17 on ESP32

PIN | ESP32 | ODrive
 RX |    16 |  2
 TX |    17 |  1
GND |   GND | GND

** Now it looks like we need to get the ODriveArduino libs up to par. Missing a lot of functionality :slight_smile:

Sample Program

/*
 * We are going to use the ESP32 extra serial communication from HardwareSerial
 * ** https://hackaday.com/2017/08/17/secret-serial-port-for-arduinoesp32/
 * ** https://youtu.be/GwShqW39jlE
 * 
 * Much of the code is from the Example file in ODriveArduino Examples: ODriveArduinoTest
 */

#include <ODriveArduino.h>

// ## I have not tried it yet, but if you need another serial: UART1, redefine pins (see video link above)
#define ESP32_UART2_PIN_TX 17
#define ESP32_UART2_PIN_RX 16

// ODrive uses 115200 baud
#define BAUDRATE 115200

// Printing with stream operator
template<class T> inline Print& operator <<(Print &obj,     T arg) { obj.print(arg);    return obj; }
template<>        inline Print& operator <<(Print &obj, float arg) { obj.print(arg, 4); return obj; }


// ODrive object //HardwareSerial Serial1;
ODriveArduino odrive(Serial1);

float vel_limit = 22000.0f;
float current_lim = 11.0f;

void setup() {
  
  // Serial to PC
  Serial.begin(BAUDRATE);
  
  // Serial to the ODrive //UART HWSerial 1 Setup
  // Note: you must also connect GND on ODrive to GND on ESP32!
  Serial1.begin(BAUDRATE, SERIAL_8N1, ESP32_UART2_PIN_TX, ESP32_UART2_PIN_RX);
  // ## You should be able to setup another serial for more motors

  
  while (!Serial) ;  // wait for Arduino Serial 0 Monitor to open
  Serial.println("Serial 0 Ready...");
  while (!Serial1) ; // wait for Arduino Serial 1 
  Serial.println("Serial 1 Ready...");
  // ## You should be able to setup another serial for more motors
  

//  ODriveArduino odrive(Serial1);
// Set current and velocity defaults
  for (int axis = 0; axis < 2; ++axis) {
    Serial1 << "w axis" << axis << ".controller.config.vel_limit " << vel_limit << '\n';
    Serial1 << "w axis" << axis << ".motor.config.current_lim " << current_lim << '\n';
  }

// Some serial out documentation
  Serial.println("Ready!");
  Serial.println("Send the character '0' or '1' to calibrate respective motor (you must do this before you can command movement)");
  Serial.println("Send the character 's' to exectue test move");
  Serial.println("Send the character 'b' to read bus voltage");
  Serial.println("Send the character 'p' to read motor positions in a 10s loop");
  Serial.println("Send the character 'c'(-) or 'C'(+) to raise and lower the current_limit (+- 5)");
  Serial.println("Send the character 'v'(-) or 'V'(+) to raise and lower the velocity_limit (+- 50000)");
  Serial.println("Send the character 'x'(-) or 'X'(+) to switch back and forth to position (+- 5000)");
}

// This is the same as the ODriveArduinoTest
void loop() {

  if (Serial.available()) {
    char c = Serial.read();
    Serial.println((String)" Serial.Read(): " + c  );
    
    // Run calibration sequence
    if (c == '0' || c == '1') {
      int motornum = 0;
      if(c=='1') motornum = 1;
      int requested_state;

      requested_state = ODriveArduino::AXIS_STATE_MOTOR_CALIBRATION;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, true);

      requested_state = ODriveArduino::AXIS_STATE_ENCODER_OFFSET_CALIBRATION;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, true);

      requested_state = ODriveArduino::AXIS_STATE_CLOSED_LOOP_CONTROL;
      Serial << "Axis" << c << ": Requesting state " << requested_state << '\n';
      odrive.run_state(motornum, requested_state, false); // don't wait
    }

   // Change Velocity incrementally
    if (c == 'V' || c == 'v'){
      float inc = 50000.0f;
      if(c=='v') inc *= -1;
      vel_limit += inc;
      Serial.println((String)"Velocity Limit: " + vel_limit);
      for (int axis = 0; axis < 2; ++axis) {
        Serial1 << "w axis" << axis << ".controller.config.vel_limit " << vel_limit << '\n';
      }
    }

   // Change Current incrementally
    if (c == 'C' || c == 'c'){
      float inc = 5.0f;
      if(c=='c') inc *= -1;
      current_lim += inc;
       Serial.println((String)"Current Limit: " + current_lim);
      for (int axis = 0; axis < 2; ++axis) {
        Serial1 << "w axis" << axis << ".motor.config.current_lim " << current_lim << '\n';
      }
    }
    
   // Change Positions: Flips position back and forth between + and - value
    if (c == 'X' || c == 'x'){
      int pos = 5000;
      if(c=='x') pos *= -1;
      Serial.println((String)"Position: " + pos);
        odrive.SetPosition(0, -pos);
        odrive.SetPosition(1, pos);
      
    }
    // Sinusoidal test move
    if (c == 's') {
      Serial.println("Executing test move");
      for (float ph = 0.0f; ph < 6.28318530718f; ph += 0.01f) {
        float pos_m0 = 20000.0f * cos(ph);
        float pos_m1 = 20000.0f * sin(ph);
        odrive.SetPosition(0, pos_m0);
        odrive.SetPosition(1, pos_m1);
        delay(5);
      }
    }

    // Read bus voltage
    if (c == 'b') {
      //odrive_serial << "r vbus_voltage\n";
      Serial1 << "r vbus_voltage\n";
      Serial << "Vbus voltage: " << odrive.readFloat() << '\n';
    }

    // print motor positions in a 10s loop
    if (c == 'p') {
      static const unsigned long duration = 10000;
      unsigned long start = millis();
      while(millis() - start < duration) {
        for (int motor = 0; motor < 2; ++motor) {
          //odrive_serial << "r axis" << motor << ".encoder.pos_estimate\n";
          Serial1 << "r axis" << motor << ".encoder.pos_estimate\n";
          Serial << odrive.readFloat() << '\t';
        }
        Serial << '\n';
      }
    }
  }
}
2 Likes

@ChrisR Thanks for sharing this, worked like a charm!

You are welcome, glad to see it helped somebody