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 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);
  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;
  lightON = val;
      if(pushed == HIGH){
        //Serial.println("Modem ON");
        digitalWrite(relayPin, LOW); 
        digitalWrite(PwrLedPin, HIGH);

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

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

// This function is called when data is sent from Cayenne.
  // 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.


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

Ditto on the problem with the button object working fine on the web interface but not on the cell phone app. Do you have a target date for when you might have this issue resolved? I have three IoT projects on hold pending resolution. Great product otherwise!

there is no update on this topic.

I also read that there is a future on/off switch widget in the offing. Perhaps this will resolve the cellphone issue. Is there a target date for its availability?

there will be no new update any soon.

OK - Here’s the workaround. Instead of a button widget, use a slider, 0-100. In your code, test for slider value > 50, if so, turn on the digital output. If < 50, turn it off. Works fine on iphones and probably will on android devices.

1 Like

wow, great workaround. let me test it and give you my opinion on this.

I have implemented and tested the slider as a means to activate a DO with both iPhone and Android phone Cayenne apps and it works solidly. As a footnote, if MyDevices would make a simple momentary push button widget available, we users could synthesize different digital actuators (toggles for example) with no difficulty at all. Thanks for a really useful product!

1 Like