Things used in this project

Hardware components:
11026 02
Jumper wires (generic)
×1
PCB
×1
Nodemcu
NodeMCU ESP8266 Breakout Board
×1
4 channel 5V Relay Module
×1
DHT 11 TEMPERATURE AND HUMIDITY SENSOR
×1
Software apps and online services:
Cayenne logo hi
Cayenne
Hand tools and fabrication machines:
Soldering Iron
SCREW DRIVER

Schematics

Schematic 1
fs8sqyzj0cotvnu_vd9DvYeNS5.fzz

Code

IOT_with_Esp8266node_mcu_Cayenne.inoArduino
#include <Adafruit_Sensor.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>



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

char ssid[] = "enter your wifi router name ";
char wifiPassword[] = "enter your wifi router password ";

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

unsigned long lastMillis = 0;
#include "DHT.h"

#define DHTPIN D4     

#define DHTTYPE DHT11  
DHT dht(DHTPIN, DHTTYPE);

float h,t,f,hic,hif;
void setup() {
	Serial.begin(9600);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  pinMode(D0,OUTPUT);
  pinMode(D1,OUTPUT);
  pinMode(D2,OUTPUT);
  pinMode(D3,OUTPUT);
 
}

void loop() {
	Cayenne.loop();

	
	if (millis() - lastMillis > 10000) {
		lastMillis = millis();
  Cayenne.virtualWrite(0, h);
  Cayenne.virtualWrite(1, t);
  Cayenne.virtualWrite(2, hic);
	}
   h = dht.readHumidity();
  
  t = dht.readTemperature();
  
  
   f = dht.readTemperature(true);

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

  hif = dht.computeHeatIndex(f, h);
  
  hic = dht.computeHeatIndex(t, h, false);

  Serial.print("Humidity: ");
  Serial.print(h);
  
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(hic);
  
  Serial.print(" *C ");
  Serial.print(hif);
  Serial.println(" *F");
  
	
}
CAYENNE_IN(3)
  {
    
    int currentValue=getValue.asInt();
    if(currentValue==1){
      digitalWrite(D0,HIGH);
      }
      else{
       digitalWrite(D0,LOW); 
      }       }
CAYENNE_IN(4)
  {
    
    int currentValue=getValue.asInt();
    if(currentValue==1){
      digitalWrite(D1,HIGH);
      }
      else{
       digitalWrite(D1,LOW); 
      }       }
CAYENNE_IN(5)
  {
    
    int currentValue=getValue.asInt();
    if(currentValue==1){
      digitalWrite(D2,HIGH);
      }
      else{
       digitalWrite(D2,LOW); 
      }       }
 CAYENNE_IN(6)
  {
    
    int currentValue=getValue.asInt();
    if(currentValue==1){
      digitalWrite(D3,HIGH);
      }
      else{
       digitalWrite(D3,LOW); 
      }       }

//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.

Credits

Moae4ooxfcjqtahjjunr
Junez Riyaz

HI! I am Junez Riyaz, currently doing Bachelor of Technology in the field of Electronics and Communication Engineering.

Contact

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

Similar projects you might like

Wireless Attendance System Using NodeMCU with MySQL
Intermediate
  • 606
  • 9

Protip

Here we are going to interface NodeMCU with RFID-RC522 and getting data to phpMyAdmin database.

Attendance System Using MYSQL with Raspberry and RFID-RC522
Intermediate
  • 1,219
  • 9

Protip

Here we are taking data from RFID reader which is connected to Node MCU V3 and saving it to MYSQL database running on Raspberry Pi.

IoT Pet Feeder
Intermediate
  • 6,573
  • 36

Full instructions

Use circuito.io to build a smart food dispenser for your pet controlled directly from your phone.

Autonomous Plant (ESP8266 - Arduino)
Intermediate
  • 39
  • 1

Full instructions

Want to build system that takes care of a plant? Here's my first attempt. Using ESP8266, soil moisture and Sonoff grow light

Build a Tank Volume Reader in Under $30 using ESP32
Intermediate
  • 752
  • 8

Full instructions

Build a DIY Level Sensor - tank monitor for volume, temperature, and humidity. Prototype for under $30.

NodeMCU Announcer for Domoticz
Intermediate
  • 101
  • 0

Full instructions

Status announcer for Domoticz using the Raspberry Pi and NodeMCU.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login