Hello
I'm new with arduino and i'm writing a code using datalogger and DHT_11 humidity and temperature sensor. I want to save every 30 second datas for 10 minutes in the sd card... also i want arduino to send the last 10 minute datas by bluetooth. The first part is ikay. But i have problems weiting the second part. Can you help me?
We can't see your code.
We can't see your schematic.
sorry, here is my code: this was for photocell data logging for 30 sec intervals, now i want to write a code which commands from the cellphone and sends back the last 10 minute data. at first i thought if i make an array of 20 buckets, and put it in a loop, then send the loop function to android would make it right, but it just sends me continues data. i only want the last 10 minute data of the program.
float sensorvalue[20];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int i = 0; i < 20; i++) {
pinMode(sensorvalue*, OUTPUT);*
- }*
}
void loop() { - // put your main code here, to run repeatedly:*
sendvalues();
char c;
if(Serial.available())
{
- c=Serial.read();*
- if (c=='t')*
sendvalues();
}
} - void sendvalues(){*
- for (int i=0 ; i<20 ; i++){*
_ Serial.println(sensorvalue*);_
_ sensorvalue = analogRead(A0);
delay(30000); //every 30 seconds read data*
* if (i>=20) {
i=0; //reset to beginning of array, so you don't try to save readings outside of the bounds of the array*
* } }
Serial.println("***********************************");
}*_
Messing about with for loop control variables inside the for loop rarely goes well, unless you really know what you're doing.
Please use code tags when posting code.
So any suggestions?
So, any code tags?
float sensorvalue[20];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for (int i = 0; i < 20; i++) {
pinMode(sensorvalue, OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
sendvalues();
char c;
if(Serial.available())
{
c=Serial.read();
if (c=='t')
sendvalues();
}
}
void sendvalues(){
for (int i=0 ; i<20 ; i++){
Serial.println(sensorvalue);
sensorvalue = analogRead(A0);
delay(30000); //every 30 seconds read data
if (i>=20) {
i=0; //reset to beginning of array, so you don't try to save readings outside of the bounds of the array
} }
Serial.println("***********************************");
}
Tell us what you think is going on in the for loop in setup.
Elements in an array is accessed with an index, like this:
const byte ARRAY_LEN = 10;
float floatArray[ARRAY_LEN];
floatArray[index] = someValue; //index must be in range 0..ARRAYLEN-1
Therefore this is an ooops..
for (int i = 0; i < 20; i++) {
pinMode(sensorvalue, OUTPUT);
}
This is another ooops..
Serial.println(sensorvalue);
sensorvalue = analogRead(A0);
This is useless in a for loop:
if (i>=20) {
i=0; //reset to beginning of array, so you don't try to save readings outside of the bounds of the array
}
Therefore this is an ooops..
No, it is, at the very least, a double oops.