hello, trying take data sensor , save sd card, option connect via bluetooth on phone. have gotten the modules work separately cannot them work together.
i can read data , send on bluetooth connection code nothing saved sd card:
but when uncomment
it saves sd card thing on bluetooth connection "will send data .."
i using sd card writer , bluetooth module
i using arduino uno , far wiring have
bluetooth module
txd >> 10
rxd >> 9
sd card writer
cs >> 4
mosi >> 11
sck >> 13
miso >> 12
in example sd card datalogger has
but wasn't sure if should include if i'm using
it looks sd.begin() causing problem don't know why. me figure out causing this?
thank you,
tyler
i can read data , send on bluetooth connection code nothing saved sd card:
code: [select]
#include <softwareserial.h>// import serial library
#include <spi.h>
#include <sd.h>
softwareserial genotronex(10, 9); // rx, tx
int bluetoothdata; // data given computer
const int triggerpin = 5;
const int echopin = 6;
const int chipselect = 4;
void setup() {
genotronex.begin(9600);
genotronex.println("will send data ..");
// // make sure default chip select pin set to
// // output, if don't use it:
// sd.begin(chipselect);
}
void loop() {
long duration, feet, inches, cm;
pinmode(triggerpin, output);
digitalwrite(triggerpin, low);
delaymicroseconds(2);
digitalwrite(triggerpin, high);
delaymicroseconds(5);
digitalwrite(triggerpin, low);
pinmode(echopin, input);
duration = pulsein(echopin, high);
// convert time distance
cm = duration / 29 / 2;
const byte nvals = 1; //# of data variables have
int var1 = cm; //change data variable sensor
int data[nvals] = {var1};
string label = "var";
//its loop because sending more on variable
if (genotronex.available()) {
(int = 0; < nvals; i++) {
string stuff = label + + ": ";
genotronex.print(stuff + data[i]);
}
genotronex.println("");
}
file datafile = sd.open("datalog.txt", file_write); //name of file save data to
//its loop because saving more on variable
if (datafile) {
(int = 0; < nvals; i++) {
string stuff = label + + ": ";
datafile.print(stuff + data[i]);
}
datafile.println("");
datafile.close();
}
delay(1000);// prepare next data ...
}
but when uncomment
code: [select]
sd.begin(chipselect);
it saves sd card thing on bluetooth connection "will send data .."
i using sd card writer , bluetooth module
i using arduino uno , far wiring have
bluetooth module
txd >> 10
rxd >> 9
sd card writer
cs >> 4
mosi >> 11
sck >> 13
miso >> 12
in example sd card datalogger has
code: [select]
pinmode(10, output);
but wasn't sure if should include if i'm using
code: [select]
softwareserial genotronex(10, 9);
it looks sd.begin() causing problem don't know why. me figure out causing this?
thank you,
tyler
you include it, pinmode(10, output);, , better off connecting bluetooth elsewhere. don't need use software serial anyway, , bet don't have reason doing so. might use hardware serial.
Arduino Forum > Using Arduino > Storage > Using SD card writer and Bluetooth
arduino
Comments
Post a Comment