-
Notifications
You must be signed in to change notification settings - Fork 47
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
SoftwareSerial not transmitting on pin D7 #172
Comments
Please provide a bare-minimum sketch that isolates the issue. There's lots of code in your provided example that doesn't have anything to do with the issue I'm trying to isolate |
This bare minimum is working! #include <SoftwareSerial.h>
SoftwareSerial Bluetooth(7, 6);
void loop()
{
delay(1000);
Bluetooth.println("Test string to BT");
}
void setup()
{
Serial.begin(9600);
Bluetooth.begin(9600);
Serial.println("\n*********\nSerial started");
Bluetooth.println("test string to BT");
} |
It is wire.begin #include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(7, 6);
void loop()
{
delay(1000);
Bluetooth.println("Test string to BT");
}
void setup()
{
Serial.begin(9600);
Bluetooth.begin(9600);
// Wire.begin(); // <---- blocks pin 7 output
Serial.println("\n*********\nSerial started");
Bluetooth.println("test string to BT");
}
|
To be clear though, in none of the pinouts is there a sound reason for starting Wire in master mode to interfere with software serial, so there is absolutely a bug here - Your approach is inefficient and should be a last resort not a first resort - but it certainly should work, and I don't see any plausible route by which it would cause it to not work. I'd do a sanity check and blink a LED after starting wire... or maybe turn on after starting wire, then after begin()ing the softweare serial, delay for 100ms (to make sure you see the flash) and turn the LED off. If that passes, move that verification to when you're sending the first data. That way you confirm that execution is not getting hung up somewhere |
I made software for the ATMEGA 328 chip and later the Nano. All components are fitted on a PCB. So pin7 is fixed for TX to a Bluetooth module. |
@ednieuw thanks for providing a neat example and for tracing down the issue. There is indeed a bug in Wire.begin that specifically affects the Nano Every. It's this code right here. I'll look into it to figure out why this is causing issues. MegaCoreX/megaavr/libraries/Wire/src/utility/twi.c Lines 73 to 77 in a34d654
@SpenceKonde is absolutely right though. The Nano Every, when used with MegaCoreX has four(!) hardware serial port. This is obviously much better than having to deal with the limitations a software serial implementation has. But if you're using a Nano Every as a drop-in replacement in an older board where a classic Nano was previously used, your current pinout makes sense. |
by the wire library after running Wire.begin(). Resolves issue #172
I've just pushed a commit that resolved this issue. It will be available in the next MegaCoreX boards manager release. Meanwhile, you can run |
Top!Thanks for the quick solution!On 19 Feb 2023, at 18:56, Hans ***@***.***> wrote:
I've just pushed a commit that resolved this issue. It will be available in the next MegaCoreX boards manager release. Meanwhile, you can run Wire.begin() before bluetooth.begin() as a temporary workaround.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
When compiling with MegaCoreX for the Nano Every with Board4809
the string send to pinD7, connected to a Bluetooth HM-10 module with "SoftwareSerial", does not work.
When compiling with MegaAVR board the string is transmitted to the Bluetooth HM-10 module.
The text was updated successfully, but these errors were encountered: