ESP8266WiFi.h
- For connecting the ESP8266 to Wi-Fi.ESP8266Firebase.h
- For interacting with the Firebase Realtime Database.Servo.h
- For controlling the servo motor.#include <ESP8266WiFi.h> // Library for ESP8266 Wi-Fi functionality.
#include <ESP8266Firebase.h> // Library for Firebase Realtime Database integration.
#include <Servo.h> // Library for controlling the servo motor.
ESP8266WiFi.h
: Manages Wi-Fi connections.ESP8266Firebase.h
: Integrates with Firebase.Servo.h
: Controls the servo motor.#define _SSID "your_hotspot_ssid" // Wi-Fi network SSID.
#define _PASSWORD "password" // Wi-Fi network password.
#define REFERENCE_URL "https://your-firebase-db-default-rtdb.firebaseio.com" // Firebase Realtime Database URL.
Firebase firebase(REFERENCE_URL); // Initialize Firebase with the database URL.
Servo gateServo; // Create a Servo object for the gate.
_SSID
and _PASSWORD
: Your Wi-Fi credentials.REFERENCE_URL
: URL for your Firebase Realtime Database.Firebase firebase(REFERENCE_URL);
: Initializes Firebase.Servo gateServo;
: Creates a servo object for gate control.Serial.begin(115200);
: Initializes serial communication.WiFi.begin(_SSID, _PASSWORD);
: Connects to the Wi-Fi network.WiFi.status()
: Checks the connection status.gateServo.attach(D0);
: Connects the servo motor to pin D0.firebase.setString()
, firebase.setInt()
, firebase.setFloat()
: Example Firebase operations to set data.For more details, visit the ESP8266Firebase GitHub repository.
How does it work? The NodeMCU is a low-cost microcontroller that integrates the ESP8266 chip. It operates through Wi-Fi, allowing you to easily create IoT projects. It supports GPIO (General Purpose Input Output) pins for sensors, actuators, and communication protocols like I2C and SPI.
Technical Specifications
Specific Features
Common Features
How does it detect object? The IR sensor uses an infrared LED to emit light, and a photodiode to detect the reflection of that light. When an object is in proximity, the reflected light is detected by the photodiode, indicating the presence of the object.
How does it adjust range? The range can be adjusted by turning the onboard potentiometer. Rotating the trimmer adjusts the sensitivity of the sensor’s digital output, allowing you to detect objects at different distances.
Where can you use it? You can use this sensor for sensing black and white lines, suitable for making optical pattern projects and line following robots. Also, you can use this sensor to sense frequency of object. Note: this sensor only works in DIGITAL mode. You can connect the digital output (DO) to sense. Adjust the potentiometer (a.k.a. trimmer) to set the digital output (DO) sensitivity.
Specific Features
Common Features
How does it spin? The SG90 servo motor rotates between 0 to 180 degrees based on the PWM (Pulse Width Modulation) signal it receives. It can hold its position once set, making it ideal for tasks like controlling a gate or robotic arm.
How does it receive input? The servo receives input via the PWM signal sent to it from a microcontroller like the NodeMCU. The width of the pulse determines the angle of rotation. For instance, a 1 ms pulse moves the servo to 0°, while a 2 ms pulse moves it to 180°.
Specific Features
Common Features