Raindrop sensor

    • First, sensor introduction
    • Two, wiring diagram
    • Complete code
    • 4. Experimental process and conclusion

First, sensor introduction

  • The raindrop sensor is simple and inexpensive, and can measure the presence and amount of raindrops by the contact between the parallel circuit exposed to the circuit board and the liquid.
  • The DO pin of the sensor is used to indicate whether raindrops have been detected. If at least one raindrop has been detected, DO outputs a high level and stays low if not.
  • The AO pin of the sensor outputs an analog voltage signal to indicate the number of raindrops detected.

Here, we only detect the voltage analog signal output by AO, because the voltage signal can not only reflect whether there are raindrops, but also see the size of rainfall. The DO interface is easier to use and can be implemented using the GPIO library functions provided by Core if the developer is interested, but not covered here.

Two, wiring diagram

Complete code

Print () : LIB_UsbConfig() : LIB_UsbConfig() : LIB_UsbConfig("CDC") -- Configure the AD voltage collection function and set the maximum sampling value4096The corresponding3.6V Input voltage -- when the channel is full1When, the cache is full, and the collection interval of each point is300ms LIB_ADConfig(1.300000)-- Start the big cyclewhile(GC(1) = =true) do-- Every 300ms check whether A0 channel conversion is complete -- developers can also connect sensors to any channel a1-A3, or multiple channels to multiple sensors, the usage is the same as belowLIB_DelayMs(300)
    A0_full_flag, A0_buf = LIB_ADCheckBufFull("A0")
    if A0_full_flag == 1Then -- Print the AD sampling value of channel A0 and the corresponding voltage value print(string.format("A0=%04d Voltage=%.2fv",  A0_buf[1], A0_buf[1] *3.6/4096.0))
    end end
Copy the code

4. Experimental process and conclusion

Step 1: There is no water on the surface of the raindrop sensor



In the figure above, it can be seen that the voltage output by the sensor is 3.3V at full voltage when there is no water

Step 2: The surface of the raindrop sensor has only 1 drop of water





The figure above shows that the output voltage is 2.23V with only 1 drop of water

Step 3: There are 5 drops of water on the raindrop sensor





The figure above shows that the output voltage is 1.87V with 5 drops of water

Step 4: Raindrop sensor is covered with raindrops





In the figure above, you can see the output voltage of 1.45V when the sensor is covered with water droplets

Conclusion:

As can be seen from the above experiment, the output voltage values of raindrop sensor in the four states of “no water” — >” 1 drop “– >” 5 drops” — >” full “are respectively 3.30V, 2.23V, 1.87V and 1.45V.

It can be seen that the output voltage of the sensor is inversely proportional to the number of raindrops. That is, the greater the rainfall, the lower the sensor output voltage value. See shineblink.com for more details