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

WiDC: Wi-Fi-Controlled FPV Robot
Intermediate
  • 4,981
  • 32

Full instructions

What about using a Wi-Fi remote-controlled robot for exploring your surroundings, reaching inaccessible places, spying and take pictures?

Smart Garden
Intermediate
  • 499
  • 4

Smart Garden is plant environmental monitoring system.

WiFi Messenger
Intermediate
  • 250
  • 3

Protip

Calling my son from his room using 2 ESP8266 modules, instead of shouting.

IoT Thermometer Using Python
Intermediate
  • 198
  • 2

Full instructions

How to develop a simple, but powerful, IoT thermometer using a Zerynth-powered single-board MCU and the Zerynth App.

Counting Pulses with Maxim DS1682
Intermediate
  • 64
  • 2

Protip

This project is interfacing the Energy Monitoring system with a pulse counter.

IoT-Based Healthcare
Intermediate
  • 482
  • 16

Full instructions

It is about a wearable device which senses temperature and heart beat and sends it to mobile app or web app. Patient monitoring or self use.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback