MAX 471

MAX471 Voltage Current Sensor

Code

1
// Watch video here: https://www.youtube.com/watch?v=T4yyK0G9Zgg
2
3
/* Connection pins:
4
5
Arduino     Current Sensor B43
6
A0                  VT
7
A1                  AT
8
+5V                 VIN
9
+5V                 VOUT
10
GND                 GND
11
*/
12
13
14
#include <Wire.h>
15
16
#define VT_PIN A0 // connect VT
17
#define AT_PIN A1// connect AT
18
19
#define ARDUINO_WORK_VOLTAGE 5.0
20
21
void setup()
22
{
23
  Serial.begin(9600);
24
  Serial.println("Voltage (V) / Current (A)");
25
}
26
27
void loop()
28
{
29
  int vt_temp = analogRead(VT_PIN);
30
  int at_temp = analogRead(AT_PIN);
31
32
  double voltage = vt_temp * (ARDUINO_WORK_VOLTAGE / 1023.0) * 5;
33
  double current = at_temp * (ARDUINO_WORK_VOLTAGE / 1023.0);
34
  Serial.print("Analog0: "); Serial.print(vt_temp); Serial.print(" / "); Serial.print("Analog1: "); Serial.print(at_temp);  Serial.print(" ----- "); 
35
  Serial.print(voltage); Serial.print(" / "); Serial.println(current);
36
  delay(1000);
37
}