How to Interface an LDR with ESP32 and BeagleBone Black for Light Monitoring System?

Hello, I’m working on a light intensity monitoring system using BeagleBone Black and a Esp32. I’m interfacing an LDR (Light Dependent Resistor) through the Esp32 with a 4-digit 7-segment display to show light levels. Could you guys guide me through the setup, For instance how do I connect the LDR properly to the Esp32 and interface it with BeagleBone Black? This is my code below, the issue is am getting no reading from my Esp32
int sensorValue = 0;
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1000);
}

int sensorValue = 0;
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1000);
}

5 Replies
ZacckOsiemo
ZacckOsiemo5mo ago
Question, you wrote the code before doing the connection? And why do you need those 2 huge systems?
Boss lady
Boss lady5mo ago
Hey @ZacckOsiemo ,Yes, I wrote the code first to outline the basic functionality of reading the LDR values through the ESP32. It’s a common approach to draft the code early and then adjust as needed when connecting the hardware. As for using both the BeagleBone Black and ESP32, each has its strengths: the ESP32 handles real-time sensor readings and communication, while the BeagleBone Black is great for more complex processing and control tasks, like managing the 7-segment display. This setup allows each device to do what it does best, and while it may seem like a lot for a simple task, it’s scalable and can handle added complexity as the project grows. Let me know if you have any other thoughts or suggestions!
ZacckOsiemo
ZacckOsiemo5mo ago
i would say you are trying to optimize and scale too early. An ESP can handle all the functionality you need and usually i start figuring out the the connections before i write code. Because for which peripheral do i write code for? Doing what? That’s stuff you sort out before you code because your code answers these questions.
Boss lady
Boss lady5mo ago
Thanks @ZacckOsiemo would firmly take ur advise can u give any suggestion on how to resolve the issue on my project
ZacckOsiemo
ZacckOsiemo5mo ago
get the connections, then do the code, then scale.

Did you find this page helpful?