My project,which included the LCD and a newly included BT module, wasn't passing Serial from the BT. After several hours, I isolated the problem to the LCD. To experiment, I created the following code. Prior to adding lcd.setCursor, the BT responded to AT and everything else. The moment I include lcd code, BT serial stops, requiring an Arduino restart after removing lcd calls to get it working again. I'm thinking it's an address conflict. I'd have to jump solder a couple pads on the LCD to change it. I don't know much about the BT module. LCD is connected to pin 12, BT is connected to 3(Rx) and 2(Tx) on a Nano. I've got the same issue with an Uno and using different pins. I wanted to run it by you guys before attempting to change the LCD address. The main project also uses an IR reference, but there was no issues with it as the test code below doesn't include it and it was physically disconnected for experimenting. I conducted these tests several times. The BT definitely hates the LCD.
#include <SoftwareSerial.h>
#include <LiquidCrystal_I2C.h>
#define IR_RECEIVE_PIN 12
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
SoftwareSerial mySerial(3, 2); // RX, TX
long BTBAUD=9600;
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(BTBAUD);
}
void loop() {
if (mySerial.available()==1){
Serial.write(mySerial.read());
lcd.setCursor(0, 0);
lcd.print("Serial");
}
if (Serial.available()==1){
mySerial.write(Serial.read());
lcd.setCursor(0, 0);
lcd.print("mySerial");
}
}