Problems using the android app

Hi! I’m having problems with the android app. I created a project that includes an alcohol sensor (using Arduino Uno) and it’s working fine in the web dashboard. It updates de value according to the level of alcohol, but when I use the android app, the value is never updated and I have to close it and open it again to see the changes in the value, but it doesn’t even show a sensed one, just a random number( I know that because I have the web dashboard open at the same time to verify the accuracy of the result ). I even try to close the web dashboard to avoid concurrence problems, but it’s still not working.

Do you know why this happens? Thank you!

@rsiegel

Hi @agustinlrisso, welcome to the Cayenne Community.

Could you share the code you’re using to populate the widget? That would give me a better idea of where the issue is, and I can try to reproduce things on my end. Please feel free to edit out your private auth token. A screenshot of the settings for the widget on the web and Android sides may help as well.

thank you @rsiegel !!. It seems weird to me that it’s working just fine in the web dashboard, but not in the android one.

the code is very simple, it’s an alcohol sensor which is connected to the A0 pin. then we duplicate the info using virtual pings to show different information based on the value the sensor detects.

#include <CayenneSerial.h>

char token[] = "xxxxxxxxxx";


int adc_MQ;
float voltaje;
float Rs;
double alcohol;

void setup()
{
  Cayenne.begin(token,9600);
  pinMode(A0, INPUT);
}

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

// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(V0)
{
  adc_MQ = analogRead(A0); //Lemos la salida analógica del MQ
  voltaje = adc_MQ * (5.0 / 1023.0); //Convertimos la lectura en un valor de voltaje
  Rs=1000*((5-voltaje)/voltaje);  //Calculamos Rs con un RL de 1k
  alcohol=0.4091*pow(Rs/5463, -1.497); // calculamos la concentración  de mg alcohol/L en aire
  alcohol=alcohol*0.021; //adaptamos para calcular la proporcion de g alcohol/L sangre
  
  Cayenne.virtualWrite(V0, alcohol);
}

CAYENNE_OUT(V1)
{
  Cayenne.virtualWrite(V1, alcohol);
}


CAYENNE_OUT(V2)
{ 
  if (alcohol>0.5){
    Cayenne.virtualWrite(V2, alcohol);
  } else {
    Cayenne.virtualWrite(V2, 0);
  }
}

CAYENNE_OUT(V3)
{
  if (alcohol>0.5){
    Cayenne.virtualWrite(V3, alcohol);
  } else {
    Cayenne.virtualWrite(V3, 0);
  }
}

this is the dashboard

and the widgets settings

sorry to bother you again, but I’m still having problems with the mobile app @rsiegel

No será esto un soplador para que no te multen no? xD

PD: A mí me funciona bien la app. EDIT: menos los sliders

@adam @shramik_salgaonkar @ognqn.chikov

Any idea here?

Are you having this problem on a specific virtual pin, or all of them? I looked over the code, it looks fine to me.

@agustinlrisso code seems to be fine. you are using usb serial. is it possible for you to add a Ethernet shield to your arduino so that we can see the debug and print messages so as to see whats happening.