Help sensor pin not declared


#1

GETTING A COMPILE ERROR
SENSOR PIN6 WAS NOT DECLARED IN THIS SCOPE

 #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
 #include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTEthernetW5500.h>

 
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "XXXXXX";
char password[] = "XXXXXX";
char clientID[] = "XXXXXXX";
// Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define SENSOR_PIN0 A0
#define VIRTUAL_CHANNEL1 V1
#define SENSOR_PIN1 A1
#define VIRTUAL_CHANNEL2 V2
#define SENSOR_PIN2 A2
#define VIRTUAL_CHANNEL3 V3
#define SENSOR_PIN3 A3
#define VIRTUAL_CHANNEL4 V4

 #define SENSOR_PIN 5  
#define VIRTUAL_CHANNEL V5
#define SENSOR_PIN 6
#define VIRTUAL_CHANNEL V6

// 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 tmpPin6 = 6;
const int tmpPin5 = 5;

OneWire oneWire6(SENSOR_PIN6);
OneWire oneWire5(SENSOR_PIN5);  
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors5(&oneWire5);

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  sensors.begin();
}

void loop()
{
  Cayenne.loop();
}
  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL5)
{
  // Send the command to get temperatures.
  sensors5.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, sensors.getTempFByIndex(0));
}  
CAYENNE_OUT(VIRTUAL_CHANNEL6) 
{
    // Send the command to get temperatures.
  sensors6.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, sensors.getTempFByIndex(0)); 
  
}
// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL1)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL1, analogRead(SENSOR_PIN0));
}
//This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL2)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL2, analogRead(SENSOR_PIN1));
} 
  //This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL3)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL3, analogRead(SENSOR_PIN2));
}

  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL4)
{
   Cayenne.virtualWrite(VIRTUAL_CHANNEL4, analogRead(SENSOR_PIN3));
  
}


#2
 #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
 #include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTEthernetW5500.h>

 
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "XXXXXX";
char password[] = "XXXXXX";
char clientID[] = "XXXXXXX";
// Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define SENSOR_PIN0 A0
#define VIRTUAL_CHANNEL1 1
#define SENSOR_PIN1 A1
#define VIRTUAL_CHANNEL2 2
#define SENSOR_PIN2 A2
#define VIRTUAL_CHANNEL3 3
#define SENSOR_PIN3 A3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 4


// 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 tmpPin6 = 6;
const int tmpPin5 = 5;

OneWire oneWire6(tmpPin6);
OneWire oneWire5(tmpPin5 );  
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors5(&oneWire5);

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  sensors.begin();
}

void loop()
{
  Cayenne.loop();
}
  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL5)
{
  // Send the command to get temperatures.
  sensors5.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors5.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, sensors5.getTempFByIndex(0));
}  
CAYENNE_OUT(VIRTUAL_CHANNEL6) 
{
    // Send the command to get temperatures.
  sensors6.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors6.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, sensors6.getTempFByIndex(0)); 
  
}
// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL1)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL1, analogRead(SENSOR_PIN0));
}
//This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL2)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL2, analogRead(SENSOR_PIN1));
} 
  //This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL3)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL3, analogRead(SENSOR_PIN2));
}

  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL4)
{
   Cayenne.virtualWrite(VIRTUAL_CHANNEL4, analogRead(SENSOR_PIN3));
  
}

#3

A copy and paste of your code i still get sensors not declared in this scope ??
Dave


#4

made the change in code. try it now


#5

still sensors not declared


#6

try this code. i have got no error but i had used #include <CayenneMQTTEthernet.h>

// This example shows how to connect to Cayenne using an Ethernet W5100 shield and send/receive sample data.

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
//#include <CayenneMQTTEthernet.h>
#include <CayenneMQTTEthernetW5500.h>
 #include <OneWire.h>
#include <DallasTemperature.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

unsigned long lastMillis = 0;

#define SENSOR_PIN0 A0
#define VIRTUAL_CHANNEL1 1
#define SENSOR_PIN1 A1
#define VIRTUAL_CHANNEL2 2
#define SENSOR_PIN2 A2
#define VIRTUAL_CHANNEL3 3
#define SENSOR_PIN3 A3
#define VIRTUAL_CHANNEL4 4
#define VIRTUAL_CHANNEL5 5
#define VIRTUAL_CHANNEL6 4


