How to set RX and TX pins?
Closed this issue · 4 comments
I have a different board. My rx and tx pins are 18 and 19. How do I set them on init?
I expected something like this would work in setup{};
myDevice.setSensorDistance(&sensorDistance);
myDevice.init(18,19)
Hi,
Currently specifying pins for RX/TX is not required since I simply use the global Serial/Serial1 object defined from the core framework of your mcu.
Lines 25 to 31 in b36895a
Note that Software Serial with custom pins is not supported for now.
Ah ok. I was hoping for software serial on esp32 custom pins. I'm not familiar enough with Arduino/c++ to add myself. I will look for another library instead.
Ok, it should be straigthforward™ to declare your Software Serial object in global.h
If you are using https://github.com/plerup/espsoftwareserial/ (the first softwareserial lib I found in google for ESP).
Something like that:
#include <SoftwareSerial.h>
...
#if defined(ESP8266) || defined(ESP32) // Check these flags I'm not 100% sure
#define MYPORT_TX 12
#define MYPORT_RX 13
EspSoftwareSerial::UART myPort;
#define SerialTTL myPort
#elif defined(ARDUINO_AVR_PROMICRO)
...
And you have to rewrite occurrences of SerialTTL.begin
in the project (https://github.com/search?q=repo%3Aysard%2FMyOwnBricks%20SerialTTL.begin&type=code) with something like that:
#if defined(ESP8266) || defined(ESP32)
SerialTTL.begin(<baudrate>, SWSERIAL_8N1, MYPORT_RX, MYPORT_TX, false);
#else
SerialTTL.begin(<baudrate>);
#endif
Let me know how it goes.
EDIT: Modifications of SerialTTL.begin
added.
Thanks for your help! We still couldn't get it to work. Ultimately we solved it differently. Our code is here: https://github.com/ste7anste7an/bluepad32_arduino