#include #include #include #include #include #include #define FIREBASE_HOST "monitoring-a2e4a.firebaseio.com" // Change the name of your #define WIFI_SSID "********" // Change the name of your WIFI #define WIFI_PASSWORD "********" // Change the password of your WIFI WiFiClient client; int gatewayID = EEPROM.read(0); // Singleton instance of the radio driver //RH_NRF24 nrf24; RH_NRF24 nrf24(2, 4); // use this for NodeMCU Amica/AdaFruit Huzzah ESP8266 Feather // RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf // RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin // RH_NRF24 nrf24(8, 7); // For RFM73 on Anarduino Mini int LED = 5; void setup() { Serial.begin(115200); Serial.print("Receiver Started, ID: "); Serial.print("Connecting to "); Serial.println(WIFI_SSID); Serial.println(); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.print("IP Address: "); Serial.println(WiFi.localIP()); Firebase.begin(FIREBASE_HOST); nrf24.init(); nrf24.setChannel(3); nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm); pinMode(LED, OUTPUT); } void loop() { if (nrf24.available()) { // Should be a message for us now uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (nrf24.recv(buf, &len)) { // new message, turn on LED digitalWrite(LED, HIGH); // Send a reply uint8_t sdata[] = "Data Received."; nrf24.send(sdata, sizeof(sdata)); nrf24.waitPacketSent(); float humidity = buf[0]; float temperature = buf[1]; int deviceID = buf[2]; Serial.println("--- Data retrieved from device ---"); Serial.print("Humidity: "); Serial.print(humidity); Serial.print("% Temperature: "); Serial.print(temperature); Serial.println("°C "); Firebase.setFloat ("Temp",temperature); Firebase.setFloat ("Humidity",humidity); } } else { // no new message, turn off LED digitalWrite(LED, LOW); } // delay delay(3000); }