Connection Arduino Yùn

Hello,

i’m using an Arduino Yùn and the Web dashboard, trying to get a graph from a temperature sensor (thermistor). The sensor works properly offline but I can’t send data to Cayenne. It says to fix the connection problem when i click on the button “step2: add sensor”. I’m a beginner both with arduino and cayenne… please, help me!

Elena

Hi Elena,

Welcome to the Cayenne community! You’ve come to the right place.

hmm. Can you post a screen shot of the error, and also the code you are using on your Arduino?

-B

Thank you for replying!

Here’s the error message and, below, the code. I tried many times, sometimes it creates an empty graph (because it’s not connected, I guess):

/*
Cayenne Thermistor Example

This sketch shows how to send temperature data to a Thermistor Sensor in the Cayenne Dashboard.

The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

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[] = "wpp8ainyhh";

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

Okay, in the connectivity field, select “virtual”. Then make sure virtual Pin 1 is selected in the “Pin” field. You can kind of follow along in the code, the thermistor should be connected to analog pin 0, and it’s sending the data to virtual pin 1 to the Cayenne dashboard. Does this make sense? Keep us updated with your progress!

-B

Now I understood what the virtual pin is, thank you!
Unfortunately, I still have the problem: the graph is empty and a message on the top of the dashboard says: “Last known status: 5 hours ago”.

Also in the device settings (arduino Yùn) the connection field is empty.
I think it’s not able to connect…

If you are using an Arduino Yun, then you’ll need to use the Arduino Yun connection in your sketch file. This is necessary because the internet connection library is specific to the arduino Yun. If you go to Arduino IDE, select examples–>Cayenne–>InternetConnections–>Arduino Yun.

-B

Thank you very much for your help bestes!
I included the Cayenneyun library and now it works on the mobile App. Unfortunately it’s not working on the web dashboard…there, my graph is still empty and some graphs that I removed yesterday are still there.

One more question…looking at the code, the void loop only contains the line “Cayenne.run()”. So, how can I calibrate my sensor in case that temperature values are not right?

Sorry if my questions are a little stupid, but I’m a beginner.
Thank you for your time
Elena

Not to worry! We have all been beginners at some point. Hmm, you should be able to calibrate your sensor outside of that line. Maybe you could look at some of the Cayenne projects that have been posted and adapt some of the code to fit your needs.

Question, did you remove the graphs from the Android mobile app, but then the widgets that you removed were still showing up on the web dashboard?

-B

I thought that, once I log into my account, the web dashboard and the mobile app should show the same widgets, the same graphs and so on…and if I add something from my mobile, it would be shown also on the web… Am I right?
But I have completely different things: on the app everything works well, I have my graph monitoring a variable from my sensor… On the web dashboard there are some empty graphs (widget) that I tried to create unsuccessfully, and some other that I tried to remove with the on going “…removing…”

Yes, you’re right that changes on one platform should be reflected on the other platform with Cayenne. This should be the case whether it is mobile → web or vice versa, with very few exceptions.

To clear the web dashboard of any stubborn widgets, you can go to the settings gear icon in the upper right > Reset Dashboard, which should eliminate the ones that were stuck on ‘removing’.

Thank you @rsiegel, now it’s working.
One more question: if I try to see the last 10 minutes data on the graph, ii says “no data available for this period”, but I have been monitoring for long time…there should be hours of data…

Thank you again
Have a nice day
Elena

Hi @elena, can you post a screenshot of graph?

Hi @0lab,
here’s the screenshot and the error message


Your boar is always connected?