Skip to content

Ayush-Kumar0207/anedya-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ Anedya IoT Hardware Simulator

A cloud-native virtual IoT device that streams real-time telemetry to the Anedya Platform β€” powering your dashboard without physical hardware.

Node.js Deployed on Render Dashboard License: ISC PRs Welcome


πŸ”„ Runs 24/7 on Render Β· πŸ“‘ Sends data every 5 seconds Β· πŸŽ›οΈ Listens for relay commands in real-time


Live Dashboard β†— Β· Report Bug Β· Request Feature


πŸ“– Table of Contents


🧠 About The Project

Building an IoT dashboard is exciting β€” until you realize you need actual hardware to generate data. This simulator eliminates that barrier entirely.

Anedya IoT Hardware Simulator is a lightweight Node.js service that acts as a virtual IoT device, continuously pushing realistic sensor telemetry (temperature & humidity) to the Anedya IoT Cloud. It also listens for incoming device commands (like relay toggles), simulating a full hardware lifecycle β€” all from a simple cloud deployment.

Why This Exists

Problem Solution
No physical hardware for development Virtual device generates realistic data
Dashboard needs continuous data stream Simulator runs 24/7 on Render
Testing command delivery is hard Automatic command polling & acknowledgment
Need real API integration, not mocks Direct Anedya Cloud API communication

βš™οΈ How It Works

The simulator performs two continuous operations in parallel:

πŸ“‘ Telemetry Transmission (every 5s)

  • Generates randomized but realistic sensor readings:
    • 🌑️ Temperature: 20.00Β°C – 30.00Β°C
    • πŸ’§ Humidity: 40.00% – 60.00%
  • Submits data via Anedya's Device API using the Connection Key
  • Data appears instantly on the IoT Dashboard

πŸŽ›οΈ Command Polling (every 2s)

  • Polls the Anedya Cloud API for pending device commands
  • Processes commands like toggle-relay and logs hardware state changes
  • Enables dashboard β†’ device communication

πŸ— Tech Stack

Layer Technology Purpose
Runtime Node.js JavaScript runtime
HTTP Client Axios API communication with Anedya
Web Framework Express Keep-alive server for Render
IoT Platform Anedya Device management & data storage
Deployment Render 24/7 cloud hosting
Dashboard React Companion dashboard on Vercel

πŸ› Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        RENDER (Cloud)                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              Anedya IoT Hardware Simulator                 β”‚  β”‚
β”‚  β”‚                                                            β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    every 5s    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚   β”‚  Telemetry   │──────────────▢│  Anedya Device API   β”‚  β”‚  β”‚
β”‚  β”‚   β”‚  Generator   β”‚   POST data   β”‚  (ap-in-1 region)    β”‚  β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚                                              β”‚              β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    every 2s    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚   β”‚  Command     │◀──────────────│  Anedya Cloud API    β”‚  β”‚  β”‚
β”‚  β”‚   β”‚  Poller      β”‚   FETCH cmds  β”‚  (ap-in-1 region)    β”‚  β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚                                                            β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                          β”‚  β”‚
β”‚  β”‚   β”‚  Express     β”‚ ← Keeps Render free tier alive          β”‚  β”‚
β”‚  β”‚   β”‚  :PORT       β”‚                                          β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   IoT Dashboard (React)       β”‚
              β”‚   Vercel Deployment            β”‚
              β”‚   Real-time data visualization β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Project Structure

anedya-simulator/
β”œβ”€β”€ simulator.js        # Core simulator β€” telemetry + command engine
β”œβ”€β”€ package.json        # Dependencies & project metadata
β”œβ”€β”€ .gitignore          # Ignores node_modules, .env, logs
└── .env                # Environment variables (not committed)

Intentionally minimal. One file. One purpose. Zero bloat.


⚑ Quick Start

Prerequisites

  • Node.js v18+
  • An Anedya account with a configured project & node

Installation

# Clone the repository
git clone https://github.com/Ayush-Kumar0207/anedya-simulator.git
cd anedya-simulator

# Install dependencies
npm install

# Configure environment variables
cp .env.example .env
# Edit .env with your Anedya credentials (see below)

# Start the simulator
node simulator.js

You should see output like:

πŸš€ Anedya IoT Hardware Simulator (STRICT CLOUD MODE)
- Communication: Strict Cloud API (AP-IN-1)
----------------------------------------------------
🌐 Dummy Web Server listening on port 3000 to satisfy Render.
[Telemetry] Sent to Cloud: Temp=24.37Β°C, Hum=52.18%

πŸ” Environment Variables

Create a .env file in the project root:

# Anedya Device Connection Key
# Found in: Anedya Console β†’ Your Project β†’ Node β†’ Connection Key
CONNECTION_KEY=your_connection_key_here

# Anedya Project API Key
# Found in: Anedya Console β†’ Your Project β†’ Settings β†’ API Keys
API_KEY=your_api_key_here

# Anedya Node ID
# Found in: Anedya Console β†’ Your Project β†’ Nodes β†’ Node ID
NODE_ID=your_node_id_here

# Server port (optional, defaults to 3000)
PORT=3000
Variable Required Description
CONNECTION_KEY βœ… Authenticates telemetry submissions to Device API
API_KEY βœ… Authenticates command fetching from Cloud API
NODE_ID βœ… Identifies the virtual device node in Anedya
PORT ❌ Web server port (auto-set by Render)

πŸš€ Deployment

Deploy to Render (Recommended)

This simulator is designed to run as a Render Web Service on the free tier.

  1. Push to GitHub

    git add .
    git commit -m "Initial commit"
    git push origin main
  2. Create a Web Service on Render

    • Go to render.com β†’ New β†’ Web Service

    • Connect your anedya-simulator repo

    • Configure:

      Setting Value
      Runtime Node
      Build Command npm install
      Start Command node simulator.js
      Plan Free
  3. Add Environment Variables

    • In Render dashboard β†’ Environment tab
    • Add CONNECTION_KEY, API_KEY, and NODE_ID
  4. Deploy β€” Render will build and start your simulator automatically.

πŸ’‘ Why Express? Render's free tier requires an HTTP listener to keep the service alive. The Express server on PORT serves this purpose while the simulator runs in the background.

Run Locally

node simulator.js

The simulator will start sending telemetry immediately and log all activity to the console.


πŸ“Š Dashboard Integration

This simulator is the data engine behind the IoT Dashboard:

Component Repository Deployment
Simulator (this repo) anedya-simulator Render
Dashboard IOT_Dashboard_using_React Vercel β†—

Data Flow: Simulator β†’ Anedya Cloud β†’ Dashboard (via Anedya API)


πŸ”’ Security

  • βœ… All credentials stored as environment variables β€” never hardcoded
  • βœ… .gitignore excludes .env, logs, and debug files
  • βœ… API communication over HTTPS exclusively
  • βœ… Connection Key used for device-level auth (scoped to single node)
  • βœ… API Key used for project-level cloud operations

⚠️ Never commit your .env file. Rotate keys immediately if exposed.


πŸ—Ί Roadmap

  • Add more sensor types (pressure, light, motion)
  • Configurable data ranges via environment variables
  • WebSocket support for bi-directional communication
  • Simulate multiple devices concurrently
  • Add data anomaly simulation for alert testing
  • Health check endpoint with uptime stats
  • Docker containerization

🀝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/multi-device-sim)
  3. Commit your changes (git commit -m 'Add multi-device simulation')
  4. Push to the branch (git push origin feature/multi-device-sim)
  5. Open a Pull Request

❓ FAQ

Why does it need Express if it's just a simulator?
Render's free tier requires an active HTTP listener to keep the service running. The Express server satisfies this requirement while the actual simulation runs via setInterval loops.
How accurate is the simulated data?
Temperature ranges from 20–30Β°C and humidity from 40–60% β€” realistic for indoor IoT sensors. Values are randomized with 2 decimal places for authentic-looking data streams.
Can I use this with a different IoT region?
Currently configured for ap-in-1 (Asia-Pacific India). To use another region, update the DEVICE_URL and CLOUD_URL constants in simulator.js.
Will this work with Anedya's free plan?
Yes. The simulator uses standard Device and Cloud APIs that are available on all Anedya plans.

πŸ“œ License

Distributed under the ISC License. See LICENSE for more information.


πŸ‘¨β€πŸ’» Author

Ayush Kumar

GitHub


🌟 Star This Repo

If this simulator helped you build your IoT project without hardware, consider giving it a ⭐

It helps others discover this tool and motivates further development!

Star History

About

Virtual IoT device simulator that streams real-time telemetry (temperature/humidity) to Anedya Cloud. Built with Node.js for seamless IoT dashboard development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors