LDR Photoresistor and resistance

Bjerknez:
Whatever...

The what ever means that fewer people are going to want to help you in future. ************** you

Grumpy_Mike:
The what ever means that fewer people are going to want to help you in future. ************** you

No, that means I don't care what you think of me.

I also don't have the time or the desire to discuss with you.

But i really think your nick maybe fits you well :slight_smile:

wolframore:
It’s ok I think we all have plenty of “extra” parts and modules that may be good somewhere one day... :slight_smile:

Yes, some day they will be usefull.... maybe :slight_smile:

Hi,
Did you google

ESP32 LDR

Tom... :slight_smile:

Bjerknez:
No, that means I don't care what you think of me.

While Grumpy_Mike is often *** he is sometimes right on simple things. Such as here. You are using your module wrong. It has two outputs: you want to use the analog one marked as AO. You are using the "wrong" one (marked as DO). If you have time look at the module again, try to find a schematic and learn how it works. It is simple but useful circuit.

Smajdalf:
While Grumpy_Mike is often *** he is sometimes right on simple things. Such as here. You are using your module wrong. It has two outputs: you want to use the analog one marked as AO. You are using the "wrong" one (marked as DO). If you have time look at the module again, try to find a schematic and learn how it works. It is simple but useful circuit.

No, my module has no analog pin. Image i pasted earlier is an image i found on the internet i thought was the same, but is is'nt.

So Grumpy is right, bus the sametime not.....

My fault by the way...

Smajdalf:
While Grumpy_Mike is often *** he is sometimes right on simple

:smiley:

I wanna know what *** means

Perhaps the pin out will help... most of the pins are analog and digital.

wolframore:
Perhaps the pin out will help... most of the pins are analog and digital.

I have seen it.

It does not helped me. It's much easyer to use an standalone LDR with two legs. Works as a charm, and much cheaper too :slight_smile:

Bjerknes, perhaps there’s a communication issue... Grumpy was pointing out that you can’t use a digital pin to read analog data. If it’s working now then you have it on an analog pin. Perhaps its a small language issue.

wolframore:
Bjerknes, perhaps there’s a communication issue... Grumpy was pointing out that you can’t use a digital pin to read analog data. If it’s working now then you have it on an analog pin. Perhaps its a small language issue.

Maybe... but i uset the same pin. I just changed the LDR sensor and the second one worket fine. I'm sure it can be fixed with the right code etc. but it's much simplier to use an sensor that works out of the box :slight_smile:

Good then all is fine

wolframore:
Good then all is fine

Yes, my problem is solved. My main priority is to move on an not stop too long for finding solutions on problems that can be solved with a simple sensor change :slight_smile:

For future reference, all of this would have gone much, much better if you had posted exactly what module you had, by part number and a link so those with something to offer would know exactly what you had. Things also go better when someone explains their project in detail including what they hope to achieve like the objective. While apparently everything came out well we likely could have been here much sooner.

Ron

I think it’s a language barrier

wolframore:
I think it’s a language barrier

Maybe but I am hard pressed to buy that on this one. Posting a picture of something you don't have as something you are working with is not a language issue. Then I say well they looked similar? Whatever someone has they got somewhere and producing a link should be a -3 on a scale of 1 to 10. :slight_smile: I can appreciate you being the kinder soul but much of what this thread has been through reflects and eerie similarity to a thread I was involved in on another forum we share. Not once but two threads on that forum. So yes, maybe I am a little callous.

Ron

Nah, all good, I'm just on here helping out a little due to Covid19 - having fun... no worries, I don't see how you put up with some of the rude folks asking for help and not listening or cooperating. I just ignore those :smiley:

Bjerknez:
Yes, my problem is solved. My main priority is to move on an not stop too long for finding solutions on problems that can be solved with a simple sensor change :slight_smile:

So a circuit diagram and the final working code would be good to finish the thread.
Thanks.. Tom.. :slight_smile:

My circuit diagram it's just in my head, but here is the code for the two units i have.

This is code for the main sensor with LCD, temperature sensor, LED, LDR etc.

#include <LiquidCrystal_I2C.h>
#include <DHT.h>;
LiquidCrystal_I2C lcd(0x27, 20, 4);

byte CelciusSymbol[] = {
  B00111,
  B00101,
  B00111,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000
};

#define DHTPIN 19     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);

int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

int sensorPin = 34;
int sensorValue = 0;
int redled = 13;
int blueled = 12;
int greenled = 14;

int freq = 5000;
int ledChannel = 13;
int ledChannel2 = 12;
int ledChannel3 = 14;
int resolution = 8;

BlynkTimer timer;

char auth[] = "***";

char ssid[] = "***";
char pass[] = "***";

void startup() {
  lcd.begin();
  lcd.backlight();
  ledcWrite(redled, 255);

  delay(1000);
  lcd.setCursor(0, 2);
  lcd.print("Ver.2.0");
  delay(1000);

  lcd.setCursor(0, 3);
  lcd.print("Starting up");
  delay(2000);

  ledcWrite(blueled, 0);
  ledcWrite(redled, 200);
  ledcWrite(greenled, 30);

  lcd.setCursor(11, 3);
  lcd.print(".");
  delay(500);

  lcd.setCursor(12, 3);
  lcd.print(".");
  delay(500);

  lcd.setCursor(13, 3);
  lcd.print(".");
  delay(500);

  lcd.setCursor(14, 3);
  lcd.print(".");
  delay(500);

  lcd.setCursor(15, 3);
  lcd.print(".");
  delay(500);

  lcd.setCursor(16, 3);
  lcd.print(".");
  delay(1000);

  lcd.clear();
}

