Kevin Strain
Published © CC BY

Sump Level Monitor

The Sump Level Monitor will determine sump levels, display them locally and send a 0-5vdc signal, relays output or I2c output.

IntermediateFull instructions provided4,454
Sump Level Monitor

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Freescale MPXV5010DP
×1
0.96" OLED Screen
×1
MCP4725 DAC
×1
Relay (generic)
×1
Capacitors 1uf, .01uf, 470pf all SMD
×1
Plastic clear project box 110mm*85mm
×1
Tygon Tubing 3/32"
×1

Story

Read more

Schematics

Custom Board Schematic

Used Eagle 6.5.0

Code

Sump Level Monitor

C/C++
Parse as you need, extra garbage in this version go ahead and clean up as you desire.
#include <SPI.h>
#include <Wire.h> 
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MCP4725.h>
#include <math.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif


Adafruit_MCP4725 dac;

int relayPin = 5; // for relay alarm output
int analogPin = 0; //measures dac output voltage
int v1 = 0; // ADC output from MPXV5010
int v2 = 0; //scaling for dac input converts from PS input to dac input
int v3 = 0; //for mm conversion from PS input
int v4 = 0; //for percentage of depth from PS input
int v5 = 0; // output of dac as read by arduino
int v6 = 0; //for mV conversion from PS input
float v7 =0; //convert from mm to inches
int v8 =0; // to eliminate inches decimals which trash the display 
int offSet = 40;  //the 0 kPa output as measured by arduino
int maxSet = 1015;  //the 10 kPa output as measured by arduino
int maxHeight = 1020; // the depth for the sump from normal water level to lid in mm
int ranging = (maxHeight * 0.8) + offSet;
int alarmHeight = 12; // the alarm height in inches

// For the MPXV5010DP differential pressure sensor
int analogPin2 = 1;

float divisor = 25.4; //for converting display to inches

void setup() {

  Serial.begin(9600);
  Serial.println("DAC test with DP sensor");
  
    // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  // Clear the buffer.
  display.clearDisplay();

  // For MCP4725A0 the address is 0x60 or 0x61
  dac.begin(0x60);
  
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);

}


void loop() {

  v1 = analogRead(analogPin2);
  delay (1000);
  if (v1 < offSet){v1 = offSet;}
  
  //v2=((v1-40)*1.4);
  v2 = map(v1, offSet, maxSet, 0, 4095);  //for dac input converts from PS input to dac input
  dac.setVoltage(v2,false);
  //v3 = map(v1, offSet, maxSet, 0, 1020);  //for mm conversion from PS input
  v3 = (v1 - offSet) / 0.8;
  v7 = v3/divisor;  //convert from mm to inches
  v8 = round (v7); // to eliminate inches decimals which trash the display
  v4 = map(v1, offSet, ranging, 0, 100);  //for percentage of depth from PS input 
  v5 = analogRead(analogPin); // output of dac as read by arduino 0-1023 range
  v6 = map(v5, 0, 1023, 0, 5000);  //for mV conversion from PS input
  
  printoled();
  serial();


}

void printoled()  {
     // Clear the buffer.
  display.clearDisplay();
  
    // invert the display for alarm and pickup relay with LOW signal
  if(v8 > alarmHeight) {  
  display.invertDisplay(true); digitalWrite(relayPin,LOW);}
  else {
  display.invertDisplay(false); digitalWrite(relayPin,HIGH);}
  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("SUMP LEVEL");
  //display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.setTextSize(4);
  display.setTextColor(WHITE);
  display.print(v8); 
  display.setTextSize(2);
  display.println("inches");
  display.display();
  delay(500);
  }

void serial(){
  //for debugging and calibration

  Serial.print("  PS analog input: ");
  Serial.print(v1);
  Serial.print(  "  Height: ");
  Serial.print(v3);
  Serial.print(" mm  ");
  Serial.print(v4);
  Serial.print(" %");
  Serial.print("  Converted voltage: ");
  Serial.print(v6);
  Serial.println(" mV");

}
//end

Credits

Kevin Strain

Kevin Strain

2 projects • 7 followers
Nothing special
Contact
Thanks to ADAFRUIT.

Comments