EasyTransfer over Software Serial

Status
Not open for further replies.

gfvalvo

Well-known member
Hi all. I’m working on a project that will use both a Teensy 3.2 and Adafruit ESP8266 Huzzah. The ESP will provide the WiFi connection and user interface via BLYNK. The Teensy will run the main application using the Audio and FastLED libraries. The required inter-processor communication is pretty modest. I intend to use EasyTransfer to send small data structures back and forth when required.

To keep the Teensy’s Serial/USB interface free for debugging, I’ll use Serial3 for connection to the ESP. As far as I can tell, the ESP only has one hardware serial port and it connects to the CP2104 for USB use. Since I also want to keep that free for debugging, I’ll use SoftwareSerial on the ESP for communication with the Teensy.

So, finally, the question. Does EasyTranfer care about software verses hardware serial? Can I pass a pointer to a SoftwareSerial object to the begin() method of my EasyTransfer object just like I can pass a pointer to the Serial object? Seems I can as the source code shows it’s actually expecting a pointer to a Stream object. But, my grasp of C++ is tenuous at best, so thought I’d ask.

Thanks.
 
Probably the simplest answer is to try it...

That is I don't know enough about the ESP8266 and SoftwareSerial.

But I believe that at least on the Teensy SoftwareSerial is derived from the class Stream and EasyTransfer takes in a pointer to a Stream object, so in theory it should work.

But again I don't know how (if at all) Software Serial is implemented on the Adafruit product. On Teensy it mainly only works on hardware Serial pins...
 
EasyTransfer comes with 4 different versions. One of those 4 is specifically designed to use SoftwareSerial.

https://github.com/madsci1016/Arduino-EasyTransfer

Just use the copy from the "SoftEasyTransfer" folder.

I do not use the ESP chip, so I do not know if SoftwareSerial works. Perhaps you should ask this question on the ESP community forums?

On the Teensy side, of course use regular serial, since there are plenty of serial ports.
 
Also, beware old versions of EasyTransfer which used "int" instead of "int16_t". In the data structure you define, always use the types with the number of bits clearly defined. If you use "int" or other generic types, it will only work if the number of bits happens to be the same. Between Teensy and ESP this may not be a large issue, but it's best to always specify the number of bits so both sides are certain to use the same data size.
 
Thanks Paul. I’m definitely looking at the library version that uses the ‘unt16_t’ type variables.

I’ve also confirmed that SoftwareSerial works on the ESP8266. At least for the pins used in the ESP-specific library example. Those pins are OK with my application.

So, my only question left (for my own edification) is why the need to have a separate version of EasyTransfer for SoftwareSerial? Looking briefly at the source code, the major difference I see is in how the serial port is defined. In the Hardware version it’s a ‘Stream *’ and in the Software version it’s a ‘SoftwareSerial *’ or ‘NewSoftSerial *’. Here’s where my limited knowledge of C++ fails me, but I believe ‘SoftwareSerial’ is derived from the ‘Stream’ class.

I’ve confirmed that the following code works on the ESP, and it treats the ‘SoftwareSerial’ as a ‘Stream’:
Code:
#include <SoftwareSerial.h>

Stream *myStream;
SoftwareSerial softSerial(14, 12, false, 256);

void setup() {
  softSerial.begin(9600);
  myStream = &softSerial;
  myStream->println("Hello World");
}

void loop() {
  if (myStream->available()) {
    myStream->write(myStream->read());
  }
}
So, on the ESP anyway, it looks like the ‘Hardware’ version of EasyTransfer would work even with ‘SoftwareSerial’ ports. Maybe the reason for a separate software version is to support the older ‘NewSoftSerial’ type? Anyway, as first suggested, I’ll just try it.

Thanks again all.
 
Status
Not open for further replies.
Back
Top