Hi, I have a simple project to read and write data over bluetooth using a bluetooth shield.
Yesterday I ran a program which simply wrote "test". I can read this in via Visual Studio on a different laptop.
Today I started working on the actual project, but when I try to send something new over bluetooth, Visual Studio still reads "test" when I clearly put something else.
This is demo code to demonstrate my issue.
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(8, 9);
void setup() {
bluetooth.begin(9600);
}
void loop() {
bluetooth.println("Hi");
}
Now when I make a new file and upload it, but with "Hi" changed to "Hello" VS still reads "Hi". How is this possible? Does a bluetooth shield save cache? If so, can I reset it?
UsernameAlreadyExists123:
How is this possible?
It isn't, and Bluetooth does not save data. I guess there are two possibilities:
either you are not uploading the new programme, you just think you are,
or you are not showing the data from the new programme, you just think you are.
This is probably not a Bluetooth problem, you just think it is, but Bluetooth is innocent.
There is nothing wrong with the code for one-way but, for a basic read<>write with Bluetooth, you might find the following background notes useful.
http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino
Nick_Pyner:
It isn't, and Bluetooth does not save data. I guess there are two possibilities:
either you are not uploading the new programme, you just think you are,
or you are not showing the data from the new programme, you just think you are.
This is probably not a Bluetooth problem, you just think it is, but Bluetooth is innocent.
There is nothing wrong with the code for one-way but, for a basic read<>write with Bluetooth, you might find the following background notes useful.
http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino
Thanks a lot for your comment. I have just found the reason why this is happening. My code is fine, but because my bluetooth.println() is in a loop without any delay, it keeps sending near instantly. And bluetooth.readline() keeps all incoming data in a 'waiting line'. So I'm first doing bluetooth.println("Hi"). It will send it lets say 100 times before I upload the new project with bluetooth.println("Hello"). My VS code (which reads incoming bluetooth every second because I'm using a delay later in the code) will first want to show the 100 Hi's before showing the "Hello" (even after a disconnect). Which means I had to wait 100 seconds before the "Hello" would show.
From that I understand all your problems are at the other end. I was going to suggest putting a delay in, but I didn't think it actually mattered.