void sensorData(){
    // some code for writing temperature and humidity values to serial monitor
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  Serial.print("Fuktighet: ");
  Serial.print(hum);
  Serial.print(" %, Temperatur: ");
  Serial.print(temp);
  Serial.println(" Celsius");

  lcd.createChar(0, CelciusSymbol);

  // code for showing temperature innside the box
  lcd.setCursor(0, 0);
  lcd.print("FURTEBUA");

  lcd.setCursor(13, 0);
  lcd.print("Ver.2.0");

  lcd.setCursor(0, 1);
  lcd.print("--------------------");

  // code for showing temperature values on LCD display
  lcd.setCursor(0, 2);
  lcd.print("Temperatur: ");

  // code for showing temperature values on LCD display
  lcd.setCursor(13, 2);
  lcd.print(temp);
  lcd.write(0);

  lcd.setCursor(19, 2);
  lcd.print("C");

    // code for showing temperature innside the box
  lcd.setCursor(0, 3);
  lcd.print("Fuktighet: ");

  // code for showing humidity values on LCD display
  lcd.setCursor(13, 3);
  lcd.print(hum);
  lcd.print(" %");

  // some code that makes the value "sensorValue"
  sensorValue = analogRead(sensorPin); // read the value from the sensor
  Serial.println(sensorValue); //prints the values coming from the sensor on the

  // some statements that turns on and off the LCD display regards to light in the room
  if (sensorValue > 3000) {
    lcd.noBacklight();
    ledcWrite(redled, 15);
    ledcWrite(greenled, 0);
    ledcWrite(blueled, 0);
  }
  if (sensorValue < 3000) {
    lcd.display();
    lcd.backlight();
    ledcWrite(redled, 0);
    ledcWrite(greenled, 15);
    ledcWrite(blueled, 0);
  }
  // some code that sends virtual data to the Blynk app
  Blynk.virtualWrite(V5, temp);
  Blynk.virtualWrite(V6, hum);
}

void setup()
{
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(2000L, sensorData);
  Serial.begin(9600);

  // configure LED PWM functionalitites
  ledcSetup(ledChannel, freq, resolution);
  ledcSetup(ledChannel2, freq, resolution);
  ledcSetup(ledChannel3, freq, resolution);

  // attach the channel to the GPIO to be controlled
  ledcAttachPin(redled, ledChannel);
  ledcAttachPin(greenled, ledChannel2);
  ledcAttachPin(blueled, ledChannel3);

  pinMode(redled, OUTPUT);
  pinMode(greenled, OUTPUT);
  pinMode(blueled, OUTPUT);
  pinMode(sensorPin, INPUT);
  ledcWrite(redled, 0);
  ledcWrite(greenled, 0);
  ledcWrite(blueled, 0);
  dht.begin();
  startup();
}

void loop() {
  Blynk.run();
  timer.run();
}

And this is the code for the internal temperature sensor inside project box:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

BlynkTimer timer;

int dark=1000; //Specified in Hz
int light=1300; //Specified in Hz
int buzzPin=15;
int timeOn=300; //specified in milliseconds
int timeOff=300; //specified in millisecods

char auth[] = "***";

char ssid[] = "***";
char pass[] = "***";

int ledred = 14;
int ledyellow = 12;
int ledblue = 13; 

void buzzer(){
 tone(buzzPin, dark);
 delay(timeOn);
 noTone(buzzPin);
 tone(buzzPin, light);
 delay(timeOff);
}

void sensorData(){
  sensors.requestTemperatures();
  Serial.print("Temperatur: ");
  Serial.println(sensors.getTempCByIndex(0));
  Blynk.virtualWrite(V5, sensors.getTempCByIndex(0));
  ledgrid();
}

void ledgrid(){
  if (sensors.getTempCByIndex(0) <20){
  digitalWrite(ledblue, HIGH);
  digitalWrite(ledyellow, LOW);
  digitalWrite(ledred, LOW);
  noTone(buzzPin);
  }
if (sensors.getTempCByIndex(0) >=20 && sensors.getTempCByIndex(0) <=25){
  digitalWrite(ledblue, LOW);
  digitalWrite(ledyellow, HIGH);
  digitalWrite(ledred, LOW);
  noTone(buzzPin);
}
if (sensors.getTempCByIndex(0) >25){
  digitalWrite(ledblue, LOW);
  digitalWrite(ledyellow, LOW);
  digitalWrite(ledred, HIGH);
  buzzer();
  Blynk.notify("WARNNG! Over 60 grader i boksen!");
  }
}

void setup()
{
  timer.setInterval(10000L, sensorData);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(ledred, OUTPUT);
  pinMode(ledyellow, OUTPUT);
  pinMode(ledblue, OUTPUT);
  pinMode(buzzPin, OUTPUT);
}

void loop() {
  Blynk.run();
  timer.run();
  }