Close
0%
0%

230V/24V Digital Signal Recorder

Simple Project to Detect and Record 230V or 24V Signals over long time to find /SPS/Relay/Sensor Failures.

Similar projects worth following
This Board detects Voltage Changing between LOW and HIGH, 2Channels 3-35VDC and 2 Channels 230VAC, Jumper configurable Pins. Bluetooth Connectivity.

The Software Records Every Signal change and Time to MicroSD File.

Parts: DS3231 i2c Clock, MicroSD Slot, Atmega328P, SPP Bluetooth Adapter


Android/PC-configuration Software ongoing.

#include <avr/pgmspace.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Streaming.h>
#include <EEPROM.h>
#include "RTClib.h"
#include <Time.h>
#include <TimeLib.h>

const uint8_t days_in_month [12] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const int chipSelect = 10;

const char string_0[] PROGMEM = "1=0-Falling 1-Rising 2-Both";
const char string_1[] PROGMEM = "2=Scan Intervall";
const char string_2[] PROGMEM = "3=0-Date+time,1-Timestamp,2-Timestamp+Millis,3-Systemmillis,4-Systemmillis+TimeDiff";
const char string_3[] PROGMEM = "4=Output 0-Serial 1-SD 2-Both";
const char string_4[] PROGMEM = "5=Minimal Signal Duration in Ms";
const char string_5[] PROGMEM = "6=Debounce in Ms";
const char string_6[] PROGMEM = "7=Activate Channel 1=On  0=Off";
const char string_7[] PROGMEM = "8=change Channel (1-4)";
const char string_8[] PROGMEM = "9=Save!";
const char string_9[] PROGMEM = "10=Set RTC unixtime UTC!";
const char* const string_table[] PROGMEM  = {string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9};
//Beispielconfig
int configs[40] = {1, 5, 2, 0, 50, 10, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

//RTC&Zeit
RTC_DS3231 RTC;
String filename = "";

void setup() {
  loadconfigs();
  Serial.begin(115200);

  if (! RTC.begin())
  {}
  setSyncProvider(syncProvider);
  setSyncInterval(1000);
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  filename += String(now() / 60 / 60);
  filename += ".csv";
}

#define SECONDS_FROM_1970_TO_2000 946684800
int pins[4] = {2, 3, 4, 5}; //Pinconfig

char buffer2[100]; //Serial Buffer
String inputString = ""; //Serial Buffer
boolean stringComplete = false; //Serial Helper

int channel = 1; //Menuhelper
boolean menuactive = false; //Menuhelper
int menuchoice = 0; //Menuhelper
int choicevalue = 0; //Menuhelper

int laststate[4] = {HIGH, HIGH, HIGH, HIGH}; //Statehelper
int state[4] = {HIGH, HIGH, HIGH, HIGH}; //Statehelper

//Testtrash
//int channelorder;
//int chswitch = 1;
//int chswitchbackup;

void loop() {
  if (!menuactive)
    intervallset();
  serialmenu();
}

//Call between Loops by Serial Input
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    if (!menuactive)
    {
      inputString += inChar;
      if (inChar == '\n') {
        stringComplete = true;
      }
    } else
    {
      if (isDigit(inChar)) {
        inputString += (char)inChar;
      }
      if (inChar == '\n') {
        stringComplete = true;
      }
    }
  }
}


//MenuPrintout
void menu() {
  Serial.print(hour());
  Serial.print(":");
  Serial.print(minute());
  Serial.print(":");
  Serial.print(second());
  Serial.print("-");
  Serial.print(day());
  Serial.print(".");
  Serial.print(month());
  Serial.print(".");
  Serial.println(year());
  Serial.print("Aktiver Kanal: ");
  Serial.println(channel);

  for (int i = 0; i <= 9; i++)
  { int test = ((channel - 1) * 10) + i;
    int tempwert = configs[((((channel - 1) * 10) + i))];
    if (tempwert != -1)
      Serial.print(tempwert);
    spaces(String(tempwert).length());
    strcpy_P(buffer2, (char*)pgm_read_word(&(string_table[i])));
    Serial.println(buffer2);
    delay( 100 );
  }
}

//Menucontrol
void serialmenu() {
  // Serial.println(menuchoice);
  if (stringComplete)

    if (!menuactive && inputString == "menu\n")
    {
      menuactive = true;
      stringComplete = false;
      inputString = "";
      //   menuchoice=0;
      menu();

    } else if (menuactive && menuchoice == 0)
    {
      menuchoice = inputString.toInt();
      strcpy_P(buffer2, (PGM_P)pgm_read_word(&(string_table[menuchoice - 1])));
      Serial.println(buffer2);
      Serial.println("Neuen Wert eingeben!");
      stringComplete = false;
      inputString = "";

    } else if (menuactive && menuchoice == 8)
    {
      choicevalue = inputString.toInt();
      if (choicevalue < 4) {
        channel = choicevalue;
      } else
      {
        Serial.println("Falsche Eingabe");
      }
      stringComplete = false;
      inputString = "";
      menuchoice = 0;

      menu();
    } else if...
Read more »

  • ups

    Schupp03/18/2019 at 13:05 0 comments

    ups

  • PCB?

    Schupp07/01/2016 at 21:32 0 comments

    To built all components into One Small Box of 80mmx80mm i Designed my First DoubleLayer Board.

  • Optimizing

    Schupp07/01/2016 at 21:29 0 comments

    Its useful to connect any monitoring wire to different Voltages.

  • Idea!

    Schupp07/01/2016 at 21:26 0 comments

    i used first a Arduino in Breadboard Style connected 5V Pins to Potential free contacts of Sensors to monitoring failures.

  • Senseless?

    Schupp07/01/2016 at 21:23 0 comments

    Search for helpfull tool or Hardware to monitoring unusual Failures of Any Sensors.

View all 5 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates