Hi all,
This worked not long ago, but when I try to compile it now I get this "wifiManager does not return a type". I assumed it was due to a problem with my libraries so I wiped them all out and reinstalled clean copies. I also tried reinstalling the Arduino IDE and tried the windows store version. The problem is moving from one computer to another, windows updates??
it fails on line 50
"WiFi.mode(WIFI_STA); //This line hides the viewing of ESP as wifi hotspot"
I have the same problem with all my programs using WiFiManager, all other libs seem fine.
I'm using WiFiManager by tzapu Ver 2.0.15-rc.1, but have tried other versions with same result.
Any thoughts?
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <WiFiManager.h>
#include "FastLED.h"
#define NUM_LEDS 24
#define DATA_PIN 2
CRGB leds[NUM_LEDS];
byte OldHue = 0;
byte Hue[NUM_LEDS];
byte OldSat = 0;
byte Sat[NUM_LEDS];
byte OldVal = 0;
byte Val[NUM_LEDS];
byte Brite[NUM_LEDS];
uint8_t currentLED = 1;
uint8_t colors[7]={0,200,96,192,64,32,224}; // Full Pallet
//uint8_t colors[7]={0,96,200,0,96,0,200}; // Christmas Pallet
int pallet_no;
int new_pallet;
int pallet_size;
int n=0, c=0;
// int s=150;
int Mode = 1;
int Old_Mode = 1;
int x = 1;
int first = 0;
int timer, Speed, Old_id=0;
String getData;
String Link;
int Brightness;
String payload;
int play = 0;
int old_time = 0;
const char *host = "http://doniot.com/Show3.php"; //Web/Server address to read/write from
void setup() {
// pinMode(ledpin,OUTPUT);
delay (3000);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
currentLED=0;
Serial.begin(115200);
Serial.println("WiFiTree3.2");
}
// WiFi Connect ----------------------------------------------------
WiFiManager wifiManager;
wifiManager.autoConnect("WiFiTree");
Serial.println("connected...yeey :)");
}
//=======================================================================
// Main Program Loop
//=======================================================================
void loop() {
HTTPClient http; //Declare object of class HTTPClient
Link = "http://doniot.com/Show256.php";
http.begin(Link); //Specify request destination
int httpCode = http.GET(); //Send the request
String payload = http.getString(); //Get the response payload
Serial.print("Payload is "); Serial.println(payload);
int ModeStart = payload.indexOf("Mode");
int BrightnessStart = payload.indexOf("Brightness");
int SpeedStart = payload.indexOf("Speed");
int hue1Start = payload.indexOf("hue1");
int hue2Start = payload.indexOf("hue2");
int hue3Start = payload.indexOf("hue3");
int hue4Start = payload.indexOf("hue4");
int hue5Start = payload.indexOf("hue5");
int hue6Start = payload.indexOf("hue6");
int hue7Start = payload.indexOf("hue0");
int idStart = payload.indexOf("id")
int FinStart = payload.length();
Mode =(payload.substring(ModeStart +5, BrightnessStart -1).toInt());
if (Mode == 0) { // Trap False catch
Mode = Old_Mode;
}
Brightness =(payload.substring(BrightnessStart +11, SpeedStart -1).toInt());
Speed =(payload.substring(SpeedStart +6, SpeedStart -1).toInt());
if ( colors[0] != payload.substring(hue1Start +5, hue2Start -1).toInt()) {
colors[0] =(payload.substring(hue1Start +5, hue2Start -1).toInt());
Serial.print("colors0 set as "); Serial.println(colors[0]);
}
if ( colors[1] != payload.substring(hue2Start +5, hue3Start -1).toInt()) {
colors[1] =(payload.substring(hue2Start +5, hue3Start -1).toInt());
Serial.print("colors1 set as "); Serial.println(colors[1]);
}
if ( colors[2] != payload.substring(hue3Start +5, hue4Start -1).toInt()) {
colors[2] =(payload.substring(hue3Start +5, hue4Start -1).toInt());
Serial.print("colors2 set as "); Serial.println(colors[2]);
}
if ( colors[3] != payload.substring(hue4Start +5, hue5Start -1).toInt()) {
colors[3] =(payload.substring(hue4Start +5, hue5Start -1).toInt());
Serial.print("colors3 set as "); Serial.println(colors[3]);
}
if ( colors[4] != payload.substring(hue5Start +5, hue6Start -1).toInt()) {
colors[4] =(payload.substring(hue5Start +5, hue6Start -1).toInt());
Serial.print("colors4 set as "); Serial.println(colors[4]);
}
Serial.print("colors5 was "); Serial.println(colors[5]);
if ( colors[5] != payload.substring(hue6Start +5, hue7Start -1).toInt()) {
colors[5] =(payload.substring(hue6Start +5, hue7Start -1).toInt());
Serial.print("colors5 set as "); Serial.println(colors[5]);
}
Serial.print("colors6 at 128 was "); Serial.println(colors[6]);
if ( colors[6] != payload.substring(hue7Start +5, FinStart).toInt()) {
colors[6] =(payload.substring(hue7Start +5, FinStart).toInt());
Serial.print("colors6 set as "); Serial.println(colors[6]);
}
int id = (payload.substring(idStart +3, FinStart).toInt());
n=1;
while (n < 8) { // Multiply to get Colors
if (colors[n]== 0) {
pallet_size = n-1;
Serial.print("Pallet Size 1 = ");Serial.println(pallet_size);
Serial.print("color");Serial.print(n);Serial.print("= ");Serial.println(colors[n]);
break;
}
else {
pallet_size = n;
Serial.print("Pallet Size 2 = ");Serial.println(pallet_size);
}
// colors[n]=colors[n]*28;
Serial.print(n);Serial.print(" = "); Serial.println(colors[n]);
n++;
}
n=0; Serial.print("colors6 at 149 was "); Serial.println(colors[6]);
if (Mode != Old_Mode) {
Serial.print("Mode was ");Serial.print(Old_Mode);Serial.print("Mode is ");Serial.println(Mode);
first = 0;
Old_Mode = Mode;
}
if (Mode == 1) {
mode1();
}
if (Mode == 2) {
mode2();
}
if (Mode == 3) {
mode3();
}
if (Mode == 4) {
mode4();
}
http.end(); //Close connection
//delay(500); //GET Data at every .5 seconds
}
void mode1() { // Single Color
Serial.println("Mode1");
currentLED=0;
while (currentLED < NUM_LEDS) {
Hue[(currentLED)]= colors[0];
Brite[(currentLED)]= Brightness;
leds[(currentLED)]= CHSV(Hue[(currentLED)],255,Brite[(currentLED)]);
currentLED++;
FastLED.show();
delay((Speed)*1000);
}
first=1;
}
void mode2() { // Slides from Old Color to New through Spectrum
Serial.println("Mode2");
pallet_no=1;
currentLED=random(0,NUM_LEDS); // Randomly Select LED
OldHue=Hue[currentLED]; // Get Selected LEDs Current Hue
OldVal=Val[currentLED]; // Get Selected LEDs Current Val
Serial.print("2a Hue of LED [");Serial.print(currentLED);Serial.print("] = ");Serial.println(Hue[(currentLED)]);
Hue[currentLED]= colors[random(0,pallet_size)]; // Set OldHue To Hue to Start Blend
Serial.print("2b Hue of LED [");Serial.print(currentLED);Serial.print("] = ");Serial.println(Hue[(currentLED)]);
while (OldHue != Hue[currentLED]) { // Blend
Serial.print("Hue is "); Serial.print(Hue[currentLED]); Serial.print(" OldHue is "); Serial.print(OldHue); Serial.print(" LED# is "); Serial.print(currentLED); Serial.print(" Mode is ");Serial.println(Mode);
OldHue = OldHue+1;
leds[(currentLED)]= CHSV(OldHue,255,Brightness);
FastLED.show();
delay(10);
}
delay((Speed)*1000); // One Second Pause Between Cycles
}
void mode3() { //Old Color Dims to 0, New Color Brightens
Serial.println("Mode3");
currentLED=0;
Serial.print("Brightness = ");Serial.print(Brightness); Serial.println("Mode3"); Serial.print("colors6 at 206 was "); Serial.println(colors[6]); //Two Color Red(0)& Blue(170)
if (first == 0){ // ********** Initilize Mode 3 ***********************
while (currentLED < NUM_LEDS+1) {
Serial.print("colors6 was at 209 "); Serial.println(colors[6]);
Hue[currentLED]=colors[random(0,pallet_size)];
Serial.print("colors6 was at 211 "); Serial.println(colors[6]);
leds[(currentLED)]= CHSV(Hue[currentLED],255,Brite[(currentLED)]);
currentLED++;
Brite[currentLED] = Brightness;
FastLED.show();
}
first = 1;
}
// ********** Mode 3 Main Logic ***************
while (first == first) { // Initiate Endless Loop
currentLED=random(0,NUM_LEDS+1); //Randomly Select LED
while (Brite[currentLED] > 0){
Brite[currentLED]--;
leds[(currentLED)]= CHSV(Hue[currentLED],255,Brite[currentLED]);
FastLED.show();
// Serial.print("Brightness 1 = ");Serial.print(Brite[currentLED]); Serial.println("Mode3");
delay(20);
}
int temp=colors[random(0,pallet_size)];
Serial.print("colors6 at 231 was "); Serial.println(colors[6]);
// Hue[currentLED]=colors[random(1,pallet_size+1)];
Hue[currentLED]=temp;
Serial.print("Current Hue");Serial.print(colors[random(0,pallet_size)]);Serial.print("temp= ");Serial.println(temp);
// Serial.print("Pallet Size = ");Serial.println(pallet_size);
// Serial.print("B Colors");Serial.print(n);Serial.print(" = "); Serial.println(colors[n]);
while (Brite[currentLED] < Brightness){
Brite[currentLED]++;
leds[(currentLED)]= CHSV(Hue[currentLED],255,Brite[currentLED]);
// Serial.print("Brightness 2 = ");Serial.print(Brite[currentLED]); Serial.println("Mode3");
FastLED.show();
delay(20);
}
delay((Speed)*1000);
break;
}
}
void mode4() { //Blink Change
Serial.println(" Mode4");
if (first == 0){ //First Run Setup
currentLED = 0;
while (currentLED < NUM_LEDS) {
Hue[currentLED]=colors[random(0,pallet_size)];
leds[(currentLED)]= CHSV(Hue[currentLED],255,Brightness);
Serial.print("LED No = ");Serial.print(currentLED);Serial.print("Color = "); Serial.println(Hue[currentLED]);
FastLED.show();
currentLED++;
}
first=1;
}
}
Thanks