Quick summary, details below: Im connecting my Uno to my Android phone and sending some data over serial. This was working fine for a while and suddenly it stopped working.
Details: I am building a device that will be part of the dashboard on my electric boat. It will tell me voltage, battery %, amp draw, etc. The Arduino (Uno) will sit inside the console and sample the electronics and relay data to my Android phone. In fact, most of this was all working well... until this afternoon. The arduino sketch is quite simple. Voltage divider into an analog input gives me my voltage reading. I've got a acs758ecb-200u for current sensing, a few calculations on the voltage range gives me battery %, and Peukert's Law to give an estimated battery time remaining. All of this gets sent over serial to be parsed on the Android side. In the Android app, I make a bluetooth connection, then grab the incoming serial communication and parse out the data. Pretty simple stuff. All of this was working (except the current sensor which just needs calibration) until this afternoon when it suddenly stopped. I am baffled as to what has happened.
Here's what happens now. I start up the Arduino and the Android app, pick the device, and tell it to connect. The bluetooth module changes from flashing to solid LED indicating a good connection. The Android app agrees. Here's where it all comes crashing down. The mBtInStream.read(buffer) call in the Android app just hangs. No data ever comes. Unplugging the bluetooth module and connecting the arduino via usb (to the computer) shows that the serial data is working. It prints out just fine in the serial monitor. So I then assume there is something wrong with the bluetooth module. Fine, I have another. I wire up the backup. Same result. Ok then, the problem must be somewhere between the bluetooth module and the ATmega328 (in the Uno board somewhere) right? That's fine too, I'll connect the rx/tx lines from the bluetooth module directly to the chip itself. Same result. Ok then, something is wrong with the ATmega328. No problem. I have a backup. I replace the chip, flash the sketch. Same result. What the hell.
I feel like I've exhausted all avenues.
- The sketch works fine. I verified that the serial monitor shows good output.
- The problem is not likely to be in the bluetooth module. I have a backup.
- The problem is not likely to be in the ATmega328. I have a backup.
- The problem is not likely to be in the Uno board itself. I tried wiring it directly to the chip.
- Nothing has changed. I've verified the connections 100 times.
Can anyone think of something else I can do? Where could the problem be?