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

Magic VR Hat
Intermediate
  • 635
  • 8

Wear the hat, get transported to different 360 VR experience.

From BT to WiFi: Creating WiFi Controlled Arduino Robot Car
Intermediate
  • 369
  • 5

Protip

NodeMCU ESP8266 in access point mode: the simplest way to make Wi-Fi controlled Robot Car from Bluetooth Arduino Robot Car + Android App.

Arduino Word Clock
Intermediate
  • 514
  • 8

Full instructions

A clock that let you read the time, for real!

DIY Complete Philips Hue Home Automation
Intermediate
  • 1,837
  • 5

Full instructions

This project emulates a Philips Hue Bridge that is able to control multiple types of lights.

ESP8266 - PIR Motion sensor detection
Intermediate
  • 42
  • 1

Full instructions

In this project, we are looking to detect motion (change) not average IR levels.

Race Car Dashboard (Online Connectivity)
Intermediate
  • 2,023
  • 7

The project was initially designed to acquire real-time race car data for BAJA-SAE competitions.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog