azure-event-hubs-reactive/tools/devices-simulator
Devis Lucato b97bf98d66 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc.
New:
* Add sink to allow cloud-to-device messages
* Add API to stop the streaming
* Extend API to allow streaming a subset of partitions
* Add support for Scala 2.12 		
* Add device filter
* Add Message ID and Content Type to message

Improvements:
* Improve performance, reduce the number of threads used
* Add more demos
* Upgrade internal dependencies

Breaking changes:
* Change configuration schema
* Change message model schema
* Change environment variables names in the reference configuration
2017-01-06 18:03:56 -08:00
..
LICENSE 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00
README.md 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00
abstract_simulator.js 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00
download_credentials.sh 0.7.0 release (#8) 2016-10-26 16:13:10 -07:00
humidity_simulator.js 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00
package.json 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00
send.js 0.7.0 release (#8) 2016-10-26 16:13:10 -07:00
temperature_simulator.js 0.8.0 release: new features: C2D Sink, Stream Close, Scala 2.12, msg ID, etc. 2017-01-06 18:03:56 -08:00

README.md

Device simulator

The program simulates some Temperature and Humidity sensors. The values gradually increase and decrease, within a range of 6 minutes, with random peaks.

How to run the device simulator

First of all you should create an Azure IoT hub instance. You can create a free instance selecting the "F1 Free" scale tier.

Once you have an IoT hub ready, you should take note of:

  • the connection string from the Shared access policies panel, for the device policy.

Create the devices

Creating devices is vey simple, thanks to the IoT hub explorer, which you can run from the command line.

From here on you should use a terminal with Node.js and Node Package Manager (npm) ready to use.

To install IoT hub explorer, open a terminal and execute

npm install -g iothub-explorer

Once the IoT hub explorer is installed, proceed to create the devices:

  • Login, using the connection string obtained earlier:
CONNSTRING="... device connection string ..."
iothub-explorer login '$CONNSTRING'
  • Create some devices, e.g. using using a Bash terminal:
for i in {1000..1010}; do iothub-explorer create device$i --display="deviceId"; done

Prepare the simulator

In order to run, the simulator needs the credentials for each device just created. The following command creates a credentials.js file with the settings required.

From the terminal, 'cd' into the same folder of this README document, and execute:

export CONNSTRING="... device connection string ..."
./download_credentials.sh
unset CONNSTRING

Run the simulator

Open a bash terminal in the same folder of this README document and execute:

npm run send

The simulator will start sending data every second, for each device created.