#define BLYNK_DEBUG
#include “C:\Users\fredmatic1\Documents\Arduino\libraries\BlynkESP8266_HardSer\ESP8266_HardSer.h”
#include <SimpleTimer.h>
#include <stdlib.h>
SimpleTimer timer;
// Set ESP8266 Serial object
#define EspSerial Serial1 // defines the ESP8266-05/01 modules connections are on Serial1, (Tx1/Rx1)
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = “58f7d282243141afb8f1c8c69709ad42”; // Key for Blynk ‘Upstairs’ API
//String apiKey = “xxxxxxxxxxxxx”; // TC Arduino Key
String apiKey = “xxxxxxxxxx”; // TC Upstairs Key
#define IP “184.106.153.149” // thingspeak.com IP address; see their website for more detail
//String GET = “GET /update?api_key=xxxxxxxxxxxxx”; // you channel will have unique code Grand Rapids
String GET = “GET /update?api_key=xxxxxxxxxxxxxx”; // you channel will have unique code Traverse City
String field1=“&field1=”;
String field2=“&field2=”;
String field3=“&field3=”;
#define pinLED PC13
#define RGBred 6
#define RGBgreen 5
#define RGBblue 9
unsigned char Black = {0, 0, 0};
unsigned char dimWhite = {8, 8, 8};
unsigned char White = {30, 30, 30};
unsigned char briteWhite = {60, 60, 60};
unsigned char Blue = {0, 0, 20};
unsigned char briteBlue = {0, 0, 50};
unsigned char Red = {20, 0, 0};
unsigned char briteRed = {50, 0, 0};
unsigned char Cyan = {0, 20, 20};
unsigned char briteCyan = {0, 50, 50};
unsigned char Yellow = {20, 20, 0};
unsigned char Violet = {10, 0, 20};
unsigned char Lime = {0, 20, 0};
unsigned char Orange = {30, 7, 0};
unsigned char *AltColor, *CurrentColor;
void setup(void);
void loop(void);
void readtemp(void);
void send_data(void);
void send_graph_data(void);
void temperature_control(void);
void writeColor(unsigned char *color);
void sendUptime(void);
void send_to_thingspeak(float tempdata);
void update(String value, String field);
char * floatToString(char * outstr, float value, int places, int minwidth, bool rightjustify);
void setup()
{
Serial.begin(115200);
pinMode(pinLED, OUTPUT);
Serial.println(“START”);
pinMode(RGBred, PWM);
pinMode(RGBgreen, PWM);
pinMode(RGBblue, PWM);
delay(1000);
CurrentColor = &White[0];
writeColor(CurrentColor);
delay(2000);
// Set ESP8266 baud rate
//EspSerial.begin(9600); // Set for ESP-01
EspSerial.begin(115200); // Set for ESP-05
delay(1000);
CurrentColor = &Blue[0];
writeColor(CurrentColor);
Blynk.begin(auth, wifi, “xxxxxxxxx”, “xxxxxxxxxxx”);
//Blynk.begin(auth, wifi, “xxxxxxxxxx”, “xxxxxxxxxx”);
CurrentColor = &briteRed[0];
writeColor(CurrentColor);
while (Blynk.connect() == false); // Wait until connected
timer.setInterval(2500L, sendData); // update everything every 2.5 second
timer.setInterval(200L, check_usb); // check for console connection every 200 msecs
timer.setInterval(500L, toggle_led_color); // toggle RGB led color every 500 msecs
CurrentColor = &Lime[0];
writeColor(CurrentColor);
yield;
Blynk.virtualWrite(11, 0);
}
void loop()
{
Blynk.run();
timer.run();
}