hello every body i want some help in my code :
my project about six LM35 with MicroSD to save temp data to memory card
i want help to run this project without computer and save data in memory
i have adapter 9V-1A and Arduino Uno
how i can do it ??

any one help

#include <SD.h>Â Â Â Â Â Â //Load SD card library
#include <SPI.h>Â Â Â Â Â //Load SPI Library
float tempC1;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC2;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC3;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC4;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC5;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC6;Â Â Â Â Â Â Â // Variable for holding temp in C
float referenceVoltage;
int reading1;
int reading2;
int reading3;
int reading4;
int reading5;
int reading6;
int pinCS = 4;Â Â Â Â Â Â //chipSelect pin for the SD card Reader
int tempPin1 = A0;Â Â Â Â //pin A1 port TEMP Sensors 1
int tempPin2 = A1;Â Â Â Â //pin A2 port TEMP Sensors 2
int tempPin3 = A2;Â Â Â Â //pin A3 port TEMP Sensors 3
int tempPin4 = A3;Â Â Â Â //pin A1 port TEMP Sensors 4
int tempPin5 = A4;Â Â Â Â //pin A2 port TEMP Sensors 5
int tempPin6 = A5;Â Â Â Â //pin A3 port TEMP Sensors 6
File mySensorData;Â Â Â Â //Data object you will write your sesnor data to
void setup() {
 Â
 Serial.begin(9600);        //turn on serial monitor
 pinMode(pinCS, OUTPUT);     //Must declare 10 an output and reserve it
 File mySensorData;
 SD.begin(4);           //Initialize the SD card reader
Â
 analogReference(INTERNAL);
 // Set Analog reference to 1.1V this gives more accuracy since the sensor will output 0-1 V
// For more information see: http://arduino.cc/en/Reference/AnalogReference
referenceVoltage = 1.1; //Set to 5, 3.3, 2.56 or 1.1 depending on analogReference Setting
Â
}
void loop() {
 reading1 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading1 += analogRead(tempPin1);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC1 = (referenceVoltage * reading1 * 10) / 1023;
Â
 reading2 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading2 += analogRead(tempPin2);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC2 = (referenceVoltage * reading2 * 10) / 1023;
 reading3 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading3 += analogRead(tempPin3);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC3 = (referenceVoltage * reading3 * 10) / 1023;
 reading4 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading4 += analogRead(tempPin4);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC4 = (referenceVoltage * reading4 * 10) / 1023;
 reading5 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading5 += analogRead(tempPin5);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC5 = (referenceVoltage * reading5 * 10) / 1023;
 reading6 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading6 += analogRead(tempPin6);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC6 = (referenceVoltage * reading6 * 10) / 1023;
Â
mySensorData = SD.open("TEMPData.txt", FILE_WRITE);
 if (mySensorData) {
 Serial.print("The Temp is: ");        //Print Your results
 Serial.print(tempC1);
 Serial.println(" degrees c Sensors 1");
 Serial.print("The Temp is: ");
 Serial.print(tempC2);
 Serial.println(" degrees c Sensors 2");
 Serial.print("The Temp is: ");
 Serial.print(tempC3);
 Serial.println(" degrees c Sensors 3");
 Serial.print("The Temp is: ");
 Serial.print(tempC4);
 Serial.println(" degrees c Sensors 4");
 Serial.print("The Temp is: ");
 Serial.print(tempC5);
 Serial.println(" degrees c Sensors 5");
 Serial.print("The Temp is: ");
 Serial.print(tempC6);
 Serial.println(" degrees c Sensors 6");
 Serial.println("");
Â
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Pause between readings.
 mySensorData.print(tempC1);          //write temperature data to card
 mySensorData.print(",");        Â
 mySensorData.print(tempC2);
 mySensorData.print(",");          Â
 mySensorData.print(tempC3);
 mySensorData.print(",");        Â
 mySensorData.print(tempC4);
 mySensorData.print(",");      Â
 mySensorData.print(tempC5);
 mySensorData.print(",");              Â
 mySensorData.println(tempC6);
 mySensorData.close();              //close the file
}
}
so any help and thx.
Once you upload you Sketch to an Arduino it will run without a computer, just connect it to power. So what is the problem?
septillion:
Once you upload you Sketch to an Arduino it will run without a computer, just connect it to power. So what is the problem?
i connect to power and not work !!!
Then you really need to give more details, "Does not work" is NEVER a problem description.
How did you connect it?
Did it work when it was connected to a PC?
Why do yu think it does not when not connected to a PC?
etc
septillion:
Then you really need to give more details, "Does not work" is NEVER a problem description.
How did you connect it?
Did it work when it was connected to a PC?
Why do yu think it does not when not connected to a PC?
etc
i connect it with adapter 9V-1A and the led of arduino power is light but don't read temp and save it on memory.
yes when i open with computer and open serial begin start works and write data to memory
That's still not an answer...
But quick scan through the code, you never actually open a file on the SD-card. So that would change the question in "Why doesn't my program write to the SD-card". Because it will not do that either when it is connected to the PC...
septillion:
That's still not an answer...
But quick scan through the code, you never actually open a file on the SD-card. So that would change the question in "Why doesn't my program write to the SD-card". Because it will not do that either when it is connected to the PC...
finally thx for your help and i will repost with your new question .
hello everybody
my project about six LM35 and Micro SD Card for save data of temp in memory .
my problem:
"Why doesn't my program write to the SD-card" Because it will not do that either when it is connected to the PC.
i want to run it without computer>
i use adapter 9V-1A.
so any help.
MY CODE:
#include <SD.h>Â Â Â Â Â Â //Load SD card library
#include <SPI.h>Â Â Â Â Â //Load SPI Library
float tempC1;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC2;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC3;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC4;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC5;Â Â Â Â Â Â Â // Variable for holding temp in C
float tempC6;Â Â Â Â Â Â Â // Variable for holding temp in C
float referenceVoltage;
int reading1;
int reading2;
int reading3;
int reading4;
int reading5;
int reading6;
int pinCS = 4;Â Â Â Â Â Â //chipSelect pin for the SD card Reader
int tempPin1 = A0;Â Â Â Â //pin A1 port TEMP Sensors 1
int tempPin2 = A1;Â Â Â Â //pin A2 port TEMP Sensors 2
int tempPin3 = A2;Â Â Â Â //pin A3 port TEMP Sensors 3
int tempPin4 = A3;Â Â Â Â //pin A1 port TEMP Sensors 4
int tempPin5 = A4;Â Â Â Â //pin A2 port TEMP Sensors 5
int tempPin6 = A5;Â Â Â Â //pin A3 port TEMP Sensors 6
File mySensorData;Â Â Â Â //Data object you will write your sesnor data to
void setup() {
 Â
 Serial.begin(9600);        //turn on serial monitor
 pinMode(pinCS, OUTPUT);     //Must declare 10 an output and reserve it
 File mySensorData;
 SD.begin(4);           //Initialize the SD card reader
Â
 analogReference(INTERNAL);
 // Set Analog reference to 1.1V this gives more accuracy since the sensor will output 0-1 V
// For more information see: http://arduino.cc/en/Reference/AnalogReference
referenceVoltage = 1.1; //Set to 5, 3.3, 2.56 or 1.1 depending on analogReference Setting
Â
}
void loop() {
 reading1 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading1 += analogRead(tempPin1);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC1 = (referenceVoltage * reading1 * 10) / 1023;
Â
 reading2 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading2 += analogRead(tempPin2);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC2 = (referenceVoltage * reading2 * 10) / 1023;
 reading3 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading3 += analogRead(tempPin3);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC3 = (referenceVoltage * reading3 * 10) / 1023;
 reading4 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading4 += analogRead(tempPin4);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC4 = (referenceVoltage * reading4 * 10) / 1023;
 reading5 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading5 += analogRead(tempPin5);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC5 = (referenceVoltage * reading5 * 10) / 1023;
 reading6 = 0;
Â
 for(int i = 0; i < 10; i++) { // Average 10 readings for accurate reading
  reading6 += analogRead(tempPin6);
  delay(20);
 }
 // A lot of examples divide the sensor reading by 1024. This is incorrect and should be 1023. There are 1024 values including 0 so this should be 1023.
 tempC6 = (referenceVoltage * reading6 * 10) / 1023;
Â
mySensorData = SD.open("TEMPData.txt", FILE_WRITE);
 if (mySensorData) {
 Serial.print("The Temp is: ");        //Print Your results
 Serial.print(tempC1);
 Serial.println(" degrees c Sensors 1");
 Serial.print("The Temp is: ");
 Serial.print(tempC2);
 Serial.println(" degrees c Sensors 2");
 Serial.print("The Temp is: ");
 Serial.print(tempC3);
 Serial.println(" degrees c Sensors 3");
 Serial.print("The Temp is: ");
 Serial.print(tempC4);
 Serial.println(" degrees c Sensors 4");
 Serial.print("The Temp is: ");
 Serial.print(tempC5);
 Serial.println(" degrees c Sensors 5");
 Serial.print("The Temp is: ");
 Serial.print(tempC6);
 Serial.println(" degrees c Sensors 6");
 Serial.println("");
Â
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â //Pause between readings.
 mySensorData.print(tempC1);          //write temperature data to card
 mySensorData.print(",");        Â
 mySensorData.print(tempC2);
 mySensorData.print(",");          Â
 mySensorData.print(tempC3);
 mySensorData.print(",");        Â
 mySensorData.print(tempC4);
 mySensorData.print(",");      Â
 mySensorData.print(tempC5);
 mySensorData.print(",");              Â
 mySensorData.println(tempC6);
 mySensorData.close();              //close the file
}
}
How did you connect the SD card? Have you connected all SPI pins? Did you connect the Chip Select pin to Arduino pin 4?
You could use arrays and for-loops to clean up your code. There's a lot of things you copy-and-pasted six times.
Pieter
-
Are you sure your wiring is correct? Double check everything.
-
Have you tried the SD card sample code? Does that work?
If 2) fails, your problem is likely in the wiring (this assuming the SD card reader isn't defective, which is yet another possibility).
If 2) works, the problem is likely somewhere in your code.
Another problem may be the power supply.
The SD card adapter I use myself works internally on 3.3V but requires higher voltage, as it has a regulator on board. The reader can draw up to 500 mA when processing writes - your power supply must be able to supply those bursts. Also at 9V the regulator may also get too hot, it's got to dissipate almost 3W of power.
septillion:
But quick scan through the code, you never actually open a file on the SD-card.
AbdoAmr:
mySensorData = SD.open("TEMPData.txt", FILE_WRITE);
Try this to check if the SD card works:
// see if the card is present and can be initialized:
if (!SD.begin(4)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while(1);
}
Serial.println("card initialized.");
Pieter
Ah, missed that in my quick scan. But never closing that again but constantly reopen it may give you trouble.