Nick and Joe
Published

MEGR 3171 Two Way Temp and Humidity Data Trasnfer

Two Particle Argons, two DHT11 sensors, two LCD screens, and two cities.

IntermediateFull instructions provided20 hours27
MEGR 3171 Two Way Temp and Humidity Data Trasnfer

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×2
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×2
Argon
Particle Argon
×2
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×2
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×2
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×2

Software apps and online services

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

Story

Read more

Schematics

Nick's Complete Setup

Joe's Complete Setup

Nick's Schematic

Joe's Schematic

ThingSpeak Live Charts

Code

Nick's Code

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

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

// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.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 11 

DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);

bool humid = false;

TCPClient client;

unsigned long myChannelNumber =1240566;
const char * myWriteAPIKey ="ZHPYCD2NCU9RBG9K";

void setup() {

  ThingSpeak.begin(client);
  
  Serial.begin(19200);
  
  dht.begin();
  
  delay(3000);
  
  lcd.clear();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("PT:");
  lcd.setCursor(0,1);
  lcd.print("PH:");
  lcd.setCursor(8,0);
  lcd.print("CT:");
  lcd.setCursor(8,1);
  lcd.print("CH:");
  Particle.subscribe("Pineville_Temp", f1, ALL_DEVICES);
  Particle.subscribe("Pineville_Humidity", h1, ALL_DEVICES);
  Particle.subscribe("Charlotte_Temp", f, ALL_DEVICES);
  Particle.subscribe("Charlotte_Humidity", h, ALL_DEVICES);
  }

void loop() {
    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 
    float h = dht.getHumidity();
    // Read temperature as Farenheit
    float f = dht.getTempFarenheit();

    Serial.print(dht.getHumidity());
    Serial.println("h");
    Serial.print(dht.getTempFarenheit());
    Serial.println("f");
    
     if (isnan(h) || isnan(f)) {
         Serial.println("Failed to read from DHT sensor!");
        return;
    }

    

    Particle.publish("Charlotte_Temp", String(f),ALL_DEVICES);
    Particle.publish("Charlotte_Humidity",String(h), ALL_DEVICES);

    ThingSpeak.setField(1,h);
    ThingSpeak.setField(2,f);

    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    delay(15000);

}


    void f1(const char *event, String data) {
    
    int dataval; 
    dataval = String(data).toInt();

    lcd.setCursor(3,0);
    lcd.print(dataval);
    lcd.setCursor(5,0);
    lcd.print((char)223);
    lcd.print("F");
    }
    
    void f(const char *event, String data) {
    
    int dataval; 
    dataval = String(data).toInt();

    lcd.setCursor(11,0);
    lcd.print(dataval);
    lcd.setCursor(13,0);
    lcd.print((char)223);
    lcd.print("F    ");
    }
    
    
    void h1(const char *event, String data) {
    
    int dataval; 
    dataval = String(data).toInt();
    
    lcd.setCursor(3,1);
    lcd.print(dataval);
    lcd.setCursor(5,1);
    lcd.print("%");
    }
    
    void h(const char *event, String data) {
    
    int dataval; 
    dataval = String(data).toInt();
    
    lcd.setCursor(11,1);
    lcd.print(dataval);
    lcd.setCursor(13,1);
    lcd.print("%   ");
    }
   
 

Joe's Code

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

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

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

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

#define DHTPIN D8

#define DHTTYPE DHT11


DHT dht(DHTPIN, DHTTYPE);
bool humid = false;


TCPClient client;

unsigned long myChannelNumber =1240566;
const char * myWriteAPIKey ="ZHPYCD2NCU9RBG9K";



const int rs = 7, en = 6, l3 = 5, l2 = 4, l1 = 3, l0 = 2; //creating variables for the pin numbers to be used in the lcd function
LiquidCrystal lcd(rs, en, l3, l2, l1, l0); 


