Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android things using UART on Intel Edison #1

Open
avirup171 opened this issue Feb 6, 2017 · 7 comments
Open

Android things using UART on Intel Edison #1

avirup171 opened this issue Feb 6, 2017 · 7 comments

Comments

@avirup171
Copy link

Hi,
The sample was tried using an Intel Edison but it seems not to work at all.

image

The data you are seeing is not sent by me.

The code for transferUartData() is mentioned below

private void transferUartData() {
        if (mLoopbackDevice != null) {
            // Loop until there is no more data in the RX buffer.
            try {
                //Log.e(TAG, "Reading1");
                byte[] buffer = new byte[CHUNK_SIZE];
                mLoopbackDevice.write(buffer, 45);
                int read;
                while ((read = mLoopbackDevice.read(buffer, buffer.length))!=0) {
                    mLoopbackDevice.write(buffer, read);
                    Log.e(TAG, String.valueOf(read));
                }
            } catch (IOException e) {
                Log.w(TAG, "Unable to transfer data over UART", e);
            }
        }
    }

And I am not sending anything through the cable.

If possible, guide me to implement the same thing on an Intel Edison on an Arduino breakout board. Do I need to do any extra steps for the UART or anything will be helpful.

@devunwired
Copy link
Contributor

Can you provide some more details about your setup? Have you connected to your Edison the same way as the schematics in the README, or are you doing something different. Perhaps RX/TX are crossed, or the baud rate on your computer is set incorrectly?

@avirup171
Copy link
Author

I did the circuitry as mentioned in the image. RX-TX, TX-RX, GND-GND. Baud rate is set to 9600
When I run the code, I keep on getting some random data. I am using the Arduino IDE serial port terminal.
in the terminal, i get some random characters as shown below.

image

Is there any workaround that can be done to solve the problem, my main target is to get analog sensor data by UART

@devunwired
Copy link
Contributor

I just realized you modified the sample code in your comment above. What is the purpose of this line?

mLoopbackDevice.write(buffer, 45);

This will cause 45 bytes of null data to be written out every time transferUartData() is called regardless of anything being read. That probably accounts for much of your garbage data, but that alone doesn't explain why the callback is triggering repeatedly. That sounds more like a hardware problem (like the RX line of the Edison is being held low or something like that).

@avirup171
Copy link
Author

I added that line to check whether data can be written or not. Apparently the Edison is only connected to the USB port as mentioned in the android things documentation. So if it's a hardware problem, then is it because of low power or so? Should I put it on external power supply?

Currently, I am not able to neither read nor write data using UART.

@devunwired
Copy link
Contributor

You could also try shorting RX/TX together on the Edison and not have the USB-TTL cable connected to eliminate any potential issues caused by that for the moment. You could modify the sample code to periodically write out a fixed string and verify that you are able to read the same string back.

@avirup171
Copy link
Author

Yesterday, wehn we were testing using another board, we did get some random values much like some random values. I'll give a shot using the method above and see if it works or not. I wanted to know one more thing, is it necessary to set anything on the Intel Edison as the UART? beside running the sample?

@devunwired
Copy link
Contributor

The code to enable & configure the UART is found in the openUart() method. There are no additional steps (in hardware or software) for the Edison. I don't know which USB-TTL cable you were using, but the IOREF voltage (set by J9) would also need to match your cable (5V or 3.3V).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants