EV3 to EV3 with bluetooth

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

EV3 to EV3 with bluetooth

Postby mindrenee » Tue Jun 24, 2014 6:31 pm

Hi everyone,

Did anybody got 2 EV3 bricks connected with bluetooth and got them send messages to each other? I want them to send each other their own position on the field. Are there any examples that I can use (with code)? I have no idea where I should start.

Thank you.
mindrenee
New User
 
Posts: 10
Joined: Tue Jun 24, 2014 6:23 pm

Re: EV3 to EV3 with bluetooth

Postby gloomyandy » Tue Jun 24, 2014 7:07 pm

How many EV3s do you want to link together? The most general way to do it is via a Bluetooth PAN (which is what we use to allow an EV3 to talk to a PC via Bluetooth). EV3 to EV3 via Bluetooth is a little tricky at the moment. It can be done but it is not possible without resorting to using Linux tools and modifying one of the EV3 startup scripts. Basically you have to modify one of the EV3s so that instead of being a Bluetooth PAN access point it is a PAN client. The following link has some of the details:
http://bluez.sourceforge.net/contrib/HOWTO-PAN
Once the client has connected you need to run the DHCP client on the network endpoint to obtain a network address. Once that is done the two EV3s are talking via TCP/IP and you can use the standard Java network classes to communicate between them. If none of this makes any sense then possible best not to try it at the moment.

If you only need to hook two EV3s together it may be possible to do so using the Bluetooth serial port interface (used to talk to an NXT), but I'm not sure if EV3 to EV3 is possible using that mechanism or not. Lawrie may be able to help with that...

Probably not the answer you wanted sorry! This is on my list to try and improve but so far there have not been many people with more then one EV3!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4078
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 to EV3 with bluetooth

Postby lawrie » Tue Jun 24, 2014 8:31 pm

EV3 to EV3 over Bluetooth serial should work, but the Bluetooth serial code has a lot of diagnostics in it at the moment and has not been tested much. If you look at the RemoteNXT project in the Git repository, NXTConnect and NXTReceive should work EV3 to EV3. Basically the leJOS on the EV3 works the same as leJOS on the NXT for this, so these programs should work EV3 to NXT, NXT to EV3, or EV3 to EV3.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Mon Aug 18, 2014 1:55 am

lawrie wrote:EV3 to EV3 over Bluetooth serial should work, but the Bluetooth serial code has a lot of diagnostics in it at the moment and has not been tested much. If you look at the RemoteNXT project in the Git repository, NXTConnect and NXTReceive should work EV3 to EV3. Basically the leJOS on the EV3 works the same as leJOS on the NXT for this, so these programs should work EV3 to NXT, NXT to EV3, or EV3 to EV3.


I have tried ev3 to ev3 and ev3 to nxt via bluetooth. The RemoteNxt code will work with the latter not the former.

Can you explain how to start a motor on the remote NXT?

The lejos NXT code- e.g. nxt.A.forward() - does not work because the EV3 RemoteNXT class has no such method.

I suspect it can be done with getNXTCommand().setOutputState() but I am not sure of the details .
And how does RemoteNXTMotorPort work?

As always, please excuse these questions if they show lamentable ignorance.

Rob
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby lawrie » Wed Aug 20, 2014 7:36 am

Hi Rob,

I think NXTConnect and NXTReceive work EV3 to EV3 as I said, but remote control of sensors and motors will only work if there is a NXT LEGO Communications Protocol (LCP) responder running on the EV3. The NXT menu program runs this but the EV3 menu does not. You can run the LCPRespond program from the RemoteNXT project on the target EV3, but the EV3 LCP responder is very incomplete, so I am not sure what will work.

To access motors on a remote NXT or a remote EV3 running LCPRespond, you need to do something like:

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.forward();
Delay.msDelay(1000);
m.stop();

NXTMotor is renamed UnregulatedMotor in the latest Git source.

I will add an example that does this to the RemoteNXT project.

This will only support simple unregulated motor methods. Those methods that require the motor regulator (like rotate) are not currently supported.

Note that the LEGO communications protocol for the EV3 is more complex than the NXT version and really requires all the Lego software to be running to support it, so leJOS does not support it. So you won't be able to access the motors and sensors of a remote EV3 running the LEGO software.

I will look into running RemoteRequestEV3 over a Bluetooth serial connection, as that should allow access to remote access to regulated motors. RemoteRequestEV3 is in the latest Git source and is intended to support remote access from Android devices. It currently only works over TCP (WiFi, Bluetooth PAN) connections, but could be made to work over Bluetooth Serial without too much work.

I am afraid that all these options for communications protocols at the network and application levels makes all this rather complex.

Lawrie
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Wed Aug 20, 2014 7:44 am

Thanks Lawrie for your help.

I have two ev3s and 1 nxt and am just trying to find a good solution for a project that will require up to 6 motors.
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby robusto » Fri Aug 22, 2014 12:58 am

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.forward();
Delay.msDelay(1000);
m.stop();

Hi Lawrie,

I can't get this code to work. There is a bluetooth connection between the ev3 and the nxt (because I can get the nxt to play a tone) but the motor does not start.

As you mentioned, a number of diagnostics appear with the RemoteNXT call (including confirmation of a connection to the nxt) and the last one is something like "sending headers".(there are a few of these and I can provide more detail if that is important which I doubt).
After that, nothing happens.

[*]Any clue why this is failing? Any tests I can do?
[*]Should I try running the same code from the PC - i.e PC to nxt via bluetooth, and see if that works?
[*]I am really resisting using two ev3s and wifi , but if I do, will I need a second wifi adapter?


Thanks in advance.

Rob
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am

Re: EV3 to EV3 with bluetooth

Postby lawrie » Sat Aug 23, 2014 3:03 pm

Try:

m.setPower(100);

I think the power might be preset to zero.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: EV3 to EV3 with bluetooth

Postby robusto » Mon Aug 25, 2014 11:54 pm

NXTMotor m = new NXTMotor(remoteNXT.getPort("A"));
m.setPower(100);
m.forward();
Delay.msDelay(1000);
m.stop();

Yes, that's the answer.
So with one ev3 and one nxt you can you run up to 7 motors (ev3 or nxt) with a bluetooth connection between the ev3 and the nxt.
robusto
Novice
 
Posts: 28
Joined: Sun May 04, 2014 11:14 am


Return to EV3 Software

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests

more stuff