void setup() {
    
    ThingSpeak.begin(client); //enable thingspeak
    
    Serial.begin(19200); //enable serial monitor
    
    dht.begin(); //enable humidity/temperature sensor

    lcd.begin(16, 2);  //enable LCD with 16 columns and 2 rows
    
    lcd.setCursor(0,0);
    lcd.print("P=Pineville"); 
    lcd.setCursor(0,1);
    lcd.print("C=Charlotte");
    
    delay(3000);
    
    lcd.clear(); //clear LCD display
    lcd.setCursor(0,0);
    lcd.print("PT:"); //Pineville Temperature
    lcd.setCursor(0,1);
    lcd.print("PH:"); //Pineville Humidity
    lcd.setCursor(8,0);
    lcd.print("CT:"); //Charlotte Temperature
    lcd.setCursor(8,1);
    lcd.print("CH:"); //Charlotte Humidity
    lcd.setCursor(0, 0);
    
    Particle.subscribe("Pineville_Temp", f1); //retrieve the temperature data from Pineville Argon
    Particle.subscribe("Pineville_Humidity", h1); //retrieve the humidity data from Pineville Argon
    Particle.subscribe("Charlotte_Temp", f); //retrieve the temperature data from Charlotte Argon
    Particle.subscribe("Charlotte_Humidity", h); //retrieve the humidity date from Charlotte Argon
}
  

 


void loop() {

    float h1 = dht.getHumidity(); //retrieve humidity value from sensor and store it in a variable
    float f1 = dht.getTempFarenheit(); //retrieve temperature value from sensor and store it in a variable
    
    Serial.print(dht.getHumidity()); //I don't know that this section needed
    Serial.println("h1");
    Serial.print(dht.getTempFarenheit());
    Serial.println("f1");
    
        //Check if any reads failed and exit early (to try again).
    if (isnan(h) || isnan(f)) {
         Serial.println("Failed to read from DHT sensor!");
        return;
    }
    
    
    
    Particle.publish("Pineville_Temp", String(f1)); //publishes my Argon's temperature data
    Particle.publish("Pineville_Humidity", String(h1)); //publishes my Argon's humidity data
    
    ThingSpeak.setField(3,h1); //primes my humidity data for thingspeak
    ThingSpeak.setField(4,f1); //primes my temperature data for thingspeak
    
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); //sends my data to thingspeak  
    
    delay(15000);
    
}


    void f1(const char *event, String data) { //subscribe data retreival for Pineville temperature
    
    int dataval; 
    dataval = String(data).toInt(); //convert subscribe data to int
    
    
    lcd.setCursor(3,0);
    lcd.print(dataval); //print converted int
    lcd.setCursor(5,0);
    lcd.print((char)223);
    lcd.print("F");
    }
    
    
    void f(const char *event, String data) { //subscribe data retreival for Charlotte temperature
    
    int dataval;
    dataval = String(data).toInt(); //convert subscribe data to int
    
    lcd.setCursor(11,0);
    lcd.print(dataval); //print converted int
    lcd.setCursor(13,0);
    lcd.print((char)223);
    lcd.print("F    ");
    }


    void h1(const char *event, String data) { //subscribe data retreival for Pineville humidity 
    
    int dataval;
    dataval = String(data).toInt(); //convert subscribe data to int
    
    lcd.setCursor(3,1);
    lcd.print(dataval); //print converted int
    lcd.setCursor(5,1);
    lcd.print("%");
    }
    
    
    void h(const char *event, String data) { //subscribe data retreival for Charlotte humidity
    
    int dataval;
    dataval = String(data).toInt(); //convert subscribe data to int
    
    lcd.setCursor(11,1);
    lcd.print(dataval); //print converted int
    lcd.setCursor(13,1);
    lcd.print("%   ");
    }

Credits

Nick and Joe

Nick and Joe

1 project • 0 followers

Comments

Add projectSign up / Login