Raja FathurrahmanRaja Fathurrahim
Published © GPL3+

Volcano Monitoring to Early Warning

Project to measure and give a early warning about activity of volcano, data will send by bluetooth and FTP. we use STFT to calculate event

AdvancedFull instructions providedOver 3 days190
Volcano Monitoring to Early Warning

Things used in this project

Hardware components

Arduino 101
Arduino 101
To proses data, record and send via bluetooth
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
to calculate data useing STFT and send data into sever using FTP
×1
Arduino Proto Shield
Arduino Proto Shield
×1
LF-24
×1
General Purpose Dual Op-Amp
Texas Instruments General Purpose Dual Op-Amp
×1
Resistor 10k ohm
Resistor 10k ohm
×4
Capacitor 10 µF
Capacitor 10 µF
×4
Adafruit ads1115
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Schematics

Schematic_Signal Conditioning

Code

dataLogger_150sps.ino

Arduino
#include <SdFat.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <Time.h>
#include <DS1307RTC.h>

// SD chip select pin.  Be sure to disable any other SPI devices such as Enet.
const uint8_t chipSelect = SS;
Adafruit_ADS1115 ads;
int16_t results;
tmElements_t tm;
const uint32_t SAMPLE_INTERVAL_MS = 1;
int detik,menit,jam;
#define FILE_BASE_NAME "DATA"
//------------------------------------------------------------------------------
// File system object.
SdFat sd;

// Log file.
SdFile file;

//==============================================================================
// User functions.  Edit writeHeader() and logData() for your requirements.

//------------------------------------------------------------------------------
// Write data header.
void writeHeader() {
  if (RTC.read(tm)) {
  file.print("time ");
  file.print(tm.Hour);
  file.write(':');
  file.print(tm.Minute);
  file.write(':');
  file.print(tm.Second);
  file.println();
}
}
//------------------------------------------------------------------------------
// Log a data record.
void logData(){ 
    file.print(results);
  file.println();
}
//==============================================================================
// Error messages stored in flash.
#define error(msg) error_P(PSTR(msg))
//------------------------------------------------------------------------------
void error_P(const char* msg) {
  sd.errorHalt_P(msg);
}
//------------------------------------------------------------------------------
void setup() {
  const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
  char fileName[13] = FILE_BASE_NAME "00.CSV";
  
  Serial.begin(115200);
  delay(10);
  
  if (!sd.begin(chipSelect, SPI_FULL_SPEED)) sd.initErrorHalt();
  
  // Find an unused file name.
  if (BASE_NAME_SIZE > 6) {
    error("FILE_BASE_NAME too long");
  }
  while (sd.exists(fileName)) {
    if (fileName[BASE_NAME_SIZE + 1] != '9') {
      fileName[BASE_NAME_SIZE + 1]++;
    } else if (fileName[BASE_NAME_SIZE] != '9') {
      fileName[BASE_NAME_SIZE + 1] = '0';
      fileName[BASE_NAME_SIZE]++;
    } else {
      error("Can't create file name");
    }
  }
  if (!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) error("file.open");

  Serial.print(F("Logging to: "));
  Serial.println(fileName);
  
  ads.setGain(GAIN_TWO); 
  ads.begin();
  // Write data header.
 
  writeHeader();
  
  if (RTC.read(tm)) {
     jam = tm.Hour;
     menit = tm.Minute;
     detik = tm.Second;
     
  }
}
//------------------------------------------------------------------------------
void loop() {
  
  results = ads.readADC_Differential_0_1();  
  logData();
  
  // Force data to SD and update the directory entry to avoid data loss.
  if (!file.sync() || file.getWriteError()) error("write error"); 
 
if (RTC.read(tm)) {
  int H = tm.Hour;
  int M = tm.Minute;
  int D = tm.Second; 
  
  if(H==00) H=24;
  
  if (H == (jam+1) && M==menit && D == detik ) {
    
      file.print("time :");
      file.print(tm.Hour);
      file.write(':');
      file.print(tm.Minute);
      file.write(':');
      file.print(tm.Second);
      file.println();
      
 // Close file and stop.
    file.close();
    Serial.println(F("Done"));
    
    const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
  char fileName[13] = FILE_BASE_NAME "00.CSV";
  
  // Find an unused file name.
  if (BASE_NAME_SIZE > 6) {
    error("FILE_BASE_NAME too long");
  }
  while (sd.exists(fileName)) {
    if (fileName[BASE_NAME_SIZE + 1] != '9') {
      fileName[BASE_NAME_SIZE + 1]++;
    } else if (fileName[BASE_NAME_SIZE] != '9') {
      fileName[BASE_NAME_SIZE + 1] = '0';
      fileName[BASE_NAME_SIZE]++;
    } else {
      error("Can't create file name");
    }
  }
file.open(fileName, O_CREAT | O_WRITE | O_EXCL);
  Serial.print(F("Logging to: "));
  Serial.println(fileName);
  
  // Write data header.
  writeHeader();
     jam = tm.Hour;
     menit = tm.Minute;
     detik = tm.Second;
  
  }
}
}

Credits

Raja Fathurrahman

Raja Fathurrahman

4 projects • 11 followers
I am a simple person who learn arduino and other microkontroler
Raja Fathurrahim

Raja Fathurrahim

1 project • 0 followers
Thanks to I Wayan Sudiarta.

Comments