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

Does this work with esp32? #86

Open
camo200sx opened this issue Feb 27, 2022 · 4 comments
Open

Does this work with esp32? #86

camo200sx opened this issue Feb 27, 2022 · 4 comments
Assignees

Comments

@camo200sx
Copy link

I get an error when using the tx/rx datum examples of

ERROR: STALE PACKET

regards

@felipe-mello
Copy link

felipe-mello commented Feb 27, 2022

Hello! I've just used this library to communicate between an ESP 32 and a Teensy 4.0 and I had no problems whatsoever.

One thing I noticed, though, is that if you send a lot of data in a small amount of time, some is lost. For my application, I only need about 10 transactions per second and It's been working fine.

Unfortunately, I am still a beginner with the library, so I don't know exactly what could be causing your error. If I must do an educated guess, I would say that there's a sync problem between your boards (must be that you're trying to send a lot of data at once, or the baud rates are not set correctly). Without the actual code, is kind of difficult to actually know what's going on.

Best

@felipe-mello
Copy link

felipe-mello commented Feb 27, 2022

Quick update: I also got the STALE PACKET error here. Turns out it was just a bad connection. I moved the cables a little bit and everything started to work again... I guess checking your connections could also be a way to go.

@PowerBroker2 PowerBroker2 self-assigned this Feb 28, 2022
@PowerBroker2
Copy link
Owner

PowerBroker2 commented Feb 28, 2022

It does work with the ESP32, try using struct __attribute__((packed)) when creating structs to transfer

@camo200sx
Copy link
Author

Hmmm thanks for the help and suggestions.

So I have further tested it. I was trying to get it going using HC-12 modules as they talk in serial but got the stale packet. Also tried with the esp's connected direct, same deal. I then changed the baud rate and it appears it is working @ 4800. I was originally using 1200 as this allows the HC12 to work at the longest possible range (which I need). I'm yet to try the HC-12 at above 1200 yet but direct serial connection is good at 4800

This then leads me to the question. Can it be done at 1200?

I have tried using __attribute__((__packed__)) but no dice @ 1200. I'm quite the noob so unsure if using that correctly. Will post my code :)

SEND

#include <Arduino.h>
#include <Wire.h>
#include "SerialTransfer.h"

SerialTransfer myTransfer;

struct __attribute__((__packed__)) STRUCT
{
  char z;
  float y;
} testStruct;

void setup()
{
  Serial.begin(4800);
  Serial2.begin(4800);
  myTransfer.begin(Serial2);

  testStruct.z = '$';
  testStruct.y = 4.5;
}

void loop()
{
  myTransfer.sendDatum(testStruct);
  delay(500);
}

RECEIVE

#include <Arduino.h>
#include <Wire.h>
#include "SerialTransfer.h"


SerialTransfer myTransfer;

struct __attribute__((__packed__)) STRUCT {
  char z;
  float y;
} testStruct;


void setup()
{
  Serial.begin(4800);
  Serial2.begin(4800);
  myTransfer.begin(Serial2);
}


void loop()
{
  if(myTransfer.available())
  {
    myTransfer.rxObj(testStruct);
    Serial.print(testStruct.z);
    Serial.println(testStruct.y);
  }
}

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

3 participants