Brett DymondConnor Thomas
Published © LGPL

IOT Group 23

An IOT device that measures the humidity and temperature of its surroundings

IntermediateFull instructions provided35
IOT Group 23

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×2
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Jumper wires (generic)
Jumper wires (generic)
×5

Software apps and online services

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

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Custom parts and enclosures

Complete Project

First Argon

Second Argon

Code

Temperature and Humidity Sensor and ThingSpeak

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 <Adafruit_DHT.h>

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

// DHT parameters
#define DHTPIN 5
// Define the type of sensor used
#define DHTTYPE DHT11        // DHT 11 

const int tog = D7;
// Variables
int temperature;
int temp_f;
int Light_Position;
int humity;
int h;

TCPClient client;

unsigned long myChannelNumber = 919455;
const char * myWriteAPIKey = "1747UUCG6UC8T987";

// DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
    // Start DHT sensor
    ThingSpeak.begin(client);
    Serial.begin(9600);
    dht.begin();
    pinMode(tog, OUTPUT);
    digitalWrite(tog, LOW);
    Particle.subscribe("ConnorThomas4525", LightPosition, ALL_DEVICES);
}
void loop (){  
    if (Light_Position <= 0){
        digitalWrite(tog, LOW);
    }
    else if (Light_Position >= 1){
        digitalWrite(tog, HIGH);
    }
    else{
        
    }
    temperature = dht.getTempCelcius();
    humity = dht.getHumidity();
    h = humity;
     
    temp_f = (1.8)*(temperature) + 32;
    // Publish data
    Particle.publish("ChrisDymond526", String(temp_f), PUBLIC);

    Particle.publish("hChrisDymond526", String(h), PUBLIC);
   
    ThingSpeak.setField(1,temp_f);
    ThingSpeak.setField(2,h);
    
    Serial.println("temp_f");
    //Serial.println("h");
    ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
    
    
    delay(4000);
    
    
}
void LightPosition(const char *events, const char *data){
    String pew = data;
    Light_Position = pew.toInt();
}  

Second Argon

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>

#define DHTPIN D6

#define DHTTYPE DHT11


//DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);



void setup() {

  lcd.clear();
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Temp");
  lcd.setCursor(0,1);
  lcd.print("Humid");
  Particle.subscribe("ChrisDidThis1", f, ALL_DEVICES);
  Particle.subscribe("ChrisDidThisToo", h, ALL_DEVICES);
    // We open up a serial port to monitor the sensor values
    //Serial.begin(9600); 
   //Serial.println("DHT11 test!");

    //dht.begin();
}

void loop() {
    // Wait a few seconds between measurements.
    delay(2000);


    Particle.publish("XxConnor_TheGreatxX",PUBLIC);
}

    void f(const char *event, const char *data) {
    
    // Print the data over serial
    lcd.setCursor(6,0);
    lcd.print(data);
    lcd.setCursor(10,0);
    lcd.print("F     ");
    }
    
    void h(const char *event, const char *data) {
    
    lcd.setCursor(7,1);
    lcd.print(data);
    lcd.setCursor(11,1);
    lcd.print("%     ");
    }

Credits

Brett Dymond

Brett Dymond

1 project • 0 followers
Connor Thomas

Connor Thomas

1 project • 0 followers

Comments

Add projectSign up / Login