/*
Voltmeter with Arduino by Steve Barth
*/
#include <SPI.h>
#include <Wire.h>
//#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSansBold9pt7b.h>
#define OLED_RESET 4
Adafruit_SSD1306 oled(128,64,&Wire,OLED_RESET);
#define v_ref 1.1 // external reference voltage LM4040 2.048V (2.048V / 1024 = 0,002V)
void setup() {
oled.begin(SSD1306_SWITCHCAPVCC, 0x3D); // Initialize with the I2C addr 0x3D if not working use 0x3C (for the 128x64)
oled.setTextColor(WHITE);
delay(1);
}
void loop(){
oled.clearDisplay();
oled.setCursor(12,5);
oled.print("Digital Voltmeter");
oled.setCursor(5,25);
oled.print("A1:");
oled.setCursor(5,46);
oled.print("A2:");
oled.setCursor(35,27); // print out the value you read:
oled.setFont(&FreeSansBold9pt7b);
int V_input1=analogRead(A1); // measurment voltage A1 input reading
float voltage1 = (V_input1 * v_ref) / 1.023; // converting that reading to voltage, which is based off the reference voltage
oled.print(voltage1);
oled.println(" V");
oled.setCursor(35,54); // print out the value you read:
oled.setFont(&FreeSansBold9pt7b);
int V_input2=analogRead(A2); // measurment voltage A1 input reading
float voltage2 = (V_input2 * v_ref) / 1023; // converting that reading to voltage, which is based off the reference voltage
oled.print(voltage2*1000);
oled.println(" V");
oled.display();
oled.setFont(); // set font default
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
pot1:VCC
pot1:SIG
pot1:GND
oled1:DATA
oled1:CLK
oled1:DC
oled1:RST
oled1:CS
oled1:3V3
oled1:VIN
oled1:GND
pot2:VCC
pot2:SIG
pot2:GND