ESP32 photodiode - LM358 - ADS1115 setup problems

2 weeks ago 20
ARTICLE AD BOX

I am having troubles with making this setup work consistently. Sometimes it gives a final reading of negative even though it theoretically should be positive. The values should read about 0.6 - 0.8 volts as it has done beforehand, but now reads very low or very high numbers, and very negative numbers (-3volts at times). Ive included a picture of the soldering on my ADS115 (which could be the problem) but ive tried a non-soldered ADS1115 that gives data but has somewaht the same problem. I have included a picture of my circuit in canva. Please do help.

arduino curcuit setup

picture

#include <Wire.h> #include <Adafruit_ADS1X15.h> #include <math.h> const int IR = 27; Adafruit_ADS1115 ads; int onValue = 0; int offValue = 0; int sinyal = 0; float akhir = 0; const int N = 10; int buffer[N]; int ind = 0; int smooth(int value) { buffer[ind] = value; ind = (ind + 1) % N; long sum = 0; for(int i=0;i<N;i++) sum += buffer[i]; return sum/N; } void setup() { pinMode(IR, OUTPUT); Serial.begin(115200); Wire.begin(21, 22); // SDA, SCL if (!ads.begin()) { Serial.println("ADS1115 not detected!"); while (1); } ads.setGain(GAIN_ONE); // ±4.096V range } void loop() { // IR LED ON digitalWrite(IR, HIGH); delay(20); onValue = ads.readADC_SingleEnded(0); // A0 // IR LED OFF delay(10); digitalWrite(IR, LOW); delay(20); offValue = ads.readADC_SingleEnded(0); // subtract ambient light sinyal = onValue - offValue; // Masukkan ke fungsi smoothing agar angkanya stabil! Serial.print(onValue); Serial.print(" - "); Serial.print(offValue); Serial.print(" = "); Serial.print(sinyal); Serial.print(" == "); akhir = (sinyal*4.096)/32767; Serial.println(akhir); delay(50); }
Read Entire Article