Help with selecting a pin

Hello, I’m trying to add a thermisor, but the option to add the PIN is not available, what am I doing wrong?

My code

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

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

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

// Virtual Pin of the Thermistor widget.
#define VIRTUAL_PIN V1

// Analog pin the thermistor is connected to.
const int thermistorPin = 0;

// Resistance of the resistor. Currently set to 10k but this can be set to the measured resistance of your
// resistor for greater accuracy.
const float resistance = 10000; 

Thermistor thermistor(thermistorPin, resistance);

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

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

// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN)
{
	// This command writes the temperature in Celsius to the Virtual Pin.
	Cayenne.celsiusWrite(VIRTUAL_PIN, thermistor.getCelsius());
	// To send the temperature in Fahrenheit or Kelvin use the corresponding code below.
	//Cayenne.fahrenheitWrite(VIRTUAL_PIN, thermistor.getFahrenheit());
	//Cayenne.kelvinWrite(VIRTUAL_PIN, thermistor.getKelvin());
}

Hi @Bruno_bls23,

Can you send a screenshot of what is the issue? It seems related to UI rather than code.

Thanks,

~Benny

So I tried it another way.

I added a thermistor, I used the ‘virtual’ sensor. But it now appears as offline on the dashboard.

I’m using the USB serial connection.

One question: do I always have to run the file “cayenne-ser.bat” when connected in this way?

Yes, you always have to have that script running.

1 Like