Last active
November 12, 2015 02:58
-
-
Save EnriqueV/76a573167a683d5f8d22 to your computer and use it in GitHub Desktop.
Data Logger ARDUINO + Sensor LM35 (Save data on SDCARD), Tomando datos con 5 sensores LM35.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Eduardo Valencia | |
// Script para leer y guardar temperatura utilizando un LM35 | |
#include <SPI.h> | |
#include <SD.h> | |
//Objeto de tipo archivo | |
File SDFile; | |
// Declaracion de variables para los sensores | |
float tempC; | |
float tempA; | |
float tempB; | |
float tempD; | |
float tempE; | |
int tempPin = 8; // Definimos la entrada en pines que ocuparan los LM35 | |
int temPinTwo = 9; | |
int temPinTree= 10; | |
int temPinFour= 11; | |
int temPinFive = 12; | |
void setup() | |
{ | |
// Abre puerto serial y lo configura a 9600 bps | |
Serial.begin(9600); | |
while (!Serial) { | |
; | |
} | |
//inicializo la sd para guardar datos | |
Serial.print("Initializing SD card..."); | |
if (!SD.begin(4)) { | |
Serial.println("initialization failed!"); | |
return; | |
} | |
Serial.println("initialization done."); | |
} | |
void loop() | |
{ | |
// Lee el valor desde el sensor | |
tempC = analogRead(tempPin); | |
tempA = analogRead(temPinTwo); | |
tempB = analogRead(temPinTree); | |
tempD = analogRead(temPinFour); | |
tempE = analogRead(temPinFive); | |
// Convierte el valor a temperatura | |
tempC = (5.0 * tempC * 100.0)/1024.0; | |
tempA=(5.0 * tempA * 100.0)/1024.0; | |
tempB= (5.0 * tempB * 100.0)/1024.0; | |
tempD= (5.0 * tempD * 100.0)/1024.0; | |
tempE= (5.0 * tempE * 100.0)/1024.0; | |
// Envia los datos al puerto serial | |
Serial.print(tempA); | |
Serial.print("\t"); | |
Serial.print(tempB); | |
Serial.print("\t"); | |
Serial.print(tempC); | |
Serial.print("\t"); | |
Serial.print(tempD); | |
Serial.print("\t"); | |
Serial.print(tempE); | |
Serial.print("\t"); | |
Serial.print(tempB); | |
Serial.print("\t"); | |
SDFile = SD.open("data.txt", FILE_WRITE); | |
if (SDFile) | |
{ | |
SDFile.print(tempA); | |
SDFile.print("\t"); | |
SDFile.print(tempB); | |
SDFile.print("\t"); | |
SDFile.print(tempC); | |
SDFile.print("\t"); | |
SDFile.print(tempD); | |
SDFile.print("\t"); | |
SDFile.print(tempE); | |
SDFile.print("\t"); | |
SDFile.print(tempB); | |
SDFile.println("\t"); | |
SDFile.close(); | |
} | |
SDFile.close(); | |
Serial.println("done."); | |
delay(900000); // vuelve a tomar una medida y guardarla cada 15 minutos. | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment