Alarma

ayuda.txt (893 Bytes)
de forma local si se activa el led pin 8 cuando abro la puerta pero cayenne no lee y si esta conectado

i did not understand what you meant by above.

el codigo que agregue a la aplicación cayenne funciona el led conectado al pin 8 se activa al abrir la puerta pero la pagina de cayenne no lee el dato y dice que la puerta sigue cerrada a un estando abierta ahora lee cayenne el pin 5 donde esta conectado el sensor magnetico tal vez debo hacer que lea el pin 8 donde esta el led
saludos
gracias

you have a magnetic sensor connected to pin 5, which can be used to show door is open or closed. Just send the magnetic sensor value to cayenne.

ahora subi el codigo que me proporciona cayenne SENSOR_PIN 4 VIRTUAL CHANEL 4 sigue sin leerlo codigo original cayenne.txt (2.3 KB)

estoy usando una resistencia pull up de 10k y la distancia entre el sensor y el w5100 es de 3 metros sera por hay donde tengo el problema

First try and find out whether you are able to read the magnetic sensor data. do you have any link to the product?

si si en otro arduino sin el escudo w5100 lo lee perfecto y con el escudo w5100 activando el pin 2 sensor y led en el 8 si se activa el led al abrir la puerta y apaga al cerrar la puerta
gracias

e usado los widget digital input digital motion sensor tendre que usar otro widget
gracias

for this code add #define CAYENNE_DEBUG and share the serial monitor output when the door opens and close.

serial

well, you can see data been published for channel 4. then what is the issue?

al inicio reconoce el sensor, ya sea estando abierta o cerrada solo aparece connection ok

But there are publish print message later also.

solo salen los datos al inicio despues ya no abra o cierra la puerta esto se queda así
gracias

no ya solo connectino ok

click on the + on top widget to make it permanent

inverti la polaridad de la resistencia pull op y si registro puerta abierta pero cierro la puerta y la sigue registrando abierta

tengo que revisar si sistema de conexion pull op

cayenne ya reconocio al sensor solo que de forma inversa indica cerrada cuando esta abierta y dice que esta cerrada cuando esta abierta también en el monitor serie aparece el estado solo tengo que invertir el estado no se como de momento

gracias
saludos

to reverse the state try this:

/*
Cayenne Digital Motion Sensor Example

This sketch shows how to send Digital Motion 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 Digital Motion Sensor to a digital pin on your Arduino.
   Schematic:
   [Ground] -- [Digital Motion Sensor] -- [5V]
                         |
                     Digital Pin
2. Set the SENSOR_PIN value below to the pin number you used when connecting the sensor.
3. Set the VIRTUAL_CHANNEL value below to a free virtual channel (or the virtual channel of a Digital Motion Sensor widget you have added) in the Dashboard.
4. Set the Cayenne authentication info to match the authentication info from the Dashboard.
5. Compile and upload this sketch.
6. Once the Arduino connects to the Dashboard it should automatically create a temporary display widget (or update the Digital Motion Sensor widget you have added) with data.
   To make a temporary widget permanent click the plus sign on the widget.
*/

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

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "ffffffffffffffffffffff";
char password[] = "ffffffffffffffffffffffff";
char clientID[] = "fffffffffffffffff";

#define SENSOR_PIN 4 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL 4

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

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

int previousState = -1;
int currentState = -1;
unsigned long previousMillis = 0;

void checkSensor()
{
  unsigned long currentMillis = millis();
  // Check sensor data every 250 milliseconds
  if (currentMillis - previousMillis >= 250) {
    // Check the sensor state and send data when it changes.
    currentState = digitalRead(SENSOR_PIN);
    if (currentState != previousState) {
      Cayenne.virtualWrite(VIRTUAL_CHANNEL, !currentState, "digital_sensor", "d");
      previousState = currentState;
    }
    previousMillis = currentMillis;
  }
}