// 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 tmpPin6 = 6;
const int tmpPin5 = 5;

OneWire oneWire6(tmpPin6);
OneWire oneWire5(tmpPin5 );  
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors5(&oneWire5);

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  sensors5.begin();
  sensors6.begin();
}

void loop()
{
  Cayenne.loop();
}
  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL5)
{
  // Send the command to get temperatures.
  sensors5.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors5.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL5, sensors5.getTempFByIndex(0));
}  
CAYENNE_OUT(VIRTUAL_CHANNEL6) 
{
    // Send the command to get temperatures.
  sensors6.requestTemperatures();
  // This command writes the temperature in Celsius to the Virtual Channel.
  //Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors6.getTempCByIndex(0));
  // To send the temperature in Fahrenheit use the corresponding code below.
  Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL6, sensors6.getTempFByIndex(0)); 
  
}
// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL1)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL1, analogRead(SENSOR_PIN0));
}
//This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL2)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL2, analogRead(SENSOR_PIN1));
} 
  //This function is called at intervals to send sensor datato Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL3)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL3, analogRead(SENSOR_PIN2));
}

  // This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL4)
{
   Cayenne.virtualWrite(VIRTUAL_CHANNEL4, analogRead(SENSOR_PIN3));
  
}

#7

Error compiling for board arduion

Arduino: 1.8.3 (Windows 7), Board: “Arduino/Genuino Uno”

In file included from C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneArduinoDefines.h:128:0,

             from C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h:21,

             from C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:21,

             from C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernetW5500.h:25,

             from C:\Users\Home Laptop\Documents\Arduino\v1_Soil_Moisture_18b20\v1_Soil_Moisture_18b20.ino:6:

C:\Users\Home Laptop\Documents\Arduino\v1_Soil_Moisture_18b20\v1_Soil_Moisture_18b20.ino: In function ‘void OutputHandler4(Request&)’:

C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneHandlers.h:69:37: error: redefinition of ‘void OutputHandler4(Request&)’

#define CAYENNE_OUT_2(channel) void OutputHandler ## channel (Request& request)

                                 ^

C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneHandlers.h:71:30: note: in expansion of macro ‘CAYENNE_OUT_2’

#define CAYENNE_OUT(channel) CAYENNE_OUT_2(channel)

                          ^

C:\Users\Home Laptop\Documents\Arduino\v1_Soil_Moisture_18b20\v1_Soil_Moisture_18b20.ino:86:1: note: in expansion of macro ‘CAYENNE_OUT’

CAYENNE_OUT(VIRTUAL_CHANNEL4)

^

C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneHandlers.h:69:37: note: ‘void OutputHandler4(Request&)’ previously defined here

#define CAYENNE_OUT_2(channel) void OutputHandler ## channel (Request& request)

                                 ^

C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT\src/CayenneHandlers.h:71:30: note: in expansion of macro ‘CAYENNE_OUT_2’

#define CAYENNE_OUT(channel) CAYENNE_OUT_2(channel)

                          ^

C:\Users\Home Laptop\Documents\Arduino\v1_Soil_Moisture_18b20\v1_Soil_Moisture_18b20.ino:59:1: note: in expansion of macro ‘CAYENNE_OUT’

CAYENNE_OUT(VIRTUAL_CHANNEL6)

^

Multiple libraries were found for "CayenneMQTTEthernetW5500.h"
Used: C:\Users\Home Laptop\Documents\Arduino\libraries\CayenneMQTT
Not used: C:\Users\Home Laptop\Documents\Arduino\libraries\Cayenne-MQTT-Arduino-master
Not used: C:\Users\Home Laptop\Documents\Arduino\libraries\Cayenne-MQTT-Arduino-master
Not used: C:\Users\Home Laptop\Documents\Arduino\libraries\Cayenne-MQTT-Arduino-master
Not used: C:\Users\Home Laptop\Documents\Arduino\libraries\Cayenne-MQTT-Arduino-master
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


#8

i had also got same error with #include <CayenneMQTTEthernetW5500.h> so i changed to #include <CayenneMQTTEthernet.h>
which ethernet shield you are using?


#9

w5500


#10

it still does not compile