HELP...Please Hold MY Hand!

The code is already here, in one of your threads Esp12-e WiFi QUAD 277Vac/16Amp Relays + power supply - #8 by adam

//#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"

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "qrm6a4rr6e";
// Your network name and password.
char ssid[] = "FBI Wiretap";
char password[] = "insanefun";

void setup()
{
  Serial.begin(115200);
  Cayenne.begin(token, ssid, password);
}

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

CAYENNE_IN(V13){ //Change V0 to whatever your virtual pin number is.  Create additional CAYENNE_IN functions for additional virtual pins
  Serial.println("Receiving Data");
  //code here - do whatever you want to do ex digitalWrite
  digitalWrite(13,!digitalRead(13));
}

CAYENNE_IN(V14){ //Change V0 to whatever your virtual pin number is.  Create additional CAYENNE_IN functions for additional virtual pins
  Serial.println("Receiving Data");
  //code here - do whatever you want to do ex digitalWrite
  digitalWrite(14,!digitalRead(14));
}

CAYENNE_IN(V16){ //Change V0 to whatever your virtual pin number is.  Create additional CAYENNE_IN functions for additional virtual pins
  Serial.println("Receiving Data");
  //code here - do whatever you want to do ex digitalWrite
  digitalWrite(16,!digitalRead(16));
}

Are you using a Feather Huzzah?

May Peace be Upon You!

Bill has his own PCB with native ESP-12s.

I think 14 is input only, although the literature is unclear. 16 may have some other mode calls that need making to operate as an output.

Maybe I’ll have time on the weekend to figure this out

Cheers,

Craig

I have the system (Feather Huzzah) and the app can talk to it!
I have some new questions:

  1. I have the sliders set for motor speed but how should they be set in the app…Data, Motion, Voltage, etc?

  2. When properly configured, what should the sliders be sending to the Feather?

  3. I can use Virtual Pins for the sliders (pins 14 & 16) but I have to Digital Pins for the motor direction…Virtual Pins will not work…What am I doing wrong?

Thanks for all the help!

T.

Hi @tsenneville,

Woot. You’re talking.

As far as the sliders go, take a look at my jukebox example. There is different behaviour depending on if you are using the mobile app or the browser dashboard. My example shows the workaround.

If you want to use virtual pins, you need to manage the pinMode settings yourself:

#define DIR_PIN 13
pinMode(DIR_PIN,OUTPUT);

//out function for direction pin on virtual channel 1
CAYENNE_IN(V1) {
    digitalWrite(DIR_PIN,getValue.asInt());
}

Personally, I think below is bad coding as you could be creating a race condition. Best to set it to whatever is on the Dashboard.

digitalWrite(13,!digitalRead(13));

Cheers,

Craig

1 Like