Button on web interface works but on in ios app

Web and IOS (13.1.3)

I have a button to control a relay, works in the web interface. on IOS it just has the spinning circle and does nothing.

1 Like

it works fine at my end. which device are you using?

can you test it now and let me know.

nodeMCU and a uno same problem. the logic seems ok on the device end.

it used to work before ios 13 update. still not working. removed and re added the device

really simple code

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "xxx";
char wifiPassword[] = "xxxxxx";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "xxxxx";
char password[] = "xxxxxxxx";
char clientID[] = "xxxxxx";

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


int pbuttonPin = 3;// connect output to push button
int relayPin = 5;// Connected to relay (LED)
int PwrLedPin = 4;// Connected power (LED)
int WifiLedPin = 14;// Connected power (LED)
int lastMillis = 0;

int val = 0; // push value from pin 2
int lightON = 0;//light status
int pushed = 0;//push status


void setup() {
  digitalWrite(PwrLedPin, HIGH);
	Serial.begin(115200);
  
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  
 
  pinMode(pbuttonPin, INPUT_PULLUP); 
  pinMode(relayPin, OUTPUT);
  pinMode(PwrLedPin, OUTPUT);
  pinMode(WifiLedPin, OUTPUT);
  digitalWrite(relayPin, HIGH);// keep the load OFF at the begining. If you wanted to be ON, change the HIGH to LOW
  
  digitalWrite(WifiLedPin, LOW);
 
}

void loop() {
  
  if (WiFi.status() == WL_CONNECTED) {
    digitalWrite(WifiLedPin, HIGH);
    digitalWrite(PwrLedPin, HIGH);
  } 
if (WiFi.status() != WL_CONNECTED && digitalRead(WifiLedPin) == HIGH) {
    digitalWrite(WifiLedPin, LOW);
   Serial.println("WIFI Down"); 
  } 
  
 val = digitalRead(pbuttonPin);// read the push button value
 
 
 //Publish data every 30 seconds (10000 milliseconds). Change this value to publish at a different interval
if (millis() - lastMillis > 10000) {
    lastMillis = millis();
    //Write data to Cayenne here. This example just sends the current uptime in milliseconds.
    Cayenne.virtualWrite(6, lastMillis);
    Cayenne.virtualWrite(5, 1, "digital_actuator", "d");
  }
  
    if(val == HIGH && lightON == LOW){
    pushed = 1-pushed;
    delay(50);
    }    
  lightON = val;
      if(pushed == HIGH){
        //Serial.println("Modem ON");
        digitalWrite(relayPin, LOW); 
        digitalWrite(PwrLedPin, HIGH);
      }else{

        //Serial.println("Modem OFF");
        digitalWrite(relayPin, HIGH);
        digitalWrite(PwrLedPin, LOW);
        Cayenne.virtualWrite(5,0, "digital_actuator", "d");
        delay(10000);
        pushed = HIGH;
        digitalWrite(relayPin, LOW);
        digitalWrite(PwrLedPin, HIGH);
        Cayenne.virtualWrite(5,1, "digital_actuator", "d");
      }     
  delay(50);
  //Serial.println("cayenne ..."); 
  Cayenne.loop();
  
  if (WiFi.status() != WL_CONNECTED && digitalRead(WifiLedPin) == LOW) {
    digitalWrite(WifiLedPin, HIGH);
    Serial.println("WIFI ..."); 
  } 
}
CAYENNE_OUT_DEFAULT()
{
  Cayenne.virtualWrite(5, pushed, "digital_actuator", "d");
  Cayenne.virtualWrite(6, lastMillis);
}


CAYENNE_IN_DEFAULT()
{
	CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  
}

// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
  
  // Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
  if (getValue.asInt() == 1) {
        pushed = HIGH;
  }
  else {
        //Serial.println("Light OFF");
      pushed = LOW;
  }
  
}

ALso just noticed, the button on the web interface does not update from the

Cayenne.virtualWrite(5,1, “digital_actuator”, “d”); command.

and

are one and the same. why are you publishing it two times with different values?

if your modem is off, how can the device send the data over the internet to cayenne?

Hi shramik

Cayenne.virtualWrite(5, 1, “digital_actuator”, “d”) used the “pushed” to start with but i hard-coded the HIGH state for testing and have not put it back.

the second is just a comment on the state of the relay. it controls a modem that is reset when the button is presses or controlled via the cayenne dash and then turned back on 10 seconds later. the device is always on.

Do not publish the actuator state, you can send the state to another two-state widget which will not interfere with the actuator command. (6, 1, “digital_sensor”, “d”)

I am facing the exact same problem.
Single relay under ESP8266.
Works fine on a browser. Lock with iOS app.
Work around has been to kill the app. Bring it back and click. Locks again but the first single action works.
Using virtual channel 0 to control.

we have taken note of this issue and will be fixed.

1 Like