1

How to post data from Raspberry PI to Cumulocity?

When I searched for the same I came across Connecting Raspberry Pi with cumulocity

But in my case I want to post to Cumulocity.

Jan Hommes
  • 5,122
  • 4
  • 33
  • 45
Knight
  • 61
  • 1
  • 11

2 Answers2

4

You can write your own Java Client and deploy it on the Pi to send data to cumulocity. After device registration you can connect to Cumulocity and start sending data.

To actually send something you have to use measurements:

MeasurementRepresentation mrep = new MeasurementRepresentation();
mrep.setDateTime(new DateTime(point.getTimestamp()));
mrep.setSource(platform.getInventoryApi().get(gId));        
Counter counter = new Counter();
counter.setValue(new MeasurementValue("12345", "unit"));
mrep.set(counter);

// platform is of the type Platform. Make sure to instantiate it!
Measurement measurement = platform.getMeasurementApi();
mrep = measurement.create(mrep);

In the example, I used a custom POJO called "Counter". This is also the name that will be displayed in the Cumulocity website. You can either create your own class (make sure the value is written in a MeasurementValue) or use one of the exisiting classes (i.e. c8y.TemeratureMeasurement).

DaGroove
  • 192
  • 1
  • 10
0

the document you linked is a prerequisite to send data to Cumulocity. When you connect the device as described there the device will start sending data to the platform.