1
\$\begingroup\$

I am building a soil moisture sensing and analysis device and I am also a complete novice. The following diagram describes the use of an Arduino Nano Every to monitor battery voltage and current.

Circurt diagram describing voltage and current sensing

Can you tell me how close I am to a sound design and schematic? What kind of standards or best practices should I be following?

The current sensing part of the diagram is where my main questions lay. The circuit fragment comes from the MLX91217 Data Sheet.

enter image description here

What are C1 and C2 used for? What is decoupling?

When I power the circuit I get output from the current sensor but I don't know how to interpret it. The main power line that is the current source for the sensor is not in place to be read by the sensor, yet I still get output. If I place main power line in proximity to the sensor, the output does not change.

enter image description here

Finally, here is the code:

const unsigned int VOLTAGE_RAW_INPUT_PIN = A0;
const unsigned int CURRENT_RAW_INPUT_PIN = A1;
unsigned int VOLTAGE_READING;
unsigned int CURRENT_READING;
float VOLTAGE;
float CURRENT;


void setup() {
  Serial.begin(9600);
  pinMode(VOLTAGE_RAW_INPUT_PIN, INPUT);
  pinMode(CURRENT_RAW_INPUT_PIN, INPUT);
}

void loop() {
  VOLTAGE_READING = analogRead(VOLTAGE_RAW_INPUT_PIN);
  VOLTAGE = (VOLTAGE_READING * 0.00488281) * 2;
  CURRENT_READING = analogRead(CURRENT_RAW_INPUT_PIN);
  CURRENT = CURRENT_READING * 0.00488281;
  Serial.print("voltage: ");
  Serial.print(VOLTAGE);
  Serial.print(" | current: ");
  Serial.println(CURRENT);
  delay(2000);
}
\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

What are C1 and C2 used for? What is decoupling?

Decoupling or bypass capacitors act as filters with the wires to help 'filter' the power voltage to keep it steady when the load changes (drawing more or less current).

When I power the circuit I get output from the current sensor but I don't know how to interpret it. The main power line that is the current source for the sensor is not in place to be read by the sensor, yet I still get output. If I place main power line in proximity to the sensor, the output does not change.

Put a known voltage on the voltage line (connect the other end to board ground) like a bench supply or 1.5V battery. You should see a change to the known voltage, if you don't you might be polling the wrong ADC in the code.

\$\endgroup\$
2
  • \$\begingroup\$ When you say "wrong ADC", are you referring to the pin? \$\endgroup\$
    – Tim Cerka
    Commented Oct 8, 2022 at 0:50
  • \$\begingroup\$ In this case, yes \$\endgroup\$
    – Voltage Spike
    Commented Oct 8, 2022 at 0:56
0
\$\begingroup\$

Decoupling capacitors are used to ensure the chip has a ‘clean’ power supply as it might be drawing high speed peaks of current. The capacitor acts as a local ‘store’. Without tge capacitor, the inductance of this power wiring might cause problems. Short answer - do what the manufacturer says.

Your pull-down resistor of 100R is way too low. The manufacturer recommends 10k at a minimum. 100R is loading down the signal.

If you are measuring AC current, then your code needs to sample the input and rectify the ADC values and average them in order to get a useful reading. This is needed as with AC, the current is constantly changing. There are examples of how to do this on the ‘web. Usually it is referred to as calculating RMS.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for your feedback. The resistor label was a typo. Thanks for pointing it out. When you say "rectify the ADC values", what do you mean? \$\endgroup\$
    – Tim Cerka
    Commented Oct 8, 2022 at 0:54
  • \$\begingroup\$ As mentioned, when measuring an AC signal, the adc values will be constantly changing. You need to apply some math to get a constant value. \$\endgroup\$
    – Kartman
    Commented Oct 8, 2022 at 23:05

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.