Browse Source

ohmmeter with 10kΩ known resistor

Fabian Peter Hammerle 3 years ago
parent
commit
1453c36dd0

+ 13 - 2
arduino-sketch.ino

@@ -7,6 +7,8 @@ const uint8_t DISPLAY_HEIGHT = 64;
 // https://startingelectronics.org/tutorials/arduino/modules/OLED-128x64-I2C-display/
 const uint8_t DISPLAY_I2C_ADDRESS = 0x3C;
 
+const double known_resistor_ohm = 10e3;
+
 Adafruit_SSD1306 display(DISPLAY_WIDTH, DISPLAY_HEIGHT);
 
 void setup() {
@@ -25,13 +27,22 @@ void setup() {
     display.println(PROJECT_VERSION);
     display.display();
     delay(2000);
-    display.setTextSize(5);
+    display.setTextSize(3);
 }
 
 void loop() {
     display.clearDisplay();
     display.setCursor(0, 0);
-    display.print(analogRead(A0));
+    // https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
+    int voltage = analogRead(A0);
+    if (voltage == 0) {
+        display.println("inf");
+    } else {
+        double unknown_resistor_ohm =
+            known_resistor_ohm * ((double)1024 / voltage - 1);
+        display.println(unknown_resistor_ohm / 1000);
+    }
+    display.print("kOhm");
     display.display();
     delay(100); // ms
 }

+ 1 - 0
photos/.gitattributes

@@ -0,0 +1 @@
+*.jpg filter=lfs diff=lfs merge=lfs -text

+ 3 - 0
photos/20210110T115503+0100.jpg

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a5f8bcd48accd51f3264b8a4d739eede27f732581a7934510de2103c4c46984e
+size 511193

+ 3 - 0
photos/20210110T115558+0100.jpg

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:54b5d9d338ec5f755d08f55591127ffd715a9bb78a7af2c0207073d4a8d97235
+size 542048

+ 3 - 0
photos/20210110T115641+0100.jpg

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ae308ad17c761acefeb8141d37c7d3cb0fd0e172e9325045a6a942396ded1c9d
+size 539729

+ 48 - 18
schema.sch

@@ -28,12 +28,12 @@ NoConn ~ 4100 4850
 $Comp
 L custom-display:SSD1306_I2C_128x64PX_0.96IN_OLED_DISPLAY DS?
 U 1 1 5FF89C8D
-P 8700 3700
-F 0 "DS?" H 8700 3700 50  0001 C CNN
-F 1 "SSD1306_I2C_128x64PX_0.96IN_OLED_DISPLAY" H 9128 4083 39  0000 L CNN
-F 2 "" H 8700 3700 50  0001 C CNN
-F 3 "" H 8700 3700 50  0001 C CNN
-	1    8700 3700
+P 8700 4400
+F 0 "DS?" H 8700 4400 50  0001 C CNN
+F 1 "SSD1306_I2C_128x64PX_0.96IN_OLED_DISPLAY" H 8031 4389 39  0000 L CNN
+F 2 "" H 8700 4400 50  0001 C CNN
+F 3 "" H 8700 4400 50  0001 C CNN
+	1    8700 4400
 	1    0    0    -1  
 $EndComp
 Wire Wire Line
@@ -41,31 +41,61 @@ Wire Wire Line
 Wire Wire Line
 	7350 2100 8650 2100
 Wire Wire Line
-	8650 2100 8650 3000
+	8650 2100 8650 3050
 Wire Wire Line
 	7250 4250 7250 4300
 Wire Wire Line
 	7250 4300 8150 4300
 Wire Wire Line
-	8150 4300 8150 2950
+	8150 4300 8150 3450
 Wire Wire Line
-	8150 2950 8550 2950
+	8150 3450 8550 3450
 Wire Wire Line
-	8550 2950 8550 3000
+	8550 3450 8550 3700
 Wire Wire Line
-	7650 3550 7850 3550
+	8850 3550 8850 3700
 Wire Wire Line
-	7850 3550 7850 2750
+	8750 3650 8750 3700
 Wire Wire Line
-	7850 2750 8850 2750
+	7650 3650 8750 3650
 Wire Wire Line
-	8850 2750 8850 3000
+	7650 3550 8850 3550
+$Comp
+L Device:R R?
+U 1 1 5FFB33CC
+P 7900 3300
+F 0 "R?" H 7970 3346 50  0001 L CNN
+F 1 "10kΩ" H 7970 3300 50  0000 L CNN
+F 2 "" V 7830 3300 50  0001 C CNN
+F 3 "~" H 7900 3300 50  0001 C CNN
+	1    7900 3300
+	1    0    0    -1  
+$EndComp
+$Comp
+L Connector:Conn_01x02_Male J?
+U 1 1 5FFB3BEF
+P 9100 3050
+F 0 "J?" H 9208 3231 50  0001 C CNN
+F 1 "Probes" H 9072 2978 50  0000 R CNN
+F 2 "" H 9100 3050 50  0001 C CNN
+F 3 "~" H 9100 3050 50  0001 C CNN
+	1    9100 3050
+	-1   0    0    -1  
+$EndComp
+Wire Wire Line
+	7650 3150 7900 3150
+Wire Wire Line
+	8900 3050 8650 3050
+Connection ~ 8650 3050
+Wire Wire Line
+	8650 3050 8650 3700
+Connection ~ 7900 3150
 Wire Wire Line
-	7650 3650 8000 3650
+	7900 3150 8900 3150
 Wire Wire Line
-	8000 3650 8000 2850
+	7900 3450 7900 4400
 Wire Wire Line
-	8000 2850 8750 2850
+	7900 4400 7150 4400
 Wire Wire Line
-	8750 2850 8750 3000
+	7150 4400 7150 4250
 $EndSCHEMATC