Things used in this project

Hardware components:
APC Back-UPS CS 500
×1
13711 01
SparkFun ESP8266 Thing - Dev Board
×1
22µF/50V
×1
1N4007
×1
09590 01
LED (generic)
×4
BC557
×1
BC547
×1
15k ohm resistor
×8
150 ohm resistor
×6
Mfr 25frf52 1k sml
Resistor 1k ohm
×1
SHARP PC817
×6
WiFi antenna
×1
Toggle Switch
×1
Step Down Power Supply
×1
Software apps and online services:
Cayenne logo hi
myDevices Cayenne
Ide web
Arduino IDE
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)
Pro dmm box 600  26129.1449785766.500.659
Digilent Mastech MS8217 Autorange Digital Multimeter

Schematics

UPS-Schematics
Apc back ups cs 500 schematics jjkxal1b2o
Schematics my curcuit
Cayenne ups schem fswmqpwucb

Code

CodeArduino
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "password";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "username";
char password[] = "password";
char clientID[] = "clientID";

unsigned long lastMillis = 0;

int inputvoltage=LOW;
int line=LOW;
int battery=LOW;

void setup() {
	Serial.begin(9600);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  pinMode(5, INPUT);   //ON LINE input
  pinMode(4, INPUT);   //ON BATTERY input
  pinMode(13, INPUT);  //OVER LOAD input
  pinMode(12, INPUT);  //REPLACE BATTERY input
  pinMode(14, OUTPUT); //BUTTON control output
  pinMode(16, INPUT);  //INPUT MAINS VOLTAGE input
}

void loop() {
	Cayenne.loop();

	//Publish data every 1 seconds (1000 milliseconds). Change this value to publish at a different interval.
	if (millis() - lastMillis > 1000) {
		lastMillis = millis();
		//Cayenne.virtualWrite(0, lastMillis);

  if(digitalRead(16)==LOW)
  {
    Cayenne.virtualWrite(V6,"1"); 
    inputvoltage=HIGH;
  }
  else
  {
    Cayenne.virtualWrite(V6,"0");  
    inputvoltage=LOW;
  }
  
  if(digitalRead(5)==LOW)
  {
    Cayenne.virtualWrite(V1,"1"); 
    line=HIGH;
  }
  else
  {
    Cayenne.virtualWrite(V1,"0");  
    line=LOW;
  }

  if(digitalRead(4)==LOW)
  {
    Cayenne.virtualWrite(V2,"1");   
    battery=HIGH;
  }
  else
  {
    Cayenne.virtualWrite(V2,"0");
    battery=LOW;
  }

  if(digitalRead(13)==LOW)
  {
    Cayenne.virtualWrite(V3,"1");   
  }
  else
  {
    Cayenne.virtualWrite(V3,"0");
  }

  if(digitalRead(12)==LOW)
  {
    Cayenne.virtualWrite(V4,"1");   
  }
  else
  {
    Cayenne.virtualWrite(V4,"0");
  }
 }
}

//Control the UPS with a button that responds to the length of the button press.

CAYENNE_IN_DEFAULT()
{
	CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %s", request.channel, getValue.getId(), getValue.asString());

  if (request.channel = 5)
  {
    String value;
    value = (String)getValue.asString();

    if (value == "1")
    {
      if (line==LOW && battery==LOW && inputvoltage==LOW)
      {
        digitalWrite(14, HIGH);
        delay(3500);
        digitalWrite(14, LOW);
        delay(1000);
        Cayenne.virtualWrite(V5,"0");
      }
      if (line==HIGH || battery==HIGH || inputvoltage==HIGH)
      {
        digitalWrite(14, HIGH);
        delay(1000);
        digitalWrite(14, LOW);
        delay(1000);
        Cayenne.virtualWrite(V5,"0");
      } 
    } 
  } 
}


 

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login