Michael StarlingAaronCharlie12341234
Published

Server Room Monitor

Report Temperature, Humidity, and Power Usage

BeginnerShowcase (no instructions)177
Server Room Monitor

Things used in this project

Hardware components

ADS1115
×1
Argon
Particle Argon
×1
Gravity: Analog AC Current Sensor
DFRobot Gravity: Analog AC Current Sensor
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×3

Software apps and online services

ThingSpeak API
ThingSpeak API
Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Temperature and Humidity

Michael Server Sensor Schematic

Cant find any actual schematic templates for the components I used. So a well lit overhead is the best I can do

Code

Humidity and Temperature Reading

Arduino
Reads the water levels in the air and temperature of the computer. Important when dealing with electronics.
// This #include statement was automatically added by the Particle IDE.
#include <JsonParserGeneratorRK.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

//This identifies the primary pin output to be read by the DHT sensor
#define DHTPIN D7    
//Defines what the type of the DHT sensor we are using is.
#define DHTTYPE DHT11        

DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

TCPClient client;



int humidity;
int temperature;

void setup() 
{
    //ThingSpeak.begin(client);
    
    //set the variable to be sent to the other argon
    Particle.variable("temperature", temperature);
    Particle.variable("humidity", humidity);
    
    //Set all the pinmodes
    pinMode(D5, OUTPUT);
    pinMode(D7, OUTPUT);
    Serial.begin(9600); 
    dht.begin();

}


void loop() 
{
    delay(5000);

        humidity = dht.getHumidity();
        //This instructs the argon to take a measurement of the relative humidity as reported by the DHT11 Sensor
 
        temperature = dht.getTempFarenheit();
        //This instructs the argon to take a measurement of the temperature in Farenheit as reported by the DHT11 Sensor

    //Sends the data recorded by the argon for relative humidity and temperature to the cloud for retrieval by partner's argon
   
   Particle.publish("G30 Iot project Humid", String(humidity));
    if(temperature > 90) {
   Particle.publish("G30 Iot project Temp", String(temperature));
   }
   
   delay (500);
   
   createEventPayload(temperature, humidity);


  //Serial.print(dht.getHumidity());
    //Serial.println("humidity");
  //Serial.print(dht.getTempFarenheit());
    //Serial.println("temperature");

  
}


void createEventPayload(int temperature, int humidity)
{
    JsonWriterStatic<256> jw;
    {
        JsonWriterAutoObject obj(&jw);
        
        jw.insertKeyValue("temperature", temperature);
        jw.insertKeyValue("humidity", humidity);
    }
    
    Particle.publish("env-vals", jw.getBuffer(), PRIVATE);
    
}
    
   

Communication

Arduino
This code receives the temperature data from the other Argon to then publish the temperature if it becomes greater than 90 degrees Fahrenheit. To test the code was ran without that restriction to confirm the data communication between the two robots.
      

char temp[2];

void setup() {
    
    //DHT dht(DHTPIN, DHTTYPE);

    Particle.subscribe("G30 Iot project Temp", theHandler);

    
}


void theHandler(const char *event, const char *data)
{
    // Reads the data off the other argon and then publishes the temperature value
    strcpy(temp,data);
    delay(50);
    Particle.publish("WARNING! TEMPERATURE IS: ", String(temp));

}

Michael Server Sensor Code

C#
Tracks humidity, temperature, and power usage. It also listens for the other two argons and alerts the main server though a serial connection that the other two are overheating. It also sends its own signal out if it overheats.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_ADS1X15.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This example assumes the sensor to be plugged into CONN2
#define DHTPIN D6     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

TCPClient client;

Adafruit_ADS1115 ads;


unsigned long myChannelNumber = 1708544;
const char * myWriteAPIKey = "XGCMF66UFUM6LQTC";


void tempone(const char *event, const char *data) {
    Serial.println("Server 1 Overheating");
}

void temptwo(const char *event, const char *data) {
    Serial.println("Server 2 to much Humidity");
}

void setup() {
    
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit =       3mV       0.1875mV (DEFAULT)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit =     2mV       0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit =     1mV       0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit =     0.5mV     0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit =     0.25mV    0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit =     0.125mV   0.0078125mV  
    ads.begin();
    ads.setGain(GAIN_TWOTHIRDS); // Sets up ADS
    
    pinMode(A0, INPUT);
    pinMode(D7, OUTPUT);
    Serial.begin(9600); 
    dht.begin(); // Sets up DHT
    ThingSpeak.begin(client); // Sets up ThingSpeak
    Particle.subscribe("Temperature", tempone, MY_DEVICES);
    Particle.subscribe("OverHumid", temptwo, MY_DEVICES);
}

void loop() {

    delay(1000);

    float h = dht.getHumidity();

    float t = dht.getTempCelcius();

    float f = dht.getTempFarenheit();
    
    float current = 0;
    double multiplier = 0.1875F;
    short adc0, adc1;
    float av0, av1;
    adc0 = ads.readADC_SingleEnded(0);
    av0 = adc0 * multiplier;
    adc1 = ads.readADC_SingleEnded(3);
    av1 = adc1 * multiplier;
    current = (av0 + av1) / 15.0; // takes reading from two sensors and avg to get semi accurate reading
    
    
    if(isnan(h) || isnan(t) || isnan(f) || isnan(av1) || isnan(av0)) {
        Serial.println("Failed to read");
        return;
    }
    if(f >= 100) { // reduces random temperature noise resulting in 200+ degree readings
        return;
    }
    if(true) {
        //Particle.publish("Temperature_F", String(f), PRIVATE);
        //Particle.publish("Humidity", String(h), PRIVATE);
        if(f > 90) {
            Particle.publish("Argon1 Overheating", String(f), PRIVATE);
        }
        ThingSpeak.setField(1, f);
        ThingSpeak.setField(2, h);
        ThingSpeak.setField(3, current);
        ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    }
    
  
    Serial.print(dht.getHumidity());
    Serial.println("h");
    Serial.print(dht.getTempFarenheit());
    Serial.println("t");
    Serial.println(av0);
    Serial.println(av1);
    
  

    delay(60000); // ThingSpeak delay

}

Credits

Michael Starling

Michael Starling

1 project • 1 follower
Aaron

Aaron

1 project • 1 follower
Charlie12341234

Charlie12341234

1 project • 1 follower

Comments