Wrong script for digital Thermistor Sensor widget, it is always analog


#1

I am using Arduino Uno with W5100 ethernet shield

I am using the Web dashboard

When trying to activate a thermistor widget on a digital pin, the system gives 3 alternatives, virtual, analog and digital. It lets me choose digital pin, but when the script is produced it is for analog pin and not digital.

Here is part of the script:
Steps:

  1. In the Cayenne Dashboard add a new Thermistor widget.
  2. Set the widget to Value Display.
  3. Select Virtual Pins and a virtual pin number.
  4. Set VIRTUAL_PIN to the pin number you selected.
  5. Attach a thermistor to an analog pin on your Arduino. Make sure to use an analog pin, not a digital pin.
    Schematic:
    [Ground] – [10k-resistor] – | – [Thermistor] – [5V]
    |
    Analog Pin
  6. Set the thermistorPin variable to match the pin used to connect the thermistor.
  7. Set the token variable to match the Arduino token from the Dashboard.
  8. Compile and upload this sketch.
  9. Once the Arduino connects to the Dashboard it should automatically update the Thermistor widget with data.
    */

#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[] = “xxxxxxxxxx”;

// 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()


#2

HI @gchiaretta,

The sketch files actually don’t dynamically change based on the selection from the dropdowns. So, no matter what, the example sketch file will always use the analog pins. This has come up before and so we’re aware that it can be a little confusing. It’s on our radar :slight_smile:

-B


#3

OK, it is quite understandable that, for a free platform, we cannot be too demanding. But putting a little note inside the sketch itself does not seem a difficult task and might prevent some issues.
A kind of warning stating just this fact, that it is not dynamically changing based on the selection from the drop-down, so that a complete new writing might be necessary. Otherwise you give an incorrect communication to the user, that feels that he might be doing something wrong or that there is a fault with the system.
Having said this, please take my congratulation, the platform is nice, some improvements are due, but I think I am going to be using it.

Thank you, Giorgio


#4

Yes, we are in agreement that it will prevent some issues :slight_smile: I will see if I can add something to our roadmap.

Thank you, and I hope to see you around! Would love to see you submit your project to our Projects Made with Cayenne category when finished!