Portenta H7 with analog sensor

4-20mA sensor simulator is connected to A0 pin of Portenta H7.
When i use map function to scale the signal between 0V and 5V i get the following result

I have also attached my code below
PortentaH7_AnalogSensorTesting.ino (293 Bytes)

I need urgent support in deciphering what could be wrong. The values are randomly changing without actually turning the knob on the simulator.
For an input value of 1023 i get different values ranges between 0v and 5V.

Also added to the above question there is no connection to AREF. should a reference voltage be applied?

you should capture the value read from A0 and mapped and print that value, not read A0 again which seems to be fluctuating

you should also edit you post, to post your code using </>

Hi, many thanks for the reply. I have appended my code and have noticed that one of my issues (multiple analogRead values having multiple results) have been resolved.
My issue is that without the simulator stimulating any value (its at 3.95mA) I get analogRead counts between 0 and 1023. I have about 27000 data points and the screen shot is attached below.

The updates code is below


void setup() {
  Serial.begin(250000);//initialize the serial port with baud rate
}

void loop() {
  int value, result;
  value = analogRead(A0);
  result = map(value, 0, 1023, 0,5);
  Serial.print(value); Serial.write('\t'); Serial.println(result);
}

what are you measuring? what is A0 attached to?

The Arduino Portenta H7 board follows the MKR form factor, but is enhanced by the addition of two 80 pin high density connectors at the bottom of the board. This ensures scalability for a wide range of applications by simply upgrading your Portenta H7 board to the one suiting your needs!

Refer to the HW setup below

I am stimulating a 4-20mA sensor using SM1.
SC1 converts the signal from SM1 and gives to Portenta H7 pin A0.

My query is as follows
Without varying SM1 the analogRead(A0) reads between 0 and 1023.
In other words the output mA from SM1 is 4mA but the Portenta pin A0 depicts variation between 0V and 5V.
Could this be a wiring issue some earthing, etc?

The SC1 is tested with a multimeter and the results are as expected when a variation in SM1 then a corresponding variation in SC1 but on the Portenta without a variation in SM1 the read out varies on its own.

doesn't there need to be a ground (-) connection common with the device A0 is connected to?

You mean the Portenta H7 board power supply?
I have not connected any power supply to the Portenta H7 since it draws its power from the USB C connector when connected to the laptop.

for any device to measure a voltage, it needs to have some reference, often a common ground.

Hello gcjr
Many thanks. The GND was not connected therefore the issue. The updated circuit will be as below

Below is a screen shot of the values obtained in serial monitor

Ran into a new issue. The SM1 is able to stimulate between 4mA and 20mA.
Portenta H7 reads 1023 at 13.5mA therefore from my scaling it's 5V from 13.5mA which is not correct. When i check with a multimeter its perfect.
Any suggestions or configurations will be most welcome.

what is the max analog input on the Portenta?

I am searching exactly the same online the maximum voltage that the Portenta H7 can read.
All other Arduino boards it says 0-5V.

https://store.arduino.cc/usa/portenta-h7 says it's 3.3V

Hi I am sorry i didnt understand what 3V means i assume that the board can supply to other board a voltage of 3V

while the board is powered at 5V thru USB, the processor is running at 3.3V thru a low-dropout regulator.

while the analog input may be protected, it cannot measure anything greater than the voltage the processor runs at.

yes gcjr many thanks i was doing some R&D and found the same.
I was able to adjust the jumpers in SC1 so that 3V is the max that is supplied to the board.
Many many thanks for the support.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.