Connecting the PLCDuino to Cayenne

@wmontg5988,

Here is my sketch. Voltage input up to 10V on Anolog In 0.

Cheers,

Craig

/*
Cayenne ESP8266 Shield WiFi Example
Adapted from Blynk's ESP8266_Shield_HardSer Example

This sketch connects to the Cayenne server using an ESP8266 WiFi module as a shield connected
via a hardware serial to an Arduino.

You should install the ESP8266HardwareSerial.zip library via the Arduino IDE (Sketch->Include Library->Add .ZIP Library)
from the Cayenne extras/libraries folder (e.g. My Documents\Arduino\libraries\Cayenne\extras\libraries) to compile this example.

NOTE: Ensure a stable serial connection to ESP8266!
      Firmware version 1.0.0 (AT v0.22) or later is needed.
      You can change ESP baud rate. Connect to AT console and call:
          AT+UART_DEF=115200,8,1,0,0

For Cayenne Dashboard widgets using digital or analog pins this sketch will automatically
send data on those pins to the Cayenne server. If the widgets use Virtual Channels, data
should be sent to those channels using virtualWrites. Examples for sending and receiving
Virtual Channel data are under the Basics folder.
*/



//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneESP8266Shield.h>
#include <PLDuino.h>
#include <PLDuinoGUI.h>
#include <TMRpcm_PLDuino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <PLDuino.h>
#include <PLDTouch.h>
#include <PLDuinoGUI.h>
#include <using_namespace_PLDuinoGUI.h>
#include <DS3232RTC.h>
#include <TimeLib.h>
#include <Wire.h>
#include <avr/io.h>


Adafruit_ILI9341 tft = Adafruit_ILI9341(PLDuino::LCD_CS, PLDuino::LCD_DC);
PLDTouch touch(PLDuino::TOUCH_CS, PLDuino::TOUCH_IRQ);

Button btnVoltage("Volts", ILI9341_YELLOW, ILI9341_BLACK);

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

// Set ESP8266 Serial object
 #define EspSerial Serial2
ESP8266 wifi(EspSerial);

void setup()
{
  PLDuino::init();
  PLDuino::enableLCD();
  PLDuino::enableESP();
  tft.begin();
  tft.setRotation(3);
  touch. init(1);

  Serial.begin(9600);
  delay(100);
  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(100);

  Cayenne.begin(token, wifi, ssid, password);

  btnVoltage.setPositionAndSize(60, 70, 200, 100);
  btnVoltage.draw(tft);
  
 
}

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

CAYENNE_OUT(V1)
{
  int adcVal = analogRead(A0);
  float adcVoltage = 10.0*adcVal/1024;
  Cayenne.virtualWrite(V1,adcVoltage);
  btnVoltage.setText(String(adcVoltage));
  btnVoltage.draw(tft);
}