Skip to content

kushal4345/Sensor-data-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 Sensor Data API

A Node.js + Express REST API to collect and manage sensor data such as temperature, humidity, soil moisture, vibration, and location. MongoDB Atlas is used for cloud-based storage.


πŸš€ Features

  • βœ… RESTful API with Express.js
  • 🌍 Cloud database with MongoDB Atlas
  • πŸ“¦ Data Schema with Mongoose
  • πŸ•’ Auto-generated timestamps
  • πŸ“‘ Sensor data includes:
    • Temperature
    • Humidity
    • Soil Moisture
    • Vibration
    • Location (Latitude & Longitude)

πŸ› οΈ Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB Atlas
  • ODM: Mongoose

πŸ“ Project Structure

Sensor-data-Server/ β”‚ β”œβ”€β”€ models/ β”‚ └── SensorData.js # Mongoose schema β”‚ β”œβ”€β”€ routes/ β”‚ └── sensor.js # API route for data posting/getting β”‚ β”œβ”€β”€ .env # Environment variables (Mongo URI, PORT) β”œβ”€β”€ server.js # Main server file └── package.json


βš™οΈ Installation

  1. Clone the repo:
git clone https://github.com/your-username/Sensor-data-Server.git
cd Sensor-data-Server

Install Dependencies"

npm install PORT=3000
MONGO_URI=your_mongo_atlas_connection_string node server.js

πŸ“¬ API Endpoints Method Endpoint Description
POST /api/sensor Submit sensor data
GET /api/sensor Retrieve all sensor data


πŸ“Œ Example Sensor Data JSON

{ "temperature": 24.5,
"humidity": 65,
"soilMoisture": 40,
"vibration": false,
"location": {
"latitude": 28.7041,
"longitude": 77.1025
} }


🌐 Deployment
When deploying (e.g., on Render, Railway, or Heroku), ensure you:
Use process.env.PORT || 3000 in your server.js.
Store MONGO_URI securely as an environment variable.


πŸ‘¨β€πŸ’» Author Kushal Sharma
πŸ“§ [email protected]
πŸ”— LinkedIn https://www.linkedin.com/in/kushal-sharma-67378a279/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published