Analog values updating ok but not triggering High and Low alarms

I am using an 8266 to send an analog value 0 to 1024 on channel 0, just using a pot. The value is updating ok on the overview page. i created some triggers to be sent via text and email and it seemed intuitive to set them up but none are working. I created high and low set-points and a threshold of 500. I also set an online/offline trigger. I can move the pot but no alerts are sent. What am i doing wrong?

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

int analogPin = A0;
int pot = 0;

// WiFi network info.
char ssid = “cleo****”;
char wifiPassword = “Bulls***”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “9d5fb8c0-bf04-11e7-993a-9b80361bb***”;
char password = “d50e5910dfd7068eae12858a7b3e47272086f***”;
char clientID = “b8af2570-bf04-11e7-b1f7-559b31b83***”;

unsigned long lastMillis = 0;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
Cayenne.loop();

pot = analogRead(analogPin); // read the input pin

// //Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 1000)

{
	lastMillis = millis();

// //Write data to Cayenne here. This example just sends the current uptime in milliseconds.
Cayenne.virtualWrite(0, pot, “analog_sensor”, “null”);
Serial.println (pot);
// //Some examples of other functions you can use to send data.
// //Cayenne.celsiusWrite(1, 22.0);
// //Cayenne.luxWrite(2, 700);
// //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
}

//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”, request.channel, getValue.getId(), getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}

@pughlabs welcome to cayenne community.
there is problem with triggers using MQTT. @rsiegel and @bestes tagging for this bug,
one alternative can be use a regular connection. add a custom guage widget with virtual pin 1.

#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

char token[] = "";
char ssid[] = "";
char password[] = "";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Cayenne.begin(token, ssid, password);
}
void loop() {
  // put your main code here, to run repeatedly:
  Cayenne.run();

}
CAYENNE_OUT(V1)
{
  pot = analogRead(analogPin); // read the input pin
  Cayenne.virtualWrite(1, pot);
}

Could you explain a little more detail on the bug you’re seeing here? I’ve run a test with some MQTT data (very contrived, just publishing numbers counting upward) and each time a trigger threshold is hit, it’s firing OK for me.

@shramik_salgaonkar I should have told you we have made a few fixes for triggers so may be something else :stuck_out_tongue:

oops sorry @bestes and @rsiegel.

1 Like