2

I am developing a control system in my raspberry, but i have the problem that it doesn't have any analogue port, so if i use an arduino to convert de signal from analogue to digital and after send this signal into a I/o digital port from anduino to raspberry, thas is posible?

my plan was receive the analog signal in arduino and transforms here in a digital signal and after send it by Digital port to rasberry

1 Answer 1

1

It is not clear what you mean by “digital port”. The simplest mean to communicate from the Arduino to the Raspberry is to use the Arduino's serial port, which gets into the Raspberry Pi through USB. Just like you would do if you had a PC instead of the Raspberry:

/*
 * Continuously report the analog readings on pins A0 through A2.
 */

void setup() {
    Serial.begin(9600);
}

void loop() {
    Serial.print("0 "); Serial.println(analogRead(A0));
    Serial.print("1 "); Serial.println(analogRead(A1));
    Serial.print("2 "); Serial.println(analogRead(A2));
}

This program will continuously output a text stream like this:

0 145
1 220
2 865
0 142
1 223
...

where the first column is the analog channel number and the second column is the ADC value. How you handle this stream on the Raspberry side is up to you.

5
  • i could manipulate this data in my rasberry? to make a controller? Jun 13, 2019 at 19:44
  • 1
    @JesusMiguelHerrera: Of course! It's your data, you do whatever you want with it. Jun 13, 2019 at 19:50
  • the last question, how could i activate the serial port in my raspberry with the goal of receive this signal? Jun 13, 2019 at 19:52
  • @JesusMiguelHerrera: On the Raspberry side, the serial port (usually /dev/ttyACM0) is activated by connecting the USB cable. Jun 13, 2019 at 19:54
  • thank you edgar i will proud this Jun 13, 2019 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.