0

I need to use SoftwareSerial for a little board I made with an M5Stamp and a LoRa board. I also was planning to use Bluetooth, but it gives me a compilation error if I try to use both libraries. Couldn't find much help online.

C:\Path...\AppData\Local\Temp\arduino-sketch-C3A1C31318E964BF44FA1E35A7FE7344\libraries\espsoftwareserial-main\SoftwareSerial.cpp.o: in function std::function<void ()>::operator()() const': c:\Path...\arduino15\packages\m5stack\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch5\xtensa-esp32-elf\include\c++\8.4.0\bits/std_function.h:686:(.iram1.66[_ZNK8delegate6detail12DelegateImplIPvvEclEv]+0x24): dangerous relocation: l32r: literal placed after use: .literal._ZNK8delegate6detail12DelegateImplIPvvEclEv collect2.exe: error: ld returned 1 exit status

Basically, I just need SoftwareSerial on pins 21, 22 of the M5Stamp pico (which are connected to a LoRa board) to work with a Bluetooth library, so I could use my phone for serial data with the board. So any help to make these libraries work or another library recommendation would be appreciated.

I haven't tried much other than searching for answers online and checking out other Bluetooth libraries. But I could couldn't find another library that could send serial data.

This is my first question here.

#include <BluetoothSerial.h>
#include <SoftwareSerial.h>
SoftwareSerial radio(21, 22); //rx, tx
BluetoothSerial SerialBT;
dda
  • 6,030
  • 2
  • 25
  • 34
Roman
  • 124
  • 6
  • The ESP32 has three hardware UARTs (serial ports), is there a reason you're using `SoftwareSerial` instead of `Serial1` or `Serial2`? – romkey Feb 09 '23 at 16:32
  • 1
    2 reasons: because of the way the m5stamp and lora board fit on the protoboard, pins 21 and 22 are right beside the serial pins of the lora board. Also,the pinout for m5stamp only shows 1 hardware serial which I use for programming the board and need it separate. But, I also went searching on google again and found that you can use any pins as hardware serial apparently and I can use Serial2. And I just tried it and it compiled. So thats awesome. I never seen that as an option before. I'll see if the code works and will close this. Thanks for the tip. – Roman Feb 09 '23 at 17:02
  • Good going, I love seeing people figure stuff out! Glad you got it working. – romkey Feb 10 '23 at 00:30

2 Answers2

1

Here is the answer I found online for the m5stamp. No serial library was needed after all:

for UART you should be able to use any available GPIO for RX and TX like this:

Serial2.begin(115200, SERIAL_8N1, <RX>, <TX>);

for I2C you should be able to use any available GPIO for SDA and SCL like this:

Wire.begin(<SDA>, <SCL>);

Roman
  • 124
  • 6
0

The error per se is that there isn't enough Flash memory for everything and the compiler is complaining about this. So by removing the SoftwareSerial library – which was not needed anyway – you probably got enough Flash space for your code.

dda
  • 6,030
  • 2
  • 25
  • 34
  • It throws the same error if I compile for the m5stack core2 which has 16mb of flash vs the m5stamp pico with 4mb. So if that was the case and if each library compiles fine for 4mb of flash, then they both would fit into 8mb and diffidently have no problem compiling for 16mb. Also, the Arduino IDE has warnings for running out of flash storage if it happens. – Roman Feb 12 '23 at 21:31