rents
rents

Reputation: 848

Is there any documented example of using a custom sensor say TMP35 with cumulocity using Java

I am having a hard time understanding where exactly do we bind the hardware for example a TMP35 temperature sensor with the software (i.e. in the Java API).

Is there any documented example for this or any custom sensor (where the driver isn't already available)?

Or can anyone outline the approach to accomplish the same? Do I need to extend the c8y.lx.driver.Driver class?

Any pointers appreciated.


I believe that TMP35 has no means of communication to the cumulocity server. So maybe anyone can please provide a way to make a custom sensor (which has a means for communication as well and is Java-enabled) link with Cumulocity? That is what I am interested in knowing?

I know that there are some certified devices which are being supported out of the box.

Upvotes: 1

Views: 273

Answers (1)

André
André

Reputation: 716

There are two steps:

  1. Get the data from your analogue sensor with Java.
  2. Send the data to Cumulocity.

Step 1 is unrelated to Cumulocity. You need an ADC, and Google provides a few examples on how to connect those (like http://www.lediouris.net/RaspberryPI/ADC/readme.html).

Step 2 is then quite simple. Create a subclass of "MeasurementPollingDriver" and implement run(). Inside run(), query the sensor using the method from Step 1 and convert that into a measurement. Send that measurement using super.sendMeasurement(measurement). Here is an example.

If you have a device library with callbacks, you could just copy the code from MeasurementPollingDriver

TemperatureMeasurement measurement = ...;
MeasurementRepresentation measurementRep = new MeasurementRepresentation();
measurementRep.setSource(mo);
measurementRep.set(measurement);
measurementRep.setTime(new Date());
measurements.create(measurementRep);

Upvotes: 2

Related Questions