This repository contains an Arduino sketch that reads data from various sensors (temperature, light, and moisture) and sends the collected data to a remote server using an ESP8266 module. The collected data is sent in JSON format via a TCP connection over WiFi. This project can be used as a starting point for building IoT applications that involve sensor data collection and remote communication.
- Arduino IDE installed.
- ESP8266 module connected to the Arduino board.
-
Clone or download this repository to your local machine.
-
Open the Arduino IDE and ensure that you have the ESP8266 board package installed (follow these instructions).
-
Connect the ESP8266 module to your Arduino board as follows:
- ESP8266 RX to Arduino TX (Pin 2)
- ESP8266 TX to Arduino RX (Pin 3)
Make sure the power and ground pins are also properly connected.
-
Open the
IoT_Sensor_Data_Sender.ino
sketch from the repository in the Arduino IDE. -
Modify the following parameters in the sketch to match your setup:
token
: Replace with your server authentication token.server
: Replace with the IP address or hostname of the remote server.port
: Replace with the port number the server is listening on.
-
Upload the sketch to your Arduino board.
-
Open the Arduino Serial Monitor at a baud rate of 9600 to view the debug output.
-
When the sketch starts, it will attempt to connect to a WiFi network using the provided credentials. If the connection is successful, sensor initialization will occur.
-
The sketch will continuously read sensor data from the LM335 temperature sensor, LDR light sensor, and moisture sensor.
-
Sensor data is collected and formatted into a JSON object.
-
The formatted JSON data is sent to the remote server using a TCP connection.
-
Data transmission success or failure is indicated in the Serial Monitor.
-
The data transmission is scheduled to occur every 15 minutes based on an interrupt timer.
- Make sure to handle security and authentication properly if deploying this code in a production environment.
- Remember to adjust pins and connections as needed based on your specific hardware setup.
- This code is provided as a basic example. You can expand and customize it to suit your project's requirements.