Numeric Entry


Numeric Entry
This is more an idea than a project. I simply wanted to share this idea but did not know what category to choose.
Since it is not currently possible to enter numeric values in Cayenne, the following setup could perhaps be useful to someone. This could be used for example entering a security code, or controlling a stepper motor.
I did it with 4 widgets : one Slider, one ‘UP’ button, one ‘Down’ button and one ‘Enter’ button.
(The fifth widget is only used to display the Result and is not mandatory.)
You simply approximate the required value with the slider, fine tune the slider value with the 2 adjusting buttons and finally press the Enter button.

For example, the 3 following screen captures illustrate what I did to enter my target value of 500 :

Here is the code. (I could have resetted the state of the digital actuators after each press, but I didn’t mind and preferred to limit the number of virtual writes.)

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

char ssid[] = "xxxxx";
char wifiPassword[] = "xxxxx";
char username[] = "xxxxx";
char password[] = "xxxxx";
char clientID[] = "xxxxx";

//define VirtualChannels
#define VC_Slider    1
#define VC_StepPlus  2
#define VC_StepMinus 3
#define VC_Enter     4
#define VC_Result    5

int Slider_Value = 0;
int Temp_Value   = 0;
int Enter_Value  = 0;
bool NewValue = false;

void setup() {
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  Cayenne.virtualWrite(VC_Slider, 0, "analog_actuator", "null"); 
  Cayenne.virtualWrite(VC_Result, 0);

void loop() {
  if(Temp_Value !=Slider_Value) {
    Slider_Value = Temp_Value;
    Cayenne.virtualWrite(VC_Slider, Slider_Value, "analog_actuator", "null");    
    Cayenne.virtualWrite(VC_Result, Enter_Value);
    NewValue = false;

  Slider_Value = getValue.asInt();
  Temp_Value = Slider_Value;

CAYENNE_IN(VC_StepPlus)  {Temp_Value++;}

CAYENNE_IN(VC_StepMinus) {Temp_Value--;}

  Enter_Value = Slider_Value;
  NewValue = true;


@Beetoven nice concept :+1: