Arduino + rasPberryPI+ Ardulink + eHealth

Hi

I'm new on arduino and raspberrypi world and need some help with this.

I have this configuration:

-RaspberryPI 2

-Raspbian

-Configuration of Ardulink into raspberry LINK

-Arduino software installed into raspberry

-This is a code compiled and launched from raspberrypi

#include <eHealth.h>

// The setup routine runs once when you press reset:
void setup() {
  Serial.begin(115200);  
}

// The loop routine runs over and over again forever:
void loop() {

  float ECG = eHealth.getECG();

  Serial.print("ECG value :  ");
  Serial.print(ECG, 2); 
  Serial.print(" V"); 
  Serial.println(""); 

  delay(1);	// wait for a millisecond
}

And this is java class wich uses Ardulink

import org.zu.ardulink.Link;
import org.zu.ardulink.RawDataListener;
import org.zu.ardulink.event.ConnectionEvent;
import org.zu.ardulink.event.ConnectionListener;
import org.zu.ardulink.event.DigitalReadChangeEvent;
import org.zu.ardulink.event.DigitalReadChangeListener;
import org.zu.ardulink.event.DisconnectionEvent;

public class Main {

  
    private final static String COMPORT = "/dev/ttyS80";
    private final static int BAUDRATE = 115200;
    private static Link link;
    
	public static void main(String[] args) {
		System.out.println("Conecting...");
		
		connect();
			
	}
	
	public static void connect(){
		link = Link.getDefaultInstance();
		
		link.addConnectionListener(new ConnectionListener() {
			
	        @Override
	        public void disconnected(DisconnectionEvent e) {
	        	System.out.println("Error connect");
	        }

	        @Override
	        public void connected(ConnectionEvent e) {
	        	System.out.println("Connect succesful");
	        	try {
	        		System.out.println("Wait...");
	        		Thread.sleep(2000);
					System.out.println("Done!");
				} catch (InterruptedException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
	        }
	    });
		
		
		
		link.connect(COMPORT, BAUDRATE);
		
		startListenStatus();
		
	}
	public static void startListenStatus(){
		
		
		link.addDigitalReadChangeListener(new DigitalReadChangeListener() {

			@Override
			public void stateChanged(DigitalReadChangeEvent e) {
				// do something
				System.out.println("STATECHANGED: " + e.getIncomingMessage());
			}

			@Override
			public int getPinListening() {
				return 11;
			}
		});

		link.addRawDataListener(new RawDataListener() {

			@Override
			public void parseInput(String id, int numBytes, int[] message) {
				
				System.out.println("ParseInput: ");
		        StringBuilder build = new StringBuilder(numBytes + 1);
		        for (int i = 0; i < numBytes; i++) {
		            build.append((char) message[i]);
		        }
		        String msgString = build.toString();
		        if (msgString.startsWith("SERIAL")) {
		            msgString = msgString.substring("SERIAL".length());
		            // print data to console
		            System.out.println(msgString);
		            int dataNewPoint = Integer.parseInt(msgString);
		            // add new data point to the real time chart
		            
		        }
			}
		});
		
	}
	


}

Sensor eHealth is connect to arduino and arduino is connected to raspberrypi through usb cable.

The problem is that I not get any messages in console when launch java program.

Thanks for all

Doesn't the Pi have a forum?

You need confirm that the port on your RPi is what you have in your program is in fact;private final static String COMPORT = "/dev/ttyS80";If you are using generic code, the port may well be different for your setup.

Oh, and welcome to the forum, the Arduino forum that is :slight_smile:


Paul