so have had code that worked for a long time then out of the blue it just stopped. from my troubleshooting i connects to the internet and the connects to the domain. but when it goes to read data from the stream it does not work i get
Can't read stream data
REASON: not connected
Stream timeout, resume streaming...
i find very odd. as this code worked two weeks ago.
`#include <Firebase_Arduino_WiFi101.h>
#include <Firebase_Arduino_WiFi101_HTTPClient.h>
#include <WiFi101.h>
#include <Adafruit_NeoPixel.h>
#include <ArduinoJson.h>
#include <SPI.h>
#define FIREBASE_HOST "homecontrol-2fa6a-default-rtdb.firebaseio.com"
#define FIREBASE_AUTH "FIv2CkgS0NToGu5nW5kOt9kZWi0KTiddZFVnR0vZ"
#define WIFI_SSID "NestieFi"
#define WIFI_PASSWORD "This1$mypassword"
FirebaseData firebaseData;
String parentPath = "/MagTagDisplay/3";
#define PIN 13
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
String msgs[6];
bool latch = false;
bool other = true;
int l = 0;
uint8_t fR, fG, fB, bR, bG, bB;
int fadeColor;
int colorCounter;
const char* message = "";
String messageBuffer = "";
const char* led1Char;
String led1Temp = "";
uint32_t led1 = 0x000000;
uint32_t led1Buffer = 0x000000;
const char* led2Char;
String led2Temp = "";
uint32_t led2 = 0x000000;
uint32_t led2Buffer = 0x000000;
DynamicJsonDocument jsonDoc(1024);
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial);
Serial.println("hello");
WiFi.setPins(8,7,4,2);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, WIFI_SSID, WIFI_PASSWORD);
Firebase.reconnectWiFi(true);
if (!Firebase.beginStream(firebaseData, parentPath))
{
Serial.println("Could not begin stream");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println();
}
strip.begin();
strip.setBrightness(30); //adjust brightness here
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Your code here
if (!Firebase.readStream(firebaseData))
{
Serial.println("Can't read stream data");
Serial.println("REASON: " + firebaseData.errorReason());
Serial.println();
}
if (firebaseData.streamTimeout())
{
Serial.println("Stream timeout, resume streaming...");
Serial.println();
}
if (firebaseData.streamAvailable())
{
if (firebaseData.dataType() == "json") {
deserializeJson(jsonDoc, firebaseData.jsonData());
JsonObject data1 = jsonDoc.as();
latch = true;
if (data1.containsKey("message")) {
message = data1["message"];
msgs[1] = String(message);
}
if (data1.containsKey("led1")) {
led1Char = data1["led1"];
led1Temp = String(led1Char);
led1Temp.replace("#", "0x");
led1 = strtoul(led1Temp.c_str(), NULL, 16);
}if (data1.containsKey("led2")) {
led2Char = data1["led2"];
led2Temp = String(led2Char);
led2Temp.replace("#", "0x");
led2 = strtoul(led2Temp.c_str(), NULL, 16);
}
}
}
if (msgs[1] == "Off") {
Serial.println("Off");
strip.clear();
strip.show();
msgs[1] = 100;
} else if (msgs[1] == "Rainbow") {
Serial.println("Rainbow");
if (latch) {
} else if (msgs[1] == "Solid") {
Serial.println("solid");
if (latch) {
} else if (msgs[1] == "Color Chase") {
Serial.println("Color Chase");
if (latch) {
} else if (msgs[1] == "Two Color Blink") {
Serial.println("two color blink");
if (latch) {
} else if (msgs[1] == "Colors Wipe") {
Serial.println("colors wipe");
if (latch) {
} else if (msgs[1] == "Random Colors") {
Serial.println("random colors");
if (latch) {
} else if (msgs[1] == "Two Color Chase") {
Serial.println("Two Color Chase");
if (latch) {
} else if (msgs[1] == "Colors Fade") {
Serial.println("Colors Fade");
if (latch) {
fadeColor = 0;
}
colorFade();
}
}
void colorWipe(uint32_t c) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(50);
}
}
void colorsWipe() {
latch = false;
colorWipe(colorPicker(colorCounter));
colorCounter++;
if (colorCounter > 15) {
colorCounter = 0;
}
}
void rainbowCycle() {
latch = false;
uint16_t i;
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + colorCounter) & 255));
}
colorCounter++;
if (colorCounter > 256) {
colorCounter = 0;
}
strip.show();
delay(20);
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
void solidColor() {
latch = false;
colorWipe(led1);
strip.show();
}
uint32_t colorPicker(int color) {
uint32_t colorPicked;
if (color == 15) { //"white"
colorPicked = strip.Color(255, 255, 255);
} else if (color == 0) {
colorPicked = strip.Color(255, 0, 0);
} else if (color == 1) {
colorPicked = strip.Color(255, 128, 0);
} else if (color == 2) {//"green"
colorPicked = strip.Color(255, 255, 0);
} else if (color == 3) {
colorPicked = strip.Color(128, 255, 0);
} else if (color == 4) {
colorPicked = strip.Color(0, 255, 0);
} else if (color == 5) {
colorPicked = strip.Color(0, 255, 128);
} else if (color == 6) {
colorPicked = strip.Color(0, 255, 255);
} else if (color == 7) {
colorPicked = strip.Color(0, 128, 255);
} else if (color == 8) {
colorPicked = strip.Color(0, 0, 255);
} else if (color == 9) {
colorPicked = strip.Color(128, 0, 255);
} else if (color == 10) {
colorPicked = strip.Color(255, 0, 255);
} else if (color == 11) {
colorPicked = strip.Color(255, 0, 128);
} else if (color == 12) {
colorPicked = strip.Color(128, 255, 255);
} else if (color == 13) {
colorPicked = strip.Color(255, 128, 255);
} else if (color == 14) {
colorPicked = strip.Color(255, 255, 128);
}
return (colorPicked);
}
void colorChase() {
latch = false;
uint32_t forgroundColor;
uint32_t backgroundColor;
int li = 0;
int gi = 0;
forgroundColor = led1;
backgroundColor = led2;
li = colorCounter - 1;
gi = colorCounter + 1;
strip.fill(backgroundColor);
strip.show();
if (li >= 0) {
strip.setPixelColor(li, forgroundColor);
}
if (gi <= strip.numPixels()) {
strip.setPixelColor(gi, forgroundColor);
}
strip.setPixelColor(colorCounter, forgroundColor);
colorCounter++;
if(colorCounter>strip.numPixels()){colorCounter=0;}
strip.show();
delay(200);
}
void colorBlink() {
latch = false;
uint32_t forgroundColor;
uint32_t backgroundColor;
forgroundColor = led1;
backgroundColor = led2;
for (int i = 0; i < strip.numPixels(); i++) {
if (other) {
strip.setPixelColor(i, forgroundColor);
i++;
strip.setPixelColor(i, backgroundColor);
} else {
strip.setPixelColor(i, backgroundColor);
i++;
strip.setPixelColor(i, forgroundColor);
}
}
if (other) {
other = false;
}
else {
other = true;
}
strip.show();
delay(200);
}
void randomColors()
{
latch = false;
for (int i = 0; i < strip.numPixels(); i++)
{
strip.setPixelColor(i, colorPicker(random(0, 15)));
}
strip.show();
delay(200);
}
void twoColorChase() {
latch = false;
uint32_t forgroundColor;
uint32_t backgroundColor;
forgroundColor = led1;
backgroundColor = led2;
strip.fill(backgroundColor);
if (l > 5) {
l = 0;
}
for (int i = l; i < strip.numPixels(); i++) {
for (int j = 0; j < 3; j++)
{
if (l > 3) {
strip.setPixelColor(0, forgroundColor);
}
if (l > 4) {
strip.setPixelColor(1, forgroundColor);
}
if (i <= strip.numPixels()) {
strip.setPixelColor(i, forgroundColor);
}
i++;
}
i = i + 2;
}
l++;
strip.show();
delay(200);
}
uint32_t fadeColorPicker(int color, int f) {
uint32_t colorPicked;
if (color == 12) { //"white"
colorPicked = strip.Color( 255.0 * ((float)f / 30.0), 255.0 * ((float)f / 30.0), 255.0 * ((float)f / 30.0));
} else if (color == 0) { //"blue"
colorPicked = strip.Color(0, 0, 255.0 * ((float)f / 30.0));
} else if (color == 1) { //"red"
colorPicked = strip.Color( 255.0 * ((float)f / 30.0), 0, 0);
} else if (color == 2) {//"green"
colorPicked = strip.Color(0, 255.0 * ((float)f / 30.0), 0);
} else if (color == 3) {//"magenta"
colorPicked = strip.Color( 255.0 * ((float)f / 30.0), 0, 255.0 * ((float)f / 30.0));
} else if (color == 4) {//"yellow"
colorPicked = strip.Color( 255.0 * ((float)f / 30.0), 255.0 * ((float)f / 30.0), 0);
} else if (color == 5) {//"cyan"
colorPicked = strip.Color(0, 255.0 * ((float)(float)f / 30.0), 255.0 * ((float)f / 30.0));
} else if (color == 6) { //"orange"
colorPicked = strip.Color( 255.0 * ((float)f / 30.0), 165.0 * ((float)f / 30.0), 0);
} else if (color == 7) {//"purple"
colorPicked = strip.Color( 128.0 * ((float)f / 30.0), 0, 128.0 * ((float)f / 30.0));
} else if (color == 8) {//"blueviolet"
colorPicked = strip.Color( 138.0 * ((float)f / 30.0), 43.0 * ((float)f / 30.0), 226.0 * ((float)f / 30.0));
} else if (color == 9) {//"olivedrab"
colorPicked = strip.Color( 107.0 * ((float)f / 30.0), 142.0 * ((float)f / 30.0), 35.0 * ((float)f / 30.0));
} else if (color == 10) {//"olive"
colorPicked = strip.Color( 128.0 * ((float)f / 30.0), 128.0 * ((float)f / 30.0), 0);
} else if (color == 11) {//"teal"
colorPicked = strip.Color(0, 128.0 * ((float)f / 30.0), 128.0 * ((float)f / 30.0));
}
return (colorPicked);
}
void colorFade() {
latch = false;
for (int i = 1; i < 30; i++) {
strip.fill(fadeColorPicker(fadeColor, i));
strip.show();
delay(100); //edits to desire
}
for (int i = 30; i >= 1; i--) {
strip.fill(fadeColorPicker(fadeColor, i));
strip.show();
delay(100); //edits to desire
}
fadeColor++;
if (fadeColor >= 13) {
fadeColor = 0;
}
}`