-
Notifications
You must be signed in to change notification settings - Fork 0
/
hal_600.ino
37 lines (33 loc) · 1013 Bytes
/
hal_600.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <Arduino.h>
#include <SoftwareSerial.h>
#define LOAD_RESISTOR 10000
int currentSensorValue = 0;
int voltageReferenceValue = 0;
float voltageA0 = 0;
float voltageA1 = 0;
float currentA0 = 0;
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
currentSensorValue = analogRead(A0); // variable to store the value read
Serial.print("Raw value output: ");
Serial.println(currentSensorValue);
delay(50);
voltageA0 = currentSensorValue * (5.0 / 1023.0);
Serial.print("Voltage A0 OUT: ");
Serial.println(voltageA0, 10); // debug value
delay(50);
currentA0 = voltageA0 / LOAD_RESISTOR;
Serial.print("Current: ");
Serial.println(currentA0, 10);
voltageReferenceValue = analogRead(A1);
Serial.print("Raw value VREF: ");
Serial.println(voltageReferenceValue);
voltageA1 = voltageReferenceValue * (5.0 / 1023.0);
Serial.print("Voltage A1 VREF: ");
Serial.println(voltageA1, 10); // debug value
delay(50);
}