Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GGimo
Novice
1,450 Views

Setting up Master/Slave control with an Arduino and an Edison with Arduino breakout board

Jump to solution

Hey all, I just have a simple question. Just like the title states I am trying to figure out how to set up an Intel Edison with breakout board to talk with an Arduino Uno. I have never really done this before so I was wondering if anyone else has? I am trying to read sensor information from the Uno using the I2C ports, but have no clue what to do from there. Any suggestions? I am using Eclipse for the Edison and the normal Arduino IDE for the Uno.

1 Solution
idata
Community Manager
94 Views

Hello Greg-G,

 

 

So, are you able to retrieve the I2C information correctly from the sensor on your Arduino? If so, then I'd suggest you to send the data to the Edison through the Arduino's serial port. This way you will be able to retrieve the information through mraa and then you can interpret it to do whatever you'd like through Edison's interfaces. I'm assuming that the Arduino part is functioning, if so, I'd suggest you to check this example of serial communication with mraa:

 

 

https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Uart-example.cpp https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Uart-example.cpp

 

 

Peter.

View solution in original post

4 Replies
idata
Community Manager
95 Views

Hello Greg-G,

 

 

So, are you able to retrieve the I2C information correctly from the sensor on your Arduino? If so, then I'd suggest you to send the data to the Edison through the Arduino's serial port. This way you will be able to retrieve the information through mraa and then you can interpret it to do whatever you'd like through Edison's interfaces. I'm assuming that the Arduino part is functioning, if so, I'd suggest you to check this example of serial communication with mraa:

 

 

https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Uart-example.cpp https://github.com/intel-iot-devkit/mraa/blob/master/examples/c%2B%2B/Uart-example.cpp

 

 

Peter.

View solution in original post

GGimo
Novice
94 Views

Sorry its been a while since I've last checked this. We actually did try the mraa example. We have two laptops, one running the Edison, the other running the arduino. When we connected the UARTs together and uploaded our codes, the arduino's code would not upload saying there was a syncing problem. We could upload if the Rx pin was removed...

GGimo
Novice
94 Views

Hi, so we used the mraa example, but modified it to read characters instead of writing through UART. Here is our code:

char buffer[1000];

int revbyte;

for(;;){

usleep(1000000);

cout << "try to read response." << endl;

if (mraa_uart_data_available(uart,0)){

cout << "dataReceived" << endl;

revbyte = mraa_uart_read(uart,buffer,sizeof(buffer));

//cout << buffer[0] << " " << buffer[1] << " " << buffer[2] << " " << buffer[3] << " " << buffer[4] << endl;

printf("data receive:%d \n",buffer[0]);

}

usleep(300000);

}//end for

return 0;

}

The problem is that when we send decimal numbers past 128 the number is negative and decrements to 0 if 255 is sent to the Edison. My question is: is the character type only allowed to read 8 bits, or is this a UART issue where the physical data bus can only read 8 bits?

idata
Community Manager
94 Views

Yes, as you can see in: http://www.arduino.cc/en/Reference/Char http://www.arduino.cc/en/Reference/Char the char type accepts only bytes. This is exactly the reason why you are receiving negative (here's an explanation why: http://www.allaboutcircuits.com/textbook/digital/chpt-2/negative-binary-numbers/ http://www.allaboutcircuits.com/textbook/digital/chpt-2/negative-binary-numbers/). You should choose a data type that fits your sketch better, for that I'd suggest you to check http://www.arduino.cc/en/Reference/HomePage/ http://www.arduino.cc/en/Reference/HomePage/.

 

 

Peter.
Reply