2017년 4월 8일 토요일

Lego Mindstorms EV3 support


My son tried to connect Lego Mindstorms EV3 to AppInventor but kept getting errors on the android device.
Has anyone been successful in getting EV3 working with AI2?

If the support needs to be built, has anyone looked at what it would take? I tried looking at the documentation 
on the Mindstorms site but the Bluetooth Developer Kit still talks about the NXT and I cannot find
anything EV3 specific.

I would be interested in helping with any efforts towards this..

--
There's been a few queries and some good intentions to get something
built, but nothing has come out off it so far.
Let us know if you want to work on this.

--
Yes, I am interested to work on this. Does anyone have access to the EV3 bluetooth documentation?

--
I don't have any official documentation, but I was able to look at the code here https://legoev3.codeplex.com/SourceControl/latest (which is C#) to figure out the bluetooth api. I found the Lego.Ev3.Core code to be the most helpful.

Earlier this year, I was successful in using App Inventor's BluetoothClient component to talk to an EV3 and control motors and lights and read sensors. I've attached my project. There a global variable block named EV3, which is set to the bluetooth address of my EV3. That block is in the lower-right of all the blocks. You'll need to change it to your EV3's bluetooth address.

Thanks Liz. I will try it out.

--
This worked like a charm. 

Liz, are you planning to add this to the repository? If you need help with that, I would be happy to help.

--
Sure. Do you think it's good enough for people to use and learn from? I haven't really looked at it since April.

--
Well, it worked right out of the box. I  have not experimented with it much. Will write back as we try more.

--
Ideally, someone would update the Mindstorms components to enable support for EV3.  In the shorter term, I think that the App Inventor gallery might be the best place for Liz's project.

--
We should make the bluetooth address more configurable. Maybe use a ListPicker that shows all the paired devices. I could do that.

--
It needs to be in a place where Google can easily find it. Liz, would you be ok if I put it as a question on stack overflow? You can answer with a link to this discussion.

--
Google (and MIT) can easily find it on the Gallery ;-)

--
How about I fix the app so that it uses a ListPicker for the bluetooth address, then I put it on the Gallery, then Alok can put a question on stack overflow and I can answer (I've never answered a question on Stack Overflow before!) it with a link to the Gallery.

--
SGTM

--
Here's the updated project with the ListPicker for choosing the EV3 bluetooth address. Can you check it out before I put it on the Gallery?


--
Yes, it is working. I was able to pick up the EV3 from the list picker and connect after that. Tried the motors, LEDs and music. Everything worked as advertised :)

I will add a question to StackOverflow and send you a link.

--
I uploaded the app to the gallery and answered the question on stackoverflow.

--
Hi everybody, i have a question, i've been trying to use your app and i goes well, my EV3 appears in the list, i pick it and make connection, but when i try to move a motor or turn on a led or anything, the app gets stuck, can you tell me what´s happenning? is because of my phone? aby help i will be so greatful, 

--
I have started porting your app to native JAVA in the appinventor code base and have the LED commands working with my sandbox.

So a couple of questions/doubts:

1. I assume it is worthwhile to have support for EV3 in mainstream app.
2. If the answer to 1 is yes, how do I get my current code reviewed. Once I know that the basic structure/style is good, I can
implement the rest of the functionality.

--
That's fantastic!

I'm not sure what the answers to your questions are. I think Andrew McKinney is the best person to answer and/or coordinate.

--
Any ideas on who can help me with this..

--
You are in the right group for that kind of work. I would recommend writing a design proposal before writing more code, mostly because the technical part (wrapping the android SDK) is generally the easy part when you are creating a component. The most difficult part is to come up with a good API, as in, the set of blocks and properties for your component.
You can find sample design proposals in this forum, and you'll see how it generally goes back and forth with feedback and comments with other group members. Once that's sorted, it would be good for you to upload a test server and companion so others can play with it and feedback again, and the last step would be to open a pull request through GitHub. Please note that although the code is important, there are several other concerns to address before doing a code review. The code might be perfectly written and tested but the component might not align with project goals, so there's no guarantee that it will be added to the main branch. That's why having several rounds of feedback while you are designing new functionality is helpful to everyone, not only to component developers but also reviewers. Hope that does not discourage you. Looking forward to hearing about your progress!

--
Thanks for your comments. I will write a proposal.

--
Hello, thanks you for share the app :D:D.

Can you explain me how works this app?

I need to make one app that i can start one aplication in ev3 using bluetooth.

--
I downloaded the app onto my Samsung Note 4 and paired the robot. The app showed it but the interface did not work. I installed on a Galaxy Tab 4 and it worked like a charm. Very nice, comprehensive interface. Thanks Liz Looney.

--

Would you mind if I post your file to the AppInventor2 Gallery so it will be available to everyone. I am planning on using the code with my AppInventor2 class. Students will modify the code to have the robot perform a series of programmed tasks. Yours was the only program I have found so far for AppInventor2 and the EV3.

--
I don't mind it being in the gallery. Should I post it myself?

--
That would be great if you posted it. This is definitely something that would be of value to others. I am not sure if you can add tags so people can search for it under EV3, Mindstorm, Lego.

Let me know when you have posted it so I can let my colleagues know it is there.

--
I published it. Here's the link: ai2.appinventor.mit.edu/?galleryId=4694699086970880

This is my first published project, so let me know if it looks OK to you.

--
I bought an EV3 about 2 months ago. I am extremely novice in programing but I do work in IT field. I had searched for way to make .apk files for Android for EV3 that had features that I could not find on other apps out there. At least not for EV3. lots for NXT. So Anyway I came across your appinventor 2 resource for EV3 and it is awesome by the way. I was able to figure out how to make my own interface with your programming that showed buttons to go forward back, left, right , etc. Yours is great just overwhelming to novice like me. So now I have a basic driving interface as described and stop button, I can connect to EV3 via Bluetooth etc. What I was wondering is if you could help direct me how to make a button let's say that would play a .wav or .mp3 file on the EV3? So the file would have to be loaded on the EV3 somehow of course also. I believe the file has to be 8 bit and I can make those files. But how do you get the file on the EV3 and how do you find it/play it by pushing a button on the mobile device? it might be nice to have access to the phone (maybe I could figure that out) and pick sounds form the phone to load onto the EV3 and have it play the files out of the EV3 speakers (like when you use the Lego software).  To that end it would be nice to understand how to run a program already loaded on the EV3 (created and sent to EV3 from the lego commander app) from the mobile device. Again maybe a list picker to display programs on the EV3 to call up when needed. This way I could make the EV3 seem like it is interacting with the environment by having different things happen at the touch of a button on the mobile device. Maybe it is a tall order. But any guidance here would be appreciated. or add that to the app you made in inventor. I leave that up to your discretion :). Thanks again and what you have there is awesome.

--
I'm glad you were able to use my App Inventor 2 project to make your own app to control your EV3.

I don't know how to send a file to the EV3 from App Inventor, but once the sound file is on the EV3, I think you can play it with the following blocks:
To hook that up to a button and use the file entered in a textbox, use these blocks:
I haven't actually tried this, but I hope it works.

I don't know how to run a program already loaded on the EV3.

--
Oops. I forgot the value for SUBCMD_SOUND_PLAY.

--
I tried your app and it worked very well.
Thanks a lot. It helped me.
I added backward move and changed the buttons from click to touch down and touch up.
It also worked very good.

My question is:
Your app uses the buttons 1-4 to read the sensors but now I want to move the motors A-D after the robot touch (-Sensor) the wall.
I could not find a way to do it
Would you please help me in this?

--
I'm glad my app helped you. I don't currently have time to experiment with my EV3, but I think that you could use a Clock component's Timer event to periodically check the data from the touch sensor (using the readInputDevice procedure). If the value from the touch sensor indicates that the sensor is pressed, you can then activate the motors (using the outputPower procedure).

I hope this helps!

--
Thanks
I will try it

--
Thanks for making your code available. I just finished two weeks of Robot Wars with my students and it would not have been possible without your code. The students worked with your app and then made their own buttons to control the robot. We then had a series of competitions with the robots that the students loved - robot obstacle course, robot dance and best song. Here is a link to the robot page for the course.


Thanks again, this would not have been possible without your code.

--
I'm really glad your course was a success!

--

Bluetooth Error 507 on Android 4.0.4, 4.1.2 & 4.4.4


I have an Arduino Uno R3 with a HC-06 Bluetooth module attached. Now I wanted to use AI2 to build an app which would send commands from Android 4.4.4 to the HC-06/Arduino.
The Arduino/HC-06 is fully functional and working well when sending data from my MacBook to the module. The AI2 app is also functional when sending data to my MacBook, however, when I pair the HC-06 with my Android device and try to use the AI2 app the connection will always fail resulting in error 507.

I used the search function/Google and found a few solutions which all did not work for me.
http://puravidaapps.com/btchat.php suggested retrying until the connection would be established, but this isn't happening. I also tried rewriting the app using a timer to reestablish (call BTClient1.connect address) a bluetooth connection every 5 sec, but this isn't working either. Initially I had the connection attempt on Screen.initialize, which failed in the same manner.

Some suggested using an earlier Android version, so I tried 4.1.2 and 4.0.4, but the error persisted.

Setting BTClient.secure to boolean true or false has no effect on the error.

Any other suggestions on how I can bring Android 4.4.4 AI2 apk to play nice with my HC-06?

-- 
This may help, it is specific to HC-06: App Inventor 2 tutorial - Android Control Arduino with HC-06 Bluetooth module 
Have you found an Arduino forum ... perhaps you would get more suggestions there?

You probably have seen some of these links, they refer to the 507 error   ....    https://www.google.com/search?q=bluetooth+error+507&oq=bluetooth+error+507&aqs=chrome..69i57.6319j0j7&sourceid=chrome&es_sm=0&ie=UTF-8     

You did not post a screen capture of your relevant blocks as a jpg png  so it is difficult for anyone to provide specific advice.  You might get more responses if you do that.

--
My english it isnt very well but I try to speach with you
I have the same problem about an connection with Bluetooth HC-06
I have seen the video and I use the same devices
Huawei Y300
arduino
Bluetooth Module HC-06
When I start the connection, appears the message error 507 ...... turn on?
sometimes the connection is established and everything works fine
If I connect to the app Amarino the connection is established every attempt
I understand that maybe the problem is in the app
Can anyone help me?

--
This thread in another forum may be a discussion of some of your issues: Lego Mindstorms EV3 support  

MIT is aware of some issues on EV3 and that might be the issue with the error message 507.   AI2 development people are working on this issue now.    There may be resources you can use in the above thread to temporarily solve your issue.    I do not do the robots stuff so I do not really know.

--
It's not a robot thing.  I get this error when I try to connect to any blue tooth device via an ai2 app.  I am using an HTC one M8.  If I use the just the phone connection and pair no problems. It's only when I do the connection in the ai2 app.  Any help would be great.

--
Some help is already in this thread:   Please read this: Lego Mindstorms EV3 support   If you read ALL the threads, it discusses a possible work around for the 507 error .  The thread is on the MIT Developers forum.    You might ask your question there within the thread and get a better response.  MIT is aware of an issue.

--

Bluetooth connection with multiple screens app inventor


I've design an app for android using app inventor, to send commands so that an Arduino microcontroller decode this commands. I've been watching tutorials all over youtube and I have manage to connect to a Bluetooth module HC-6. 

The problem is that I couldn't stay connected with the bluetooth module with the others screen, which consists of clicking the buttons to send the commands. Then I use the block "open another screen, start value" to send a variable that contain the  MAC Address of the android device. But after watching and reading a lot, I couldn't find an answer about why i cannot stay connected after changing screens in the app. In other words, In the main screen I can send data but when i try to send data from another another then the erro of loose connection appears. 

The error that shows up when the connection is lost is "Error 507" of app inventor.

--
for bluetooth I recommend you to use only one screen
to simulate different screens, just use vertical screen arrangements and set them to visible = false or true as needed

Advice: Before posting, it's a good idea to search in this forum. Many others have likely run into problems similar to yours. How to search see screenshot.

--
Thanks for your response! 

--
I'm not understand and I find in MIT and not see "vertical screen arrangements", Can you example for me

--
you can find the arrangements in the Layout drawer
PS: I deleted your duplicate post in the other thread for you. See also the Posting Guidelines.

--

search for Problem with error 507 for Bluetooth connection


... from another another then the erro of loose connection appears. The error that shows up when the connection is lost is "Error 507" of app inventor.
I'm trying to get a connection between an Android tablet and an Android phone with Bluetooth but error 507 occured, I don't know why because when i ...
Huawei Y300 arduino Bluetooth Module HC-06 When I start the connection, appears the message error 507 ...... turn on? sometimes the connection is ...
Neiter via the web connect nor as an app installed on the phone it establishes a bluetooth connection with the hands-free when selected. Failure message is: Error 507: Unable to connect. Is the device turned on? BUT when I ...
... say ''error 508 unable to listen for a connection from a bluetooth device'' and the client say ''error 507: unable to connect is the device turned on?
This seems to work for the first .connect instance on the new screen, however ALL subsequent connection attempts spawn the dreaded 507 error ...
hello !! i have a problem in connection between my application and my bluetooth module which i use in arduino.. and also has a problem in connect two device via bluetooth in a ... "Error:com.google.appinventor.components.runtime. bluetoothClient@1b0d09a6,507,Connect,unable to connect . Is your ...