Why Devices Offline


#1

Im using Arduino+Ethernet Shield W5100, and MQTT. All is propertly connected.

Could someone help me? Why not working TMP36 and even a LedLight. Sensor is connected on A0, and LedLight on digital pin 8.

Maybe I must to change some settings on router?

Thanks in advance.


#2

This is because you have added the device using Bring your device and you have to use custom widgets or auto populate using code.


#3

Hi, why to use ESP8266, when I don’t have Arduino ESP wifi shield. I have original ArduinoUno and original ArduinoEthernetShieldW5100. What exactly library I need. Cayenne or Cayenne MQTT, or MQTT master. And I don’t know what code to use. Some code is gived by Cayenne, on buttion GetCode, or from your links from GitHub. What I must to configure. And do I have to use on home screen of Cayenne, regulary Arduino connection, or Bring your own devices. What is wrong? Device is offline, I cant get nothing from sensors, I cant even turn on led connected on digitalpin8. Or maybe problem with router configuration? What libraries I must have called in second sketch, I mean not on first sketch for connection, I mean to second sketch with configuration sensors or actuators.

Thanks in advance!


#4

And to add. Im using this sketch. Something is wrong.

cayenne-docs/examples/MQTT_EthernetShieldW5100_with_TMP36_and_Actuator/ MQTT_EthernetShieldW5100_with_TMP36_and_Actuator.ino

Can we get some support with TeamViewer maybe? :slight_smile:


#5

Yes we can but before that can you check that your MQTT credentials are correct. As error 5 is for Connection refused, not authorized.


#6

I’ve checked, and credentials are matching. Last night I’m installed 1.0.2 libraries, and im using sketch in Arduino IDE and only this codes, and I click on “Bring your own devices”. This method, and its works. But i have couple of questions if you can answer to me, i will be much thankfull very very much.

1.) In what situation, or with which hardware i must to use standard method to connect on Cayenne(regular click on Arduino picture of board itd…), or when i must to use other method “Bring your own devices”, and using “Custom widget” only.

2.)I have all connected, all working, and after connect to server, its all working, but for five minutes when i was in bathroom or something, probably server goes to standby or something, and its nothing working, i must to plug out usb from Arduino, and plug in back and reconnect, and i wait for litle while, and its working. It must to working with stable connection, i going to connect 30 sensors, and Central Heating System on gas, and i need stable connection, not for five minutes, then must to restart devices. Why im lossing connection?

3.) For example, i was connected a TMP36, Photoresistor and a LED. And all propertly working, but when one sensor changing a readings, its affects on other sensor. For example, when i lighted to photoresistor, and that sensor quickly goes to above 1000+ value, then TMP36 quickly goes from 33C to -26C, or 12C, its going crazy.

4.) When adding more sensors, can i define virtual channels like this:

#define VIRTUAL_CHANNEL_SENSOR1 1

#define VIRTUAL_CHANNEL_SENSOR2 2

#define VIRTUAL_CHANNEL_SENSOR3 3

……………………AND ITC… OR I MAY TO USE BETTER METHOD?

Thank in advance!


#7

Mostly you have to select arduino. Bring your own devices is adding an unsupported device to cayenne using MQTT library.

add #define CAYENNE_DEBUG in your code and open your serial monitor. you will find what is casung the disconnect. Also post the screenshot of the serial monitor here.

can you share the code that is causing this.

yes you can or you can directly use channel number while calling.

Cayenne.virtualWrite(VIRTUAL_CHANNEL_SENSOR1, 0, "digital_sensor", "d");

as

Cayenne.virtualWrite(1, 0, "digital_sensor", "d");

Both are same


#8

Thanks for answer.

1.) If I understand, If I use regular method to connect with Arduino board, I don’t need to use MQTT library, than use standard Cayenne libraries?

2.)When I add to my code #define CAYENNE_DEBUG, I noticed that if I click on light widget, its turn on LED, but for 5 seconds, its turn off automatically every time. Yesterday, I haven’t this problem before I added debugger. Every time turn off the switch automatically.

3.)The code I’m using is copyed here. Look this code if you notice some mistakes in sketch.

4.)Thanks for suggestion

The sketch I’m using is copyed here:

/*
Cayenne TMP36 Example

This sketch shows how to send TMP36 Sensor data to the Cayenne Dashboard.

The CayenneMQTT 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. Attach a TMP36 to an analog pin on your Arduino. Make sure to use an analog pin, not a digital pin.
   Schematic:
   [Ground] -- [TMP36] -- [5V]
                  |
              Analog Pin
2. Set the VIRTUAL_CHANNEL value below to a free virtual channel (or the virtual channel of the TMP36 Sensor widget you have added) in the Dashboard.
3. Set the tmpPin variable to match the pin used to connect the TMP36.
4. Set the voltage variable to match the voltage used to connect the TMP36.
5. Set the Cayenne authentication info to match the authentication info from the Dashboard.
6. Compile and upload this sketch.
7. Once the Arduino connects to the Dashboard it should automatically create temporary display widgets (or update the TMP36 Sensor widgets you have added) with data.
   To make a temporary widget permanent click the plus sign on the widget.
  
    */
    #define CAYENNE_DEBUG
    #define CAYENNE_PRINT Serial   // Comment this out to disable prints and save space
    #include <CayenneTemperature.h>
    #include <CayenneMQTTEthernet.h>   // Change this to use a different communication device. See Communications examples.

    // Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
    char username[] = "12ffd810-d065-11e6-b089-9f6bfa78ab33";
    char password[] = "6b707832ed8ea5e32d0ecffc77ed2a1a9e5114a4";
    char clientID[] = "eba424a0-9e77-11e8-9300-637b1fa64cc6";

    #define VIRTUAL_CHANNEL_SENSOR1 0
    #define VIRTUAL_CHANNEL_SENSOR2 1
    #define virtual_channel 8
    #define ACTUATOR_PIN 8
    #define SENSOR_PIN 1 

    // Analog pin the TMP36 is connected to.
    const int tmpPin = 0;

    // Voltage to the TMP36. For 3v3 Arduinos use 3.3.
    const float voltage = 5.0; 

    TMP36 tmpSensor(tmpPin, voltage);

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

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

      // This function is called at intervals to send sensor data to Cayenne.
    CAYENNE_OUT(VIRTUAL_CHANNEL_SENSOR1)
    {
      // This command writes the temperature in Celsius to the Virtual Channel.
      Cayenne.celsiusWrite(VIRTUAL_CHANNEL_SENSOR1, tmpSensor.getCelsius());
      // To send the temperature in Fahrenheit or Kelvin use the corresponding code below.
      //Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL, tmpSensor.getFahrenheit());
      //Cayenne.kelvinWrite(VIRTUAL_CHANNEL, tmpSensor.getKelvin());
    }

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

    // This function is called when data is sent from Cayenne.
    CAYENNE_IN(virtual_channel)
    {
      int value = getValue.asInt();
      CAYENNE_LOG("Channel %d, pin %d, value %d", virtual_channel, ACTUATOR_PIN, value);
      // Write the value received to the digital pin.
      digitalWrite(ACTUATOR_PIN, value);
    }

#9

Both uses MQTT but BYOT is for devices which are not listed in arduino list. So you can add a new unknown device like nodemcu.

your code looks fine. I am not sure why it is causing a disconnect. try changing the actuator pin and add a debug line in it to see what is going on.


#10

I’m forgot i was created a trigger that turn off light off when temp is below 35, and in serial monitor is constantly pin8 value 0. That it.:grinning:

Thanks on detailed support and answers.