필터 지우기
필터 지우기

While reading voltage readVoltage(a, 'A0'), i am always getting 5 volts, irrespective of if the sensor is in air, or water or soil. What may be the reason?

조회 수: 3 (최근 30일)
a = ardunio('COM3', 'uno');
moisture_reading = readVoltage(a, 'A0');
disp("moisture reading is " moisture_reading);
Always getting 5 reading, irerespective of the place where the moisture sensor is, i.e. in air or in water or in soil.
  댓글 수: 1
DGM
DGM 2023년 4월 18일
편집: DGM 2023년 4월 18일
You're asking people to debug an ad hoc circuit and some code without seeing any of it. Establish something that is known. Put a known voltage on a pin and verify that it can be read. Read the sensor output with a known meter and verify that it responds.

댓글을 달려면 로그인하십시오.

답변 (1개)

Shuba Nandini
Shuba Nandini 2023년 5월 29일
Hi Shivam,
It is my understanding that, readVoltage(a, 'A0') is always giving a reading of 5 volts irrespective of if the sensor is in air, or water or soil. There could be multiple reasons why readVoltage(a, 'A0') is always giving a reading of 5 volts.
  • By default, the Arduino's reference voltage is set to 5 volts. If the sensor is operating at a lower voltage level, this could cause the issue. You can try setting the reference voltage to match the sensor's operating voltage.
To set the reference voltage, you can use the analogReference() function. For example, if you are using a 3.3V voltage supply, you can use the following command:
analogReference(a,EXTERNAL);
  • It is also possible that the sensor is not functioning correctly.
  • Please make sure that the sensor is connected to the correct pin on the Arduino board.
  • Ensure the Arduino board has a proper grounding connection. If there is poor grounding, there could be error in the readings, which may result in incorrect values.
  • Check the code for errors or bugs. Please make sure that the readVoltage function is used correctly.
To know more about AnalogReference function, please refer to:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by