Skip to main content



      Home
Home » Eclipse Projects » Kura » Receiving sensor data in Eclipse via Kura (IoT)(Help with receiving sensor data in Eclipse via Kura )
icon5.gif  Receiving sensor data in Eclipse via Kura (IoT) [message #1754411] Fri, 17 February 2017 07:58 Go to next message
Eclipse UserFriend
Hi, everyone.

I'm working on an IoT project. The objective is to receive sensor readings data (in this case, a thermostat) in Eclipse, so that a management application can be developed later on.


    The sensor is plugged in a microcontroller. The microcontroller is connected to a Raspberry Pi gateway via WiFi (the gateway's WiFi).

    The Raspberry Pi is running a Linux server, and on top of it is Kura Framework.

    The Raspberry Pi is connected to a router, and then to my computer.

    All of the itens listed above are already working. The sensor is reading temperature data, sending it to the gateway via WiFi and the linux server within sends the data to my computer, on which I can read it in a terminal (PuTTY).

    The Kura web UI is also working.


Now, I need to make this data that is being received on PuTTY to be transmitted to Eclipse instead, or to Kura web UI and then to Eclipse. That way, I can manipulate the data anyway I want.

To help develop all of this I'm following the steps in Eclipse Kura documentation, and it has helped A LOT so far, but now that it has come to receive the sensor data, I got stuck.

Does anyone has any hints, tutorials or documentations that can help me with this?

Thanks in advance!
Re: Receiving sensor data in Eclipse via Kura (IoT) [message #1754452 is a reply to message #1754411] Fri, 17 February 2017 17:34 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

How are you viewing the data via PuTTY? Is the data being stored on the Pi? What is the protocol being used to send data from the sensor to the gateway?

Thanks,
--Dave
Re: Receiving sensor data in Eclipse via Kura (IoT) [message #1754597 is a reply to message #1754452] Mon, 20 February 2017 11:40 Go to previous messageGo to next message
Eclipse UserFriend
Hello, thank you for answering.

I added a screen capture showing how the data is being shown. The value of the thermostat is the sole number at the end.
index.php/fa/28539/0/

Apparently, the MQTT protocol (the one being used; further explaining below) has some sort of storing method running by itself, and I'm planning on storing the data on the Pi further on, but right now just reading the data being send at the moment is enough.

The protocol being used is MQTT, and the data is being published using topics. The main problem, you could say, is that I need to validate user/password and then subscribe to the topic transmitting the data. Both are things I'm having trouble with.

Any help is appreciated!
Re: Receiving sensor data in Eclipse via Kura (IoT) [message #1754831 is a reply to message #1754597] Wed, 22 February 2017 17:15 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

I am afraid I am even more confused. I will try different questions:

You said the microcontroller is connected to the RPi via WiFi. How is it sending messages to the RPi? Is the microcontroller running an MQTT client? Is the RPi running an MQTT server?

Thanks,
--Dave

Re: Receiving sensor data in Eclipse via Kura (IoT) [message #1754968 is a reply to message #1754831] Fri, 24 February 2017 12:25 Go to previous messageGo to next message
Eclipse UserFriend
The microcontroller is sending data to the RPi using MQTT protocol, and the RPi isn't sending data anywhere yet.

The message shown in the "temperature data putty.PNG" is from a .log file in the linux server, being accessed via PuTTY.

What I need is to find out how to make these messages appear on the Eclipse console, too.
icon3.gif  Re: Receiving sensor data in Eclipse via Kura (IoT) [message #1754972 is a reply to message #1754968] Fri, 24 February 2017 12:49 Go to previous message
Eclipse UserFriend
I've managed to show the data in Eclipse. Here's the code for the update method that is being called every time data is send:

private Map<String, Object> properties;

public void updated(Map<String, Object> properties) {
  this.properties = properties;
  String broker   = "";
  String clientId = "";
  String topic   = "";
        
  if(properties != null && !properties.isEmpty()) {
            
    broker = (String) properties.get("broker.name");
    clientId = (String) properties.get("clientId.name");
    topic = (String) properties.get("topic.name");
        	
    doDemo(broker, clientId, topic);
  }
}

public void doDemo(String broker, String clientId, String topic) {
  MemoryPersistence persistence = new MemoryPersistence();

  try {
    MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
    MqttConnectOptions connOpts = new MqttConnectOptions();
    connOpts.setCleanSession(true);
			
    sampleClient.setCallback(new MqttCallback() {
      public void connectionLost(Throwable cause) {}

      public void messageArrived(String topic, MqttMessage message) throws Exception {
        System.out.println("Message: " + message.toString());
      }

      public void deliveryComplete(IMqttDeliveryToken token) {}
    });
			
  sampleClient.connect(connOpts);
  sampleClient.subscribe(topic);
			
  } catch(MqttException e) {
    e.printStackTrace();
  }
}

Previous Topic:Eclipse compilation problem for another directory besides workspace
Next Topic:MQTT Subscribe not working using DataService
Goto Forum:
  


Current Time: Sat Jul 12 22:39:07 EDT 2025

Powered by FUDForum. Page generated in 0.05123 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top