IBM Support

Viewing data from an IOT device in Maximo

Technical Blog Post


Viewing data from an IOT device in Maximo


Previously I used a Raspberry PI to enter data into Maximo, Logging data in Maximo with a Raspberry PI using Node-Red.

However sometimes we do not care about the history of data but only want to view a current value, for example the temperature, humidity and the barometric pressure in a room. This blog will show you how to view data from a JSON Resource.

An IOT device such as a Raspberry Pi or Beagle Bone Black can be used as a primitive REST server, in this case the server returns a basic JSON objects that can be used to display data in Maximo. The JSON Resources can also pass along data from Maximo, in our case the current Location. I have created a basic REST server on my Raspberry Pi and when I send a request, for example, the Raspberry Pi responds with,

  "location": "",
  "temperature": 29.4,
  "humidity": 41.35,
  "pressure": 994.04

If I pass along a location parameter, I also get the location with the JSON object. Creating a simple REST server on the Rapsberry Pi in Node-Red is as easy as this.



The top node "Save the readings from Sense Hat into Flow parameters." saves the latest available data so it can be used for the REST call.

// Save the incomming data in a variables that can be used in the flow.
// The Sense hat is reporting data on a regular basis but we only care about the latest.
return msg;

The "HTTP GET Request for Sensehat data" node adds a listening point on "/sensehat" so when a REST request comes in, it passes it to the "Create respons with Sensehat data." node.

// Here is a little bit of a hack.
// The Payload returned is something like, { "location=BASIN-W1": "" }
// This JSON Object does not work for me since the key is the whole request parameter.
// So I convert it back to a string and then grab the parameter after the equal sign.
payloadString = JSON.stringify(msg.payload);
location = payloadString.substring(payloadString.indexOf("=")+1, payloadString.length - 5);

// Grab readings from sense hat.
temperature = flow.get('temperature') || 0;
humidity = flow.get('humidity') || 0;
pressure = flow.get('pressure') || 0;

// Construct JSON response.
jsonResponse = { "location" : location, "temperature" : temperature,
                 "humidity" : humidity, "pressure" : pressure};

// Set Payload.
msg.payload = jsonResponse;
return msg;

The top part is a workaround when a "?location=My Location" is passed in, I'm not sure if this is a bug in Maximo or Node Red. Anyhow, the main point here is that a JSON object is created called jsonResponse that is returned from the REST request. The passed along location can be used to read a specific sensor, so the response is different between and However in my example we only have one set of sensors so we return the passed along Location to at least get some specific data. Now head over to Maximo and go to the JSON Resource module and create a new Resource.


Here we create a new resource called PILOC that will use the room temperature data from the Raspberry Pi. We want to use the data as an object in Maximo and it's a REST Resource. On the URL we specify the URL and the location parameter. I want to display this data in the Locations application and want to pass along the LOCATIONS.LOCATION attribute to the REST call. So if my current location in Maximo would be LOC1, the REST call from Maximo would be















Next I'll specify the parent object, in my case LOCATIONS and a sample, this is the response from above.


Let's ignore the bug that say CURRWEATHERZIP and click Process to create the JSON Resource. To use the Object, we can now add some fields to our Locations App. Head over to the Application designer and add four new fields to the application.



These fields should be added with an Attribute name of PILOC.LOCATION, PILOC.TEMPERATURE, PILOC.PRESSURE and PILOC.HUMIDITY. This is because the Object we create via the JSON Resource is called PILOC and the attributes are taken from the JSON Object returned from the REST server. Save your changes, log out and in again from Maximo and head over to the Locations app, bring up a record.



















This example returns the room data from the Raspberry Pi and also returns the location parameter passed in, this should always match the main Location field.

Hopefully this example will help you to get started with JSON Resources in Maximo.


[{"id":"fb3df4af.ec90a8","type":"http in","z":"1af30efd.0062e1","name":"HTTP GET Request for Sensehat data","url":"/sensehat","method":"get","swaggerDoc":"","x":190,"y":140,"wires":[["7d69fa9f.d12ab4"]]},{"id":"34c6efdf.dd7d7","type":"http response","z":"1af30efd.0062e1","name":"HTTP Response with data","x":810,"y":140,"wires":[]},{"id":"f8721182.733ab","type":"rpi-sensehat in","z":"1af30efd.0062e1","name":"","motion":false,"env":true,"stick":false,"x":100,"y":60,"wires":[["49878d05.aa4334"]]},{"id":"49878d05.aa4334","type":"function","z":"1af30efd.0062e1","name":"Save the readings from Sense Hat into Flow parameters.","func":"// Save the incomming data in a variables that can be used in the flow.\n// The Sense hat is reporting data on a regular basis but we only care about the latest.\nflow.set(\"temperature\",msg.payload.temperature);\nflow.set(\"humidity\",msg.payload.humidity);\nflow.set(\"pressure\",msg.payload.pressure);\nreturn msg;\n","outputs":1,"noerr":0,"x":410,"y":60,"wires":[[]]},{"id":"7d69fa9f.d12ab4","type":"function","z":"1af30efd.0062e1","name":"Create respons with Sensehat data.","func":"// Here is a little bit of a hack.\n// The Payload returned is something like, { \"location=BASIN-W1\": \"\" }\n// This JSON Object does not work for me since the key is the whole request parameter.\n// So I convert it back to a string and then grab the parameter after the equal sign.\npayloadString = JSON.stringify(msg.payload);\nlocation = payloadString.substring(payloadString.indexOf(\"=\")+1, payloadString.length - 5);\n\n// Grab readings from sense hat.\ntemperature = flow.get('temperature') || 0;\nhumidity = flow.get('humidity') || 0;\npressure = flow.get('pressure') || 0;\n\n// Construct JSON response.\njsonResponse = { \"location\" : location, \"temperature\" : temperature, \n                 \"humidity\" : humidity, \"pressure\" : pressure};\n\n// Set Payload.\nmsg.payload = jsonResponse;\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":140,"wires":[["497f05d3.6142ec","34c6efdf.dd7d7"]]},{"id":"497f05d3.6142ec","type":"debug","z":"1af30efd.0062e1","name":"REST Output","active":true,"console":"false","complete":"payload","x":790,"y":200,"wires":[]}]

[{"Business Unit":{"code":"BU055","label":"Cognitive Applications"},"Product":{"code":"SSLKT6","label":"Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":""}]