PauliusPlus
Published © GPL3+

Feel the Heat with Arduino and Cayenne

Arduino with Cayenne enables you to control and monitor your electric devices from anywhere in the world.

IntermediateShowcase (no instructions)6 hours7,552
Feel the Heat with Arduino and Cayenne

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino Ethernet Shield
×1
4-Channel 5V Relay Module
×1
Step Down Adjustable Power Supply
×2
Relay (generic)
×2
AC-DC Industrial DIN rail power supply
×1
Miniature Circuit Breaker
×3

Software apps and online services

Arduino IDE
Arduino IDE
Cayenne
myDevices Cayenne

Story

Read more

Schematics

Temp sensor

The temperature sensor is connected to Arduino pin 14 (A0).

Code

DS18B20 code

C/C++
This sketch shows how to send temperature data to a DS18B20 Sensor in the Cayenne Dashboard.
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <OneWire.h>
#include <DallasTemperature.h>

// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples.
#include <CayenneEthernet.h>

// Virtual Pin of the DS18B20 widget.
#define VIRTUAL_PIN V10

// Digital pin the DS18B20 is connected to. Do not use digital pins 0 or 1 since those conflict with the use of Serial.
const int tmpPin = 14;

OneWire oneWire(tmpPin);
DallasTemperature sensors(&oneWire);

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "xxxxxx";

void setup()
{
	Serial.begin(9600);
	Cayenne.begin(token);
	sensors.begin();
}

void loop()
{
	Cayenne.run();
}

// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN)
{
	// Send the command to get temperatures.
	sensors.requestTemperatures();
	// This command writes the temperature in Celsius to the Virtual Pin.
	Cayenne.celsiusWrite(VIRTUAL_PIN, sensors.getTempCByIndex(0));
	// To send the temperature in Fahrenheit use the corresponding code below.
	//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}

Credits

PauliusPlus

PauliusPlus

2 projects • 13 followers
Automation Engineer

Comments