Skip to content

InfluxCommunity/MQTT_Simulators

Repository files navigation

MQTT Simulators

This repoistory will allow you to spin up differnt MQTT simulators producing fake IoT data for differnt scenerios.

Scenarios

Emergency Generators (Payload: JSON)

Each generator will write to its own MQTT topic the following values:

  1. Load
  2. Voltage
  3. Fuel Level
  4. Temperature

The payload will look like this:

{"generatorID": "generator1", "lat": 40.68066, "lon": -73.47429, "temperature": 186, "power": 186, "load": 2, "fuel": 277}

Construction Yard (Payload: Single Value) (WIP)

Each vehicle will write to its own MQTT topic and subtopics the following values:

  1. Speed
  2. Temperature
  3. Vibration

The payload will look like this:

RoadRoller/Temperature 24.1
RoadRoller/Speed 12
RoadRoller/Vibration 1.00394

To run this construction site example make sure to uncomment the correct sections of the MQTT Input plugin in the the telegraf.conf and docker-compose.yml. Also make sure to replace the commands below with the right pathways, i.e:

docker build -t construction-site:latest ./construction_site 

Setup

There are two ways to setup this Sim: Docker + Locally

Option 1: Docker (Recommended)

  1. Clone this repo to your system
git clone https://github.com/Jayclifford345/mqtt-emergency-generator.git
  1. Build the simulator docker image:
docker build emergency_generator/. -t emergency-generator:latest
  1. Deploy the docker-compose file:
docker-compose up -d

Option 2: Locally

  1. Install the Mosquitto MQTT Broker onto your device:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudp apt-get install mosquitto
  1. Start the Mosquitto broker:
sudo systemctl enable Mosquitto
sudo systemctl start Mosquitto
  1. Clone this repo to your local system:
git clone https://github.com/Jayclifford345/mqtt-emergency-generator.git
  1. Naviage to this folder
cd mqtt-emergency-generator/tree/master/generator_simulator
  1. Install the pip requirements
RUN python3 -m pip install --no-cache-dir -r requirements.txt
  1. Setup your enviroment variables
export GENERATORS=3
export BROKER=localhost
  1. Run the the simulator
python3 src/emergency_generator.py

Edge to Cloud Replication

This section will teach you how to configure InfluxDB OSS to send data to InfluxDB Cloud.

To use this option, first uncomment the InfluxDB Output section of telegraf.conf and uncomment out the current InfluxDB Output section which is configured to write directly to InfluxDB Cloud.

  1. Create a remote connection
influx remote create --name cloud --remote-url https://us-east-1-1.aws.cloud2.influxdata.com --remote-org-id <ORG_ID> --remote-api-token <CLOUD_TOKEN>
  1. Create a replication between a local bucket and a cloud bucket
influx replication create --local-bucket-id 1f158076adc417f5 --remote-bucket-id 621a1bf27327b2fc --remote-id 0947082f21c3e000  --name edge_to_cloud

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages