[POC] python and ev3

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

Moderators: roger, gloomyandy, skoehler

New User
Posts: 9
Joined: Wed Nov 13, 2013 12:50 pm

Re: [POC] python and ev3

Postby GeekDude » Sun Nov 24, 2013 1:59 pm

I'm using the LeJOS image because I don't happen to own a wifi or usb ethernet adapter. The LeJOS image lets me use it over USB.

New User
Posts: 1
Joined: Mon Nov 25, 2013 3:30 am

python and ev3 - simple message send/receive

Postby jpmarno » Mon Nov 25, 2013 3:41 am

1.) I need an example program in python that I can send a message via wifi to the EV3 (the EV3 would then use the message command to do something in response to the text received. I wold also like to send a message from the EV3 to a python program on my mac via wifi.

2.) I would like an explanation of how I could use the RS-485 (i2c?) I am pretty sure on the new EV3 it is RS-485 - to interface a generic device to the EV3, I can write the RS-485 interface if given the spec. I would like to use the sensor block on EV3 software to read the value sent via RS-485.

I am willing to pay top dollar if I can get either, but I will pay a serious premium if I can get it in the next 3-4 days.

Anybody know how to do this?

- Jeff

leJOS Team Member
Posts: 965
Joined: Mon Feb 05, 2007 1:27 pm

Re: [POC] python and ev3

Postby lawrie » Mon Nov 25, 2013 2:37 pm

With leJOS, sending messages to the EV3 over Wifi is simple, you just use sockets.

For example, from python:

Code: Select all

import socket
s.send(("", 8001)

This worked for me, in the latest version of leJOS. It sends a message to the menu, which ignores it.

You would need to write a Java program on the EV3 that creates a server socket, accepts a connection on it, reads a message and does some action.

But do you want to use leJOS or the standard Lego software (as you mention using the sensor block, which is Lego software)?

With the Lego software it is slightly harder to establish a connection and then send a message to a message box, but I have seen examples of code that does this.

The EV3 supports i2c and its own version of uart, but not rs485. An i2c device that works for the NXT ought to work on the EV3 too. The uart protocol is probably a little more tricky to interface with.


New User
Posts: 9
Joined: Wed Nov 13, 2013 12:50 pm

Re: [POC] python and ev3

Postby GeekDude » Mon Dec 09, 2013 4:24 am

New and exciting project: EV3 web interface! (aka CoNXTroll3r)

Basing my work off of my previous work with nxt-python (unreleased), I've done the following:
  • Downloaded and installed the cherrypy python library (Google it, the forum only allows me 3 links per post)
  • Written a wrapper for the python library of the EV3 api. You initialize it with some basic measurements, and then you can say "spin left 90 degrees", or "move forward 30 centimeters". It doesn't have to be centimeters, just whatever unit you measured in.
  • Run a webcam streaming server on my laptop to do a live feed of the robot as it moves
  • Written a basic webpage with some buttons that cause the EV3 to move

Put all together, you get https://github.com/G33kDude/CoNXTroll3r

Here's an image of the website it runs. The webcam feed goes where it says "offline". I didn't bother putting the feed up for the sake of this picture.


An exciting application of this is that you can then control it over HTTP via a simple API. I've used Snap! to control the EV3 with its graphical programming language.


As for getting the EV3 onto the web without a WiFi adapter (I'm using the ethernet over USB feature of LeJOS firmware), I've done a simple bit of SSH port forwarding. I SSH into it with the PuTTY options to allow requests from other hosts, source port 8080, and destination Make sure it is set to "Local", and "Auto". This will make all web requests to your computer on port 8080 go to the EV3 on port 80.

Please don't criticize my html/js/css too badly, I reused my nxt-python webpage, which was the first time I've endeavoured to write a real webpage.
Please do criticize my python code and tell me if I've done something odd, poorly, or just flat out incorrectly.

Future plans:
  • Get webcam to interface with EV3 (not sure about the feasibility of this, especially when taking power draw into account)
  • Get a dedicated setup to run this
  • Get a (micro) WiFi adapter that works with the EV3 so I can stop jerry rigging the port forwarding

New User
Posts: 9
Joined: Wed Nov 13, 2013 12:50 pm

Re: [POC] python and ev3

Postby GeekDude » Wed Dec 11, 2013 5:28 pm

Why did you switch to a modified firmware as opposed to just giving a link to arm compiled python? Would it still work okay if I just compiled python myself, downloaded the github code/library, and put it on whatever firmware I have at that moment?

Edit: Any reason other than a custom start screen, that is

Posts: 26
Joined: Thu Mar 20, 2008 9:15 pm
Location: Switzerland

Re: [POC] python and ev3

Postby aegidius » Mon Aug 04, 2014 11:53 am

We merged Python 2.7 and the leJOS SD card distribution and use a TCP/IP gateway between Python and leJOS.
For more information consult http://www.aplu.ch

Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 3 guests