logo elektroda
logo elektroda
X
logo elektroda

How to fix Eventor in Blynk for WeMos D1 mini with photoresist?

crroo 1122 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18225580
    crroo
    Level 12  
    Hello.
    I have made a project in Blynk as attached.
    I have uploaded a basic program to Wemos under Blynk.
    I have a photoresistor + resistor connected to A0 and 3.3V connected to GND.
    I have a relay connected to D1.
    The Blynk reads the light intensity, there is a graph, I can control the relay via Buton from the blynk, but the Eventor which is supposed to switch the relay on above a value of 30 (lux) does not switch the relay on.
    I've extended the code more, but it still doesn't work.
    Would someone please drop me a code?

    Greetings.
  • ADVERTISEMENT
  • #2 18226492
    khoam
    Level 42  
    crroo wrote:
    I expanded the code more, but it still doesn't work.

    Please show the "extended" one. From the picture you posted it is rather impossible to guess this code.

    crroo wrote:
    I have a relay connected to D1.
    .
    Yes, just like that? What kind of relay is it?
  • #3 18226513
    crroo
    Level 12  
    Below is the code.
    This is a reworked (truncated) code once downloaded from the internet and adapted to my needs, which I have for the greenhouse and there the humidity sensor connected to A0 works.

    Code: C / C++
    Log in, to see the code
    .


    And the relay is such an overlay on the wemos .
    How to fix Eventor in Blynk for WeMos D1 mini with photoresist? .
    The relay itself works as I switch this on the buton in the blynk.

    I am not very strong in programming ;) .
  • ADVERTISEMENT
  • #4 18226647
    khoam
    Level 42  
    And where is the transmitBLYNK() function called in this code? This is not a standard supported Blynk function such as BLYNK_READ().

    You can take a look at how this is done in the code from the following link:
    http://100-x-arduino.blogspot.com/2016/07/bezprzewodowy-miernik-wilgotnosci-gleby_31.html

    Added after 6 [minutes]:

    And here: https://examples.blynk.cc/?board=ESP8266&...&example=GettingStarted%2FVirtualPinReply
  • ADVERTISEMENT
  • #5 18226701
    crroo
    Level 12  
    This function is at the end of the code

    void transmitBLYNK() { //procedure to send the state of the buttons to the BLYNK server

    Blynk.virtualWrite(V0, lux); //sending to Blynk
    }

    I'll have a look at the links you provided, maybe I'll deduce something
  • #6 18226704
    khoam
    Level 42  
    crroo wrote:
    This function is at the end of the code
    .
    I know that it is at the end of :) What I don't know is where you call it in your code.
  • #7 18226787
    crroo
    Level 12  
    Is this how it should be?

    Code: C / C++
    Log in, to see the code



    Unfortunately it does not work :( .
  • ADVERTISEMENT
  • #8 18226860
    khoam
    Level 42  
    It won't be until you run a timer that calls transmitBLYNK() and reads the analog input every specified time interval.
    See the code link from post #4 (the first one) for an implementation of the timer1sek() function and how to configure this timer in setup().
  • #9 18228240
    crroo
    Level 12  
    I converted the code from the link and it works
    Code: C / C++
    Log in, to see the code
    .

    only i had to disable sleep after 20s

    // action.attach(1, 20000, sleep); // put to sleep after 20 sec of operation

    I will try to refactor this code for my needs.
    Thank you for your help.
  • #10 18229453
    crroo
    Level 12  
    However, I have a problem with this program, namely this wemos + photoresistor + relay are supposed to give a signal to the alarm, which in the morning (let's say when it reads the intensity of light more than 100) opens the roller blinds and in the evening closes them (when it is less than 50) (such a hysteresis).
    It seems to be working OK, but there is a problem: when I turn the project off in Blynk and then on again, the relay switches off at an intensity of, say, 600.
    How can I improve this so that the roller shutters do not go up and down unnecessarily?
  • #11 18229474
    khoam
    Level 42  
    crroo wrote:
    It seems to work ok but there is a problem when I turn the project off in a flash and then back on again the relay switches off at an intensity of e.g. 600 .
    How to correct this so that the roller shutters do not go up and down unnecessarily?
    .
    I would do it like this: store the last N light intensity measurements. After each measurement, I would count the average and the trend from these N measurements and only on this basis would I make a decision on what state the blinds should be in.

    Added after 2 [minutes]: .

    It would be good if you showed the current version of the code.

Topic summary

The discussion revolves around troubleshooting the Eventor feature in Blynk for a WeMos D1 mini project that utilizes a photoresistor to control a relay based on light intensity. The user reports that while the Blynk app successfully reads light levels and allows relay control via a button, the Eventor does not activate the relay when light intensity exceeds 30 lux. Various responses suggest reviewing the code, particularly the implementation of the transmitBLYNK() function and the use of timers to regularly read sensor values. The user eventually adapts their code to include a timer and successfully implements functionality to control roller blinds based on light intensity thresholds, but encounters issues with relay behavior upon project restart. Suggestions include averaging multiple light measurements to prevent unnecessary relay activation.
Summary generated by the language model.
ADVERTISEMENT