Pages: [1]   Go Down
Author Topic: SD and BT at the same time  (Read 485 times)
0 Members and 1 Guest are viewing this topic.
Berlijn
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Brutalen hebben de halve wereld.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Fellow Arduinoers,

Hi i am trying to get my program that exists of a BT and SD shield working
What i have is a BT Shield V2.2 module, and SDcard Logshield, being run by a Arduino uno.
the problem is that my BT is eating all the Data (i can see this data with my BT program on the Laptop)
but there is no Data left for my File on the SD card.
now am wondering how to tackle/solve this problem

the Pins for the BT are put on softwareserial.h on 2,3 and also on the Jumpers of the BT.

any Ideas?

* BTklein.ino (4.16 KB - downloaded 8 times.)
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3996
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the problem is that my BT is eating all the Data

Without seeing your code I'd say you have a different problem. You write a byte to BT, it doesn't erase the contents of the variable unless perhaps you let the data go out of scope and lose the variable.
If that is true then you need to get the data into a Global Variable so you can write it to both BT and SD.

Logged

Examples can be found in your IDE.

Berlijn
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Brutalen hebben de halve wereld.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



Hi!

the code is given in the script down below the comment i posted:)

sincerly yours

B
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46017
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
char init_timer2()
{

TCCR2A |= (1<<WGM21) |(1<<WGM20);
TCCR2B |= 0x07;
ASSR   |= (0<<AS2);
//
TIMSK2 |=0x01;
TCNT2  = 0;
sei();
}
Non-void functions are supposed to return a value. Why doesn't this one?

Code:
pinMode(2,INPUT);
You told the SoftwareSerial instance that this pins was its to control. Why are you messing with it?

Where do you ever see if data has arrived for the software serial instance to read? Where do you actually read that data?

The answer is that you don't. Your bluetooth device isn't consuming all your data. It is collecting it. You are ignoring it.
Logged

Berlijn
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Brutalen hebben de halve wereld.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The thing is i just dont understand, i am still getting Jibber/jabber on the BLuetooth screen on my computer.

i checked the code of the BT the thing you meant about the void, i had to correct it, there's no char init_timer2

secondly i thought it went automatic because of the function serial.print, and or BTSerial.print, i thought that if i split the signals with different Baudrates things would make a difference.

any further suggestions?



Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 548
Posts: 46017
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i checked the code of the BT the thing you meant about the void, i had to correct it, there's no char init_timer2
There was in the code you posted. Are you saying you removed it? Or, are you saying you posted the wrong code?

Quote
The thing is i just dont understand, i am still getting Jibber/jabber on the BLuetooth screen on my computer.
The Arduino is NOT reading anything from the bluetooth module. It is trying to talk to it. Your diddling with the pin it is trying to use may be interfering with its ability to do so. Have you removed that code?

Quote
secondly i thought it went automatic because of the function serial.print, and or BTSerial.print, i thought that if i split the signals with different Baudrates things would make a difference.
Printing is OUTPUT. Reading is INPUT. Input doesn't happen automatically, and more than output does.
Logged

Berlijn
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Brutalen hebben de halve wereld.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1 I compared with the Bluetooth code i had, then changed it to void init_timer2()
2 I am aware that bluetooth connection is being established in the beginning, with the baudrates and so on.
3 that code of the Pin fiddling was removed.
4 the thing is that the softwareserial should make a different connection to the board over the pins 2,3, i checked this also on the Hardware of the BT shield V2.2.
5 secondly where do i start... and do i have to work with interrupts?
6 the thing is that the code that writes to the file also should write to the BTSerial that i can take from there to the screen with my Terra Term logging program.
7 this is what i have understood of the SoftwareSerial

I really really appreciated your critism. the new file is also included.

tx.

* BTklein.ino (4.14 KB - downloaded 5 times.)
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3996
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So you're not using pin 2 or 3 for Serial?
Logged

Examples can be found in your IDE.

Berlijn
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Brutalen hebben de halve wereld.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Solved the problem guys, i mixed up some BT Program, but i actually needed just the Software Serial.h and create a virtual port called BTSerial.print(values) + a Delay(100); you all put this below the Serial.flush();

ill give the example code as well so check it out.



* BTklein.ino (3.29 KB - downloaded 6 times.)
Logged

Pages: [1]   Go Up
Jump to: