Problems with Virtual and input pins

So I just started using cayenne a few hours ago and have no idea how to progress. I have hooked up an 8way relay board to an arduino uno. I am able to control it using the cayenne website and android app without any faults. But when I add a button and motion sensor the cayenne program stops talking to the arduino board which needs to be reset. I am using virtual pin1 for the motion sensor and digital in 11 for the button.


#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

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

#define VIRTUAL_PIN 1

#define VIRTUAL_PIN 2
const int motionSensorPin = 10;

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

void setup()
// set digital pin to output


// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 1

// assuming you wire your relay as normally open
if (currentValue == 0) {
} else {

void loop()

int previousState = -1;
int currentState = -1;
unsigned long previousMillis = 0;

void checkSensor()
unsigned long currentMillis = millis();
// Check sensor data every 250 milliseconds
if (currentMillis - previousMillis >= 250) {
// Check the sensor state and send data when it changes.
currentState = digitalRead(motionSensorPin);
if (currentState != previousState) {
  Cayenne.virtualWrite(VIRTUAL_PIN, currentState);
  previousState = currentState;
    previousMillis = currentMillis;

Circuit Image

Note: I can provide a digital representation of the circuit if required

Thanks for any Help

don’t worry, I have solved the problem. With my arduino board the last 4 pins were inverted so the board turned off to stop itself from frying

Welcome to Cayenne, glad you got it sorted out!

For 8 relays I’d recommend having a separate 5v power supply because it can add up to a substantial mA draw if they are all activated at the same time. Each one should be around around 20mA so that’s 160mA total. It can handle it, but why push it? Here is some info from the Arduino forums:

Well here are the rules for +5vdc usage for output pin current ratings,
total processor chip rating, and total board current ratings.

pins: Recommended continuous current, 20ma. Absolute maximum above
which will damage pin/chip 40ma (use 20ma recommendation)

chip Vcc current (all output pins total and chip overhead): 200ma., i.e.
10 output pin driving 10 leds @ 20 ma is max for whole chip.

Total +5vdc current available for on-board and external use:

If USB powered: 500ma max limited by on-board thermofuse and USB standards.

If powered via on-board +5vdc voltage regulator driven by external power socket (Input Voltage (recommended) 7-12V ) :
not specified, but don’t plan on using more then 500ma max.

Hi Adam thanks for the tips.

I was just using that setup for experimenting with how cayenne works without spending a lot of money. I plan on using a 12v relay control system using transistors to step up the 5v to 12v as well as including override switches if the micro controller dies. I slowly plan on converting all lighting in the home to intelligent lighting using cayenne but will start on the outside first as we are currently re-landscaping.


Looks like that board already has transistor switches on it. I think you just need to give it a separate supply (common ground).