Connection Refused
sophieJ07 opened this issue · 1 comments
sophieJ07 commented
Hi, I'm working on a project with an Arduino MKR 1000 (connected to six sensors) but firebaseData.errorReason() always returns "Connection refused." Any suggestions? Thanks :>
#include <WiFi101.h>
#include "Firebase_Arduino_WiFi101.h"
//firebase info
#define HOST "sensornetwork-fsl-default-rtdb.firebaseio.com"
#define AUTH "" //database secret
#define SSID ""
#define PASSWORD ""
FirebaseData db;
//pins info
const int NUM_SENSORS = 6;
const int trigPins[NUM_SENSORS] = {1, 3, 5, 7, 9, 13};
const int echoPins[NUM_SENSORS] = {2, 4, 6, 8, 10, 14};
void setup() {
Serial.begin(1000);
//wifi setup
Serial.print("Connecting to Wi-Fi");
int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED){
status = WiFi.begin(SSID, PASSWORD);
Serial.print(".");
delay(100);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
delay(100);
//set up firebase
Firebase.begin(HOST, AUTH, SSID, PASSWORD);
Firebase.reconnectWiFi(true);
//set up all inputs and outputs
for(int i = 0; i < NUM_SENSORS; i++){
pinMode(trigPins[i], OUTPUT);
pinMode(echoPins[i], INPUT);
}
}
void loop() {
long duration, inches, cm;
for(int i = 0; i < NUM_SENSORS; i++){
digitalWrite(trigPins[i], LOW);
delayMicroseconds(2);
digitalWrite(trigPins[i], HIGH);
delayMicroseconds(10);
digitalWrite(trigPins[i], LOW);
duration = pulseIn(echoPins[i], HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print("Sensor ");
Serial.print(i+1);
Serial.print(" : ");
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
//update database and print status
bool spotOccupied = (cm < 5);
String path = "/spots/" + String(i+1);
Serial.println(path);
if (Firebase.setBool(db, path, spotOccupied)) {
Serial.println("Firebase update successful");
} else {
Serial.println("Firebase update failed");
Serial.println(db.errorReason());
}
}
delay(100);
}
long microsecondsToInches(long microseconds) {
return microseconds / 148;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 58;
}
mobizt commented
Update Firmware first
https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/updating-firmware
Then update certificate
https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/updating-ssl-certificates
Don't forget to add your firebase domain when update certificate.
This is the issue of device which uses WiFiNINA you can follow.
mobizt/Firebase-Arduino-WiFiNINA#18