1

I have a distance sensor connected to an Arduino DUE and I want to wire its output to an Arduino UNO.

In Arduino DUE, after calculating the distance, I convert a range of distances (0-10cm) to Volts (0-5V), then I map these to 0-255 values and I do AnalogWrite at the DAC pin.

In Arduino UNO, I AnalogRead from an analog pin (A0) which is connected with a jumpwire to the DAC pin of Arduino DUE. I was expecting to get values between 0 (when the distance is 0 cm) and 1023 (when the distance is 10 cm). But instead I get a weird and unstable range between 100 and 548.

The two Arduinos are connected with a jumpwire between grounds and a jumpwire between DAC and A0.

What am I doing wrong? I thought I had understood how to do this, but apparently not :)

Thank you for your help and time in advance!

Konstantina

4
  • 1
    why do you want to do this? Due is 3.3 V and Uno ADC reads 1023 at 5 V Commented Oct 21, 2020 at 16:26
  • I'm not too sure what you're end goal is but it sounds like your using this as a means of communication. If that's the case, use a level shifter and communicate via UART through the arduino. Here's a link for the level shifter adafruit.com/product/757 Commented Oct 21, 2020 at 17:35
  • As said by @Juraj it is 3.3V, so it is normal to have a value from 0 to 550. Add a 1k resistor to ground if you want a better and stable output. Isn't there a better way to transmit the value? You will never be able to transmit the real value if you convert it to an analog signal. Commented Oct 21, 2020 at 19:32
  • Thank you very much guys! The reason I want to do this, is that the Arduino UNO is already part of a larger system that I cannot modify. This Arduino UNO normally reads the analog signal from a potentiometer. I need to replace this potentiometer with a distance sensor. So I bought the ultrasonic HS sensor and I reasoned that I could do it through an Arduino DUE that does AnalogWrite to the Arduino UNO that does its AnalogRead. Do you think I could do it in a smarter way? I am not super good with these so any help/suggestions are greatly appreciated! Commented Oct 22, 2020 at 5:17

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.