Arduino Yun - Buiding a Simple App on Desktop.

Hi, everybody.

We are working on the "Push Notification" project based on Arduino Yun. We have succeed to send a email and text message by a simple push button. Now, we need to create a simple application which can edit contact information and messages. By the time, we have tried to use Visual Studio 2012 to create the application. Here is our demo for the app.

We want to be able to change email address whenever we want by a simple fuction through this app.

Here is the code for sending email.

Our instructor told us to use serial port command in Visual Studio 2012 and Arduino program to make it work but we can't figure it out so far.

If anybody has an answer for this one, we really appreciate.

Thank you for your time.

Sincerely, Eugene.

First, why have you not asked your question in the Yun section of the Forum?

Second, where does the Yun fit into the project?

Third, post your Arduino code.

Fourth, if you are content to use a browser as the user interface you could do the entire thing on a Yun - that's why it has a Linux side.

...R

tonggiang001:
Our instructor told us to use serial port command in Visual Studio 2012 and Arduino program to make it work but we can't figure it out so far.

I'm going to assume your instructor has a valid reason for having you do it that way. It's certainly possible, but I can think of a bunch of better and easier ways to do it. Personally, I don't like the way that Visual Studio and .Net handle the serial port -- it's cumbersome and I find I have to write a lot of wrapper code to come up with a good asynchronous serial port that fires events as data comes in.

So, assuming you MUST use the serial port, you will plug the Yun's micro-USB connector into your computer, and note the COM port number that gets assigned to it. You will use that port with your application. Then, in the sketch, you need to use the Serial object to handle the Yun's side of the serial link. You'll need to come up with a protocol to reliably send the new address over the serial port and receive it on the Yun (you need to check for transmission errors, and be able to tell the start and end of the email address.)

Once you receive the email address on the Yun, you can put it in a variable, and use it in place of the constant string that's in your sketch now. If you do that, you'll have to send the email address to the Yun every time you power up or reset the sketch. If you need it to survive power cycles and remember the uploaded email address, you'll need to look at the EEPROM library to store the address in EEPROM when it is updated and read it out of EEPROM on power up, or use the FileIO class,, or work out a way to send/get that address from the Linux side, and have some Linux code store it on disk.

Hopefully that will get you going. Since this is obviously a learning exercise, I'm not going to give you actual code, you'll need to work that out yourself. I might have given too strong of a hint already.

If I were doing it, I would communicate with the Yun over the network - I think it's actually easier than using the serial port. There are many options if you go that route.

Thanks you, Robin and ShapeShifter for replying.

I'm sorry to put it in the wrong category because I'm new to this forum.

Anyway, we don't have to use the serial port to solve this problem. My professor just tried to give us a hint. Since both of you guys said we should use the network to control the Yun, do anybody have any source over the internet so that can guide us to a solution?. We will try to research, but we still appreciate for any help.

tonggiang001:
but we still appreciate for any help.

You have not clearly explained what you want the Yun to do and what the PC will be doing.

...R

Robin2:
You have not clearly explained what you want the Yun to do and what the PC will be doing.

Yes, the better the problem statement, the better the answers. Besides just the problem statement, it would be helpful to know what is the intended learning experience: is this strictly a programming exercise? Is the subject matter networking or communications? Is the sending of the email the primary goal, or is it some sort of control/sensor project and sending the email is a small part of it? Knowing what you are trying to accomplish and what you are trying to learn would give better answers.

Taking it at face value, and strictly answering the question of being able to remotely change the destination email address, my first thought is to use the Bridge Library and the Bridge.get() method to read a new email address. Get the value periodically, look to see if it has changed, and if so store it away for future use.

Then, to change the value, you can easily test the sketch code by using a web browser to access the page http://arduino.local/data/put/key/value where "arduino" is the name of your Yun, "key" is the key name you are using for the Bridge.get() call, and "value" is the new email address. This will automatically put the value to the Bridge under that key name, so you can easily call Bridge.get() to read that value.

Once you have that part working, you can use something like the WebClient class to access that same URL from within your VisualStudio application, and send the new email address to the Yun.

The other option is to do most of this work on the Linux side of the Yun, where it can send an email more directly than going through Temboo. As Robin mentioned earlier, if you don't need the VisualStudio application to meet your instructor's requirements, you can implement a web interface completely on the Yun. You could either do it manually with a full html/cgi implementation, or there are several frameworks available that greatly simply web application development (I've recently been playing with the Bottle framework under Python - I think I first heard about it from Robin. It would probably easily do what you are trying to accomplish, whatever that is.)

Ok Robin. I will explain clearly

"A system designed that simply has a series of buttons I can push to notify different people.
I can simply pushes the button to notify anybody. The system should be USB connectable to her PC to allow here to change the messages, phone numbers, email addresses, etc. easily through an application."

  1. what do I want the Yun to do?
  • We want to send either email or text message SMS to person who have his/her contact information stored in microcontroller, and we choose the Arduino Yun as our microcontroller. Because The Yun can be easier to connect to wifi, ethernet; most of all it can do a lot of thing for our project. Here is the example code which used to send email that already available in Arduino program.

So we will be able to send email to "alavi@uta.edu" when we process the code. If we want to send email to a different person, we just need to replace that email address and upload the code.

2.what will the PC be doing?

  • We will connect the Yun to PC desktop. We want to be able to change the email address of the person we want to send email anytime we like; with a simple function. For example, we just create a PC application demo (it doesn't work theoretical). Here is the picture.

As you see, the "Key 1", "Firt Name" and "Last Name" are consider as ID tracker. We want to change email address of Kambiz Alavi into new email addres like "eugene@uta.edu". Then we will press "update Contact" button. We expect that will automatically change and save the new email address in the Yun.

Like I said, you guy told me I shouldn't use serial port to solve this problem. We can use the network to communicate the YUN, but I need some sources for that. I still keep searching. Thank you.

ShapeShifter:
if you don't need the VisualStudio application to meet your instructor's requirements, you can implement a web interface completely on the Yun. You could either do it manually with a full html/cgi implementation, or there are several frameworks available that greatly simply web application development (I've recently been playing with the Bottle framework under Python - I think I first heard about it from Robin. It would probably easily do what you are trying to accomplish, whatever that is.)

I think my professor can accept the Web method because he only want a simple function for user. Do you have any clearly instructions or resources that I can look at.

tonggiang001:
I think my professor can accept the Web method because he only want a simple function for user.

Are you sure? Are these your professor's words that are calling for a USB connection?

tonggiang001:
"A system designed that simply has a series of buttons I can push to notify different people.
I can simply pushes the button to notify anybody. The system should be USB connectable to her PC to allow here to change the messages, phone numbers, email addresses, etc. easily through an application."

Do you have any clearly instructions or resources that I can look at.

I don't want to do the project for you, you should be doing your own work and research.

If you want to go with the bridge method using the the simple /data/put/ URL above, I think the links and class names I provided above should be enough to get you started.

If you want to make a web application and do it all on the Yun without a PC application (use a web browser on the PC) then take a look at the Bottle or Flask frameworks, or similar frameworks, as they can simplify things (even though they may be overkill for a project like this.) For example, the Bottle site has a sample to-do list application tutorial where it generates some simple web pages to display and set information, saving the data between runs in a simple database.

While not necessarily the simplest/fastest way to approach it because of the leaning curve, knowing what I know now (which in no way covers every possible method) my instinct on approaching a task like this is to do most of it in Python and Bottle (but that could just be because that is what I'm currently in the process of learning, and I like what I see so far.) I would use Bottle running on the Yun to develop a simple web app to take the place of the PC application, and allow configuring what each button does. That information is stored in a simple sqlite database, just like the Bottle tutorial to-do application. Then, the sketch on the Yun is looking for key presses, and when it finds one, it uses a Process object to run a Python script on the Linux side of the Yun, passing the key pressed as a parameter. The Python script takes the key number, looks up the contact information in the database, and sends the required email using the Python email package.

I'll help by pointing you the general direction, but I'm not going to give you code, nor am I going to give much more general information than this. If you have a specific question, I'll see if I can help, but I'm not going to answer a general "how do I do it?" type of questions - you need to research that on your own.

tonggiang001:
Ok Robin. I will explain clearly

Sorry but it is still not clear to me.

Are you talking about several physical push-buttons connected to I/O pins on the Arduino side of the Yun?
Or are you talking about virtual on-screen buttons that are clicked with a mouse?

Is the Yun intended to operate stand-alone and will it only be occasionally connected to the PC for short periods for the purpose of uploading new contact details?

Maybe it would be useful to look at these demos EzScrn and Develop on PC deploy on Yun

...R