# MAX471 Current Sensor

With this article, I would like to further complete the series on current sensors with the MAX471. One or the other regular reader may already be bored – but I want to have the most important current sensors treated all. The blog shall also serve as a reference tool.

## Technical features of the MAX471

The heart of the MAX471 modules is the actual MAX471 IC. The data sheet can be found here. The MAX471 is designed to measure currents up to 3 amperes. Internally, it uses a shunt (= small resistor for current measurement) of 35 milliohms, through which the current to be measured is sent. The MAX471 amplifies the voltage drop across the shunt and outputs it to the OUT pin. The voltage at OUT is always positive regardless of the current direction.

I found two versions of MAX471 modules that are a little different in their design and properties:

First of all, however, the similarities. Both modules have no connection for a power voltage. The MAX471 takes the power required for itself from the circuit to be measured. The modules are integrated into the circuit via their RS+/RS- or VIN / VOUT connections. The voltage must be in the range of 3 to 36 volts. This means that the MAX471 must be connected on the high-side, i.e. on the V+ side.

The bare MAX417 has an additional shutdown pin that can be used to put it into a sleep mode. The modules unfortunately don’t use that pin.

### The most important data at a glance

• Maximum current: 3 amperes.
• Voltage range: 3 – 36 volts.
• Power consumption: < 100 microamperes.
• in sleep mode (IC only): < 18 microamperes.
• Shunt: 35 milliohms (internal).
• Sensitivity: approx. 1 volt / ampere.

### Differences between the MAX471 modules

Model at the top left (purple module):

• Current connections: RS+ / RS-
• Signal: OUT
• SIGN: Indicates the current direction

Model at the top right (red module):

• Current connections: VIN / VOUT
• Signal 1 (1 Volt / ampere): AT
• Signal 2 (0.2 volts / ampere): VT
• The SIGN pin is not used

The signal 2 is generated by a voltage divider on the module from the signal 1. The voltage divider consists of the 30 kOhm and the 7.5 kOhm resistors, which you can see on the module.

## Connecting the MAX471 to the Arduino

### Wiring

This is what your circuit for the purple module might look like if you are using an Arduino UNO:

The OUT signal is read at the analog input A0. The SIGN pin is an open collector input. It is closed when the current flows from RS+ to RS- and is open when current flows in the other direction. You can check this by attaching a pull-up resistor and then reading it via digitalRead(). A HIGH or 1 would indicate that the current is flowing from RS+ to RS-

The wiring of the alternative red module is no longer a surprise. Most are more likely to use the more sensitive AT output than VT.

### Calibration

If it doesn’t matter that much, you can just start now and determine the current according to this formula:

I\,[\text{mA}]=analogRead(A0)\cdot\frac{5000}{1023}

If you want to measure more accurately, you can calibrate your MAX471 with your trusted ammeter. In my experience, most multimeters provide fairly precise values. And if you stay below one ampere in your current measurements, you can increase the resolution of the Arduino A/D converter with analogReference(INTERNAL). This causes the Arduino UNO or the ATmega328P to use an internal 1.1 volt source as a reference. Simply put, an analogRead result 1023 no longer corresponds to 5, but 1.1 volts.

To create a calibration curve, you can use devices with different current consumption that you insert into the circuit. To read out the A/D converter I used the following sketch:

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

void loop() {
unsigned int rawVal = 0;

for(int i=0; i<25; i++){
delay(10);
}
float meanRawVal = (rawVal / 25.0);
Serial.println(meanRawVal);
delay(2000);
}

Since the measured values fluctuated quite strongly, 25 individual values are averaged. The voltage in millivolts is obtained by multiplying the raw values by 1.1/1023. That’s what I let Excel do for me. In addition, Excel has created a regression line (trend line) for me. I inserted the voltage values in the equation of the regression line (calculated current). The calculated current is surprisingly well in line with the measured values:

Actually, the slope of the calibration straight should be 1 mA/mV, instead it is 0.9452. That is a deviation of just over 5 percent. So, the effort is worth it if you want to measure the current accurately. I repeated it again with my favorite A/D converter, the ADS1115. The calibration line had a slope of 0.948. It all fits together pretty well.

## The complete power and power sensor

Now you can use the calibration line to determine currents. You can also use the current sensor to determine the consumer’s power P. All you have to do is measure the voltage on the consumer’s V+. You already know the current (called bus current).

P = U_{V_{+}}\cdot I_{Bus}

But beware: if the power source provides a voltage greater than 5 volts for the consumer, you absolutely need to set a voltage divider between V+ (consumer) and A1 (Arduino). Otherwise you will destroy the Arduino!

The complete sketch probably doesn’t need much more explanation, except for one point. The reference for the A/D converter changes in the main loop between 5 volts (DEFAULT) and 1.1 volts (INTERNAL). After switching to 1.1 volts, I had initially detected strangely low values. This effect can be counteracted by performing a dummy analogRead(), followed by a short delay  (line 18-20).

const int outPin = A0;
const int busPin = A1;
const int signPin = 8;

void setup() {
Serial.begin(9600);
Serial.println("MAX471 Strom- und Leistungssensor");
Serial.println();
}

void loop() {
float voltage = 0.0;
unsigned long rawVal = 0;
analogReference(INTERNAL);

/* After switching you have to execute a dummy analogRead,
followed by a short */
rawVal = 0;
delay(10);

for(int i=0; i<25; i++){
delay(10);  // 25 measurements to reduce noise
}

voltage = (rawVal/25.0) * 1100.0 / 1023.0;
Serial.print("V Out         [mV]: ");
Serial.println(voltage);

float current_mA = voltage * 0.9452 + 1.0544; // Calibration parameters
Serial.print("Busstrom      [mA]: ");  // Bus current
Serial.println(current_mA);

Serial.print("Stromrichtung:    : ");  // Current direction
Serial.println("RS+ -> RS-");
}
else{
Serial.println("RS- -> RS+");
}

analogReference(DEFAULT);
voltage = analogRead(busPin) * 5.0 / 1023.0;
Serial.print("Busspannung    [V]: "); // Bus voltage
Serial.println(voltage);

float power_mW = (voltage * current_mA);
Serial.print("Leistung      [mW]: ");  // Power
Serial.println(power_mW);

Serial.println("-------------------------------");
delay(2000);
}

And this is what the result looks like on the serial monitor:
{"ft_lang_label":"__label__en","ft_lang_prob":0.8248166,"math_prob":0.93850595,"size":7290,"snap":"2022-27-2022-33","text_gpt3_token_len":1789,"char_repetition_ratio":0.13258304,"word_repetition_ratio":0.0033641716,"special_character_ratio":0.26502058,"punctuation_ratio":0.14033851,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9719599,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-07T12:59:26Z\",\"WARC-Record-ID\":\"<urn:uuid:3e83edc6-a826-4b6b-bfda-6d4473606af5>\",\"Content-Length\":\"79649\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5a6855cc-07f0-42d3-b5aa-b404def4fc5e>\",\"WARC-Concurrent-To\":\"<urn:uuid:0d94853d-b154-4181-af8d-85ddbb62679f>\",\"WARC-IP-Address\":\"217.160.0.114\",\"WARC-Target-URI\":\"https://wolles-elektronikkiste.de/en/max471-current-sensor\",\"WARC-Payload-Digest\":\"sha1:Z4R7YARFUN5NHR4U4JX5D4ATAYGVVLIO\",\"WARC-Block-Digest\":\"sha1:PYUCTK2E2LUW4GHWDSBNUTAUC3DCL4D2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104692018.96_warc_CC-MAIN-20220707124050-20220707154050-00078.warc.gz\"}"}