top of page

Tutorial: Set up REST API on the nodeG5 edge IoT gateway to collect & parse data into JSON format.

TUTORIAL STEPS

We will be going to be running through the following steps:

1.     Set up a REST API response Mocking Rule

2.     Configuring the target device HTTP GET URL, data format & fields with a JSON file

3.     Confirming that the nodeG5 receives data from the target device.

4.     (Optional) Process the data received from devices.

5.     Send the refined device data to a designated AWS IoT Core MQTT broker.

STEP 1: Setting up the REST API response Mocking Rule.

 

We will be using a service called Beeceptor which allows you to set up an API response Mocking Rule that provides the following JSON data frame response when it is queried:

JSON set beeceptor.png

STEP 2: Configuring the target device HTTP GET URL, data formats & fields in a JSON file

Next the user will also need to upload a JSON "asset" file into the nodeG5 that includes the (i) GET URL, the (ii) list of fields that need to be retrieved at each polling loop & (iii) the format of each of those fields. Here is an example of the JSON file in the URL link below:

 

URL: https://g5tester.free.beeceptor.com/operation/site3/status

Parse: JSON

Example Field: controlResponse.pumpStation.pumps..pump.1pressure

JSON beeceptor answer.png

STEP 3: Confirming that the nodeG5 receives data from the target device.

At this point, to confirm that the nodeG5 receives data from the target device, you can enable a "test mode" to monitor the process within the script in the console.

If the target device (or Beeceptor API mocking service) responds as expected, the data point "25" will be parsed and inserted into the on-board database.

JSON parsed data.png

STEP 4: (Optional) Process the data received from devices.

You are now ready to directly send the parsed data to the cloud.

 

Alternatively you can also refine the data with your own custom scripts before sending it by using our Python library. Some of the advantages of preprocessing data at the gateway level is that it could help you refine & reduce amount of data you are sending; you also end up with a leaner data lake filled with more relevant data.

STEP 5: Send the device data to a designated AWS IoT Core MQTT broker

 

The nodeG5 comes with integrated cloud SDK client for AWS IoT Core, AWS Sitewise, Azure IoT Central, Azure IoT Hub & Ubidots. There is also a TLS secured MQTT client that will enable you to send to any designated MQTT broker.

In the below example, the data obtained is securely received in AWS IoT Core under "Things". For a more detailed tutorial to set up AWS IoT Core with our gateway, you can see the following link: AWS IoT Core set up.

aws json receive.png
bottom of page