Skip to content

A small simulator to create some measurement and publish them over MQTT. You can simulate an DHT22 or any other sensor.

Notifications You must be signed in to change notification settings

ElevenSpins/Sensor_Simulator_NodeJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sensor Simulator

Generate multiple MQTT publishes in several topics. In this case i Simulate a DHT 22 for an Arduino ans push the temperature and the humidity to the MQTT Broker.

  • JS modules.
  • Create a real simulator of every sencor you want.
  • Modular to fit different use cases: big IoT applications or even small tests for api or something else.
  • Pushes the data in a JSON format and add a timestamp to every measurement.

Size Limit CLI

How It Works

  1. This application contains several node packages. In this project are two packages used: mqtt, moment
  2. Edit the configurations to the measurements and topics you need. See the part below.
  3. The appication generate random values in a specific range. After it will build the topic to be pusblished on.

Usage

JS Applications

It's very easy to use this simulator for every of your projects.

  1. Download and run the project:

    $ git clone 'repo'
    $ cd 'repo'
    $ npm install
    $ node simulator.js

Config

Size Limits supports three ways to define config.

  1. The genreal MQTT Config

     const connectoptions = {
     cmd: 'connect',
     protocolId: 'MQTT', 
     protocolVersion: 4, 
     clientId: 'Simulator',
     clean: true,
     keepalive: 10, 
     port: 1883,
     will:
         {
             topic: 'your/crazy/Topic/',
             payload: new Buffer('offline'), // Payloads are buffers
         },
  2. Build the topic path

    const homeTopic = 'your/crazy/'
    const anlage = 'topic/'
    
    const topicTemp = homeTopic + anlage + 'Temperatur'
    const topicLuft = homeTopic + anlage + 'Luftfeuchtigkeit'
  3. The publish:

       client.publish(topicTemp, JSON.stringify(temp, null, 0), { qos: 0, retain: false, dup: false })

About

A small simulator to create some measurement and publish them over MQTT. You can simulate an DHT22 or any other sensor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published