-
Notifications
You must be signed in to change notification settings - Fork 96
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
Serial and SoftwareSerial port comments #203
Conversation
docs/TheThingsNetwork.md
Outdated
|
||
# Comments | ||
## Serial ports (Stream objects) | ||
The Stream objects (Serial ports) need to be initialized at the correct baud rates at the start of your `setup()` function. See [our examples](https://github.com/TheThingsNetwork/arduino-device-lib/blob/asian-frequency-plans/examples) for more details. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we really start with the definition of the serials, so explain a bit about the hardware serial(s) and potential software serials?
docs/TheThingsNetwork.md
Outdated
} | ||
``` | ||
|
||
### SodaqOne |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SODAQ One
docs/TheThingsNetwork.md
Outdated
``` | ||
|
||
### TheThingsUno | ||
At the top of your sketch use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or any Leonardo with RX/TX connected to the RN module
docs/TheThingsNetwork.md
Outdated
} | ||
``` | ||
|
||
SoftwareSerial does not operate correctly at high baud rates. We normally use it at 9600 baud. Because the RN2483 and RN2903 normally operates at 57600 baud, we need to switch it to 9600 baud so that we can communicate with it using 9600 baud. Luckily this is done automatically inside TheThingsNetwork Arduino library, so you as user do not have to worry about this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the autobaud feature really strong enough to handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another tip is to use AltSoftSerial
; which determines for you which RX/TX pins you can use, but it's reliable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to stick to standard libraries, and therefore the SoftwareSerial library that comes with Arduino. AltSoftSerial has the side effect that it can cause interference with your own program when you use timers and interrupts. On a normal Arduino you should be able to use SoftwareSerial on all pins.
The autobaud() function is based on the version in my library. That one is quite stable. We can however test this one a bit better. I'll see if I can find an Arduino and RN2483 to test with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to stick to standard libraries, but better not use them when you know they're not reliable in certain cases. AltSoftSerial is required when you want to use other (software) serial on The Things Uno, that's definitely not stable with standard libraries.
The autobaud is stable but I'm not sure if it really sets the RN module to any baud rate you want, or it merely syncs the serial interface timing so that it doesn't get corrupted on first transmissions.
Maybe the description of the Serial ports belongs better in https://github.com/TheThingsNetwork/docs/edit/master/_content/devices/arduino/usage.md than in the API reference. Should I move it? I should also add a comment about a level shifter and/or voltage levels (3.3V vs 5V) for when someone builds their own device. |
Yes indeed |
Added a description of the Stream parameters passed to TheThingsNetwork library. Elaborate about Software Serial and serial on other devices.