Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ESP32 Nano boards #54

Open
matthewmcneill opened this issue Aug 10, 2024 · 1 comment
Open

Support for ESP32 Nano boards #54

matthewmcneill opened this issue Aug 10, 2024 · 1 comment

Comments

@matthewmcneill
Copy link

This is relatively simple, just need to add the correct architecture pins for the Hardware Serial1 to the architectures in RS432.h

I'm not sure you want the default TX pin to be 1 however, so you may need to change that too.

#elif defined(ARDUINO_ARCH_ESP32)
#define SERIAL_PORT_HARDWARE Serial1
#define RS485_DEFAULT_DE_PIN 8
#define RS485_DEFAULT_RE_PIN 7
#define RS485_DEFAULT_TX_PIN 2

Without this change the library complains about the SERIAL_PORT_HARDWARE macro not being defined upon compilation

@matthewmcneill
Copy link
Author

Alternatively a more future-proof way is to change the declaration of the global variable at the bottom of the .cpp only to create it if these are properly defined - forcing the user to manually declare RS458 with their own configs.

#ifdef RS485_SERIAL_PORT
RS485Class RS485(RS485_SERIAL_PORT, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
#elif SERIAL_PORT_HARDWARE
RS485Class RS485(SERIAL_PORT_HARDWARE, RS485_DEFAULT_TX_PIN, RS485_DEFAULT_DE_PIN, RS485_DEFAULT_RE_PIN);
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant