Capacitive Rain Sensor
Moderators: grovkillen, Stuntteam, TD-er
Capacitive Rain Sensor
The usual cheap rain sensors from AliExpress and other platforms have some disadvantages.
They work by conductance so the electrodes must have direct contact to the water.
Dirt and aging can influece this, the water conductance may differ depending on
what a raindrop collected on it's way through the air.
Worse, these sensors mostly use DC. Over time the sensor gets corroded by electrolysis.
This design uses a capacitive sensor. It is covered by solder resist, on top I sprayed a thin
urethane film for better environment resistance.
. .
The complete sensor fits into a box of 83x58x33mm soit's about half size compared to usual sensors.
. .
The sensor itself is built around an ATtiny 2313 CPU as it needs more speed then ESP8266 and ESPEasy can deliver.
It measures the capacitance of the sensor by measuring the loading time of the sensors capacitance.
Capacitance varies due to the dielectric constant of the isolation. The sensor board itself has a
dielectric constant of around 4, pure water is around 80 so water on the sensor makes the
capacitance bigger, it takes longer do load it. This difference is measured.
The ATTiny gives three signals for "a bit", "rainy" and "really wet".
The signals are connected to switch inputs of the ESP-07S, LEDs on the PCB show the signal states.
Internally the ATTiny uses a "Meridian" calculation to keep the measurement stable.
Threshholds can be changed in the source of ATTiny firmware.
On top there is a DS18B20 in the box. As it gets warm in the box it is not suitable to
gather environment temperature. It is used to switch the sensor heating on if temperature
gets under a certain level to avoid water freezing on the sensor or snow settling on the surface.
The sensor is heated if it gets wet or temperature is low.
If anyone wants firmware and/or PCBs message me.
(PCB's, ATTiny firmware and schematic designed by me)
They work by conductance so the electrodes must have direct contact to the water.
Dirt and aging can influece this, the water conductance may differ depending on
what a raindrop collected on it's way through the air.
Worse, these sensors mostly use DC. Over time the sensor gets corroded by electrolysis.
This design uses a capacitive sensor. It is covered by solder resist, on top I sprayed a thin
urethane film for better environment resistance.
. .
The complete sensor fits into a box of 83x58x33mm soit's about half size compared to usual sensors.
. .
The sensor itself is built around an ATtiny 2313 CPU as it needs more speed then ESP8266 and ESPEasy can deliver.
It measures the capacitance of the sensor by measuring the loading time of the sensors capacitance.
Capacitance varies due to the dielectric constant of the isolation. The sensor board itself has a
dielectric constant of around 4, pure water is around 80 so water on the sensor makes the
capacitance bigger, it takes longer do load it. This difference is measured.
The ATTiny gives three signals for "a bit", "rainy" and "really wet".
The signals are connected to switch inputs of the ESP-07S, LEDs on the PCB show the signal states.
Internally the ATTiny uses a "Meridian" calculation to keep the measurement stable.
Threshholds can be changed in the source of ATTiny firmware.
On top there is a DS18B20 in the box. As it gets warm in the box it is not suitable to
gather environment temperature. It is used to switch the sensor heating on if temperature
gets under a certain level to avoid water freezing on the sensor or snow settling on the surface.
The sensor is heated if it gets wet or temperature is low.
If anyone wants firmware and/or PCBs message me.
(PCB's, ATTiny firmware and schematic designed by me)
Last edited by Shardan on 16 Mar 2019, 15:25, edited 3 times in total.
Regards
Shardan
Shardan
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Capacitive Rain Sensor
Awesome! Let's start sell them! ![Cool 8-)](./images/smilies/icon_cool.gif)
![Cool 8-)](./images/smilies/icon_cool.gif)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
![Idee :idea:](./images/smilies/icon_idea.gif)
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
![Idee :idea:](./images/smilies/icon_idea.gif)
![Idee :idea:](./images/smilies/icon_idea.gif)
![Idee :idea:](./images/smilies/icon_idea.gif)
Re: Capacitive Rain Sensor
I still want to make some changes to the firmware.
It works nice, the ESP does the heating control well...
But the setting of threshhold values by recompiling and flashing firmware isn't to my likings.
It should be possible to read the values from serial and store them into the EEprom area of the chip.
The usual progger for the ESP and a terminal program should do.
The serial interface is already implemented, I use it for calibrating, it sends the actual timecounter value.
The serial receiving part still has to be done.
If ESPEasy gets a real serial for controlling some day, setting of these values should be possible
even via ESPEasy. Just read the value from the ATTiny and set threshhold values accordingly, that would be perfect.
But when setting thershholds via serial is done selling is possible I think.
It works nice, the ESP does the heating control well...
But the setting of threshhold values by recompiling and flashing firmware isn't to my likings.
It should be possible to read the values from serial and store them into the EEprom area of the chip.
The usual progger for the ESP and a terminal program should do.
The serial interface is already implemented, I use it for calibrating, it sends the actual timecounter value.
The serial receiving part still has to be done.
If ESPEasy gets a real serial for controlling some day, setting of these values should be possible
even via ESPEasy. Just read the value from the ATTiny and set threshhold values accordingly, that would be perfect.
But when setting thershholds via serial is done selling is possible I think.
Regards
Shardan
Shardan
Re: Capacitive Rain Sensor
I can't send a sketch, as it is not based on the Arduino IDE.SzuR wrote: ↑22 Jun 2019, 11:06 Hi
Great project can you please send me pcb's and sketch?
My email is mszura1@gmail.com
All PCB's can be obtained from me, later maybe from Grovkillen's shop.
Regards
Shardan
Shardan
Re: Capacitive Rain Sensor
Just discover a rain sensor created with a normal rain sensor and a smart home water sensor on https://www.thingiverse.com/thing:3884616. Not sure it would be a good model or not cause it's just a 3d printing share. ![Erg Blij :D](./images/smilies/icon_e_biggrin.gif)
![Erg Blij :D](./images/smilies/icon_e_biggrin.gif)
Smart home will finally come in our future living.
Knowing how to run a smart home device is sufficient and necessary.
Knowing how to run a smart home device is sufficient and necessary.
Re: Capacitive Rain Sensor
It is a nice idea.
Only thing I see which strikes me as odd, is that it has the "cover" over the edge of the sensor at the bottom.
This will keep some water in it and that will break during winter.
ShardanX sent me such a sensor which is basically a PCB with solder mask covering the entire "collecting" surface of the PCB.
So far it is working just great.
Only thing I see which strikes me as odd, is that it has the "cover" over the edge of the sensor at the bottom.
This will keep some water in it and that will break during winter.
ShardanX sent me such a sensor which is basically a PCB with solder mask covering the entire "collecting" surface of the PCB.
So far it is working just great.
Re: Capacitive Rain Sensor
Hello Shardan,
Congratulations, great project.
I would like to do a similar project to my security alarm system, using the Radiocontrolli Capacitive Rain Sensor (https://www.radiocontrolli.com/en/compo ... ain-sensor).
Could you describe the heater's operating conditions in your project (launch conditions) or send me your source code?
I need to integrate the rain sensor with twilight sensor, and others.
B.R. Rafal
Congratulations, great project.
I would like to do a similar project to my security alarm system, using the Radiocontrolli Capacitive Rain Sensor (https://www.radiocontrolli.com/en/compo ... ain-sensor).
Could you describe the heater's operating conditions in your project (launch conditions) or send me your source code?
I need to integrate the rain sensor with twilight sensor, and others.
B.R. Rafal
Re: Capacitive Rain Sensor
Nice project! Again proves that having a dedicated low-level MCU added to the architecture can be useful or even required in some cases.
I'm working on a "MiniProExtenderPlus" version for my servo prototyping solution. Thinking if an Arduino Pro Mini board would be a better fit for these kind of projects. It uses an enhanced version of the P011_PME plugin that can also read/write EEPROM values and read the VCC voltage. And store values from/to the Atmega386 RAM because the ESP is dead inbetween wake-ups.
ATTiny85 has also been one of my favourite devices in the past, but i think that a Pro Mini board is quite a lot easier for many users. Even cheaper.
Maybe having our own "ProMiniEasy" eco-system in companion with a more enhanced P011 plugin would be nice in order to get some sort of architecture standard?
It should also be possible to OTA upgrade the ATMega328 firmware using ESPEasy as a telnet/serial bridge used by AVRDude.
Re: Capacitive Rain Sensor
Hello martinus,
for this type of rain sensor a separate MCU is definitely necessary.
The capacitive sensor works quite simple.
The sensor board builds a capacitor. As water has a far higher dielectric constanc then air (about 80 times..)
the capacitance rises when water drops on the sensor surface.
The MCU connects a GPIO to the sensor via a resistor.
First step: The GPIO is set to 0 volt discharging the sensor capacitance.
Then it is set to 1 loading the capacitance and a counter is started.
If a specific voltage level at the sensor is reached, a comparator stops the counter.
The counter usually gives a value around 50--60 if sensor is dry and about 250 if it is completely wet.
The rest is just calculating, building a meridian value of 15 values, setting threshholds for foggy/rainy/wet etc.
Implementing this into an ESP8266 is possible, but it is a problem with the ESPeasy framework.
Counting must run very fast so a plugin would block all other tasks while running, it needs an interrupt and
a lot of variables taking up RAM.
So I think a separate MCU is the better way for such applications.
A new MiniPro Extender would definitely be appreciated giving a lot of possibilities
the ESPeasy framework and the ESP hardware just won't allow.
It might be a good idea to give the I²C part as a lib for the Arduino IDE besides the full extender firmware.
The full version changes the Arduino mini into a GPIO extension - which is definitely nice but will
reduce the Arduino Mini to "Some more ports of ESP" again.
A given lib for connecting to a generic externder-plugin for communication with ESPEasy
gives full flexibility to use the ATmega to the limits of hardware.
So giving the Extender firmware and the lib opens up both ways, just expanding GPIOs
and free use of the MCU hardware.
Using the ATtiny 2313... well, this might be possible on smaller ATTiny chips for sure.
The ATtiny 2313 is my universal workinghorse for small applications, I've always some in my shelf.
For more complex things I use ATmega168 or 328.
Another reason for the 2313: I need some more GPIO then an ATtiny85 offers.
Meanwhile I've changed the firmware a bit. Setting the threshhold values can be done now via
the usual programmer you use for flashing the ESP8266.
Shorting a jumper starts the programming mode, then you can send the value(s) via hterm or
a similiar terminal program. The LEDs show the programming state.
One thing I would really appreciate: A generic RS232 plugin.
I've several projects meanwhile where parameters can be set via RS232 as described above...
would be nice if I could do that directly from the ESP.
At this time I'm working on a windspeed / wind direction addon for my weather station.
I've got the cheap windmill and wind vane from Ali, both around 15 EUR each...
The windmill is working nice, the vane is terrible to read and unreliable.
I'm working on a new pcb for the vane with a magnetic sensor (AS5600 from AMS).
As the windmill is chained to the vane an ATmega168 can do all measurements.
It sends data per serial... until we might have a generic RS232 it will send a "taskvalueset <speed>, taskvalueset <direction>, taskrun"...
A little trick to get values via serial, allowing much longer cabling compared to I²C.. All calculation will be done inside the wind vane.
The ATmega168 is a bit of overkill - just the smd version is very small (TQFP-32) and there's not much space inside the housing.
for this type of rain sensor a separate MCU is definitely necessary.
The capacitive sensor works quite simple.
The sensor board builds a capacitor. As water has a far higher dielectric constanc then air (about 80 times..)
the capacitance rises when water drops on the sensor surface.
The MCU connects a GPIO to the sensor via a resistor.
First step: The GPIO is set to 0 volt discharging the sensor capacitance.
Then it is set to 1 loading the capacitance and a counter is started.
If a specific voltage level at the sensor is reached, a comparator stops the counter.
The counter usually gives a value around 50--60 if sensor is dry and about 250 if it is completely wet.
The rest is just calculating, building a meridian value of 15 values, setting threshholds for foggy/rainy/wet etc.
Implementing this into an ESP8266 is possible, but it is a problem with the ESPeasy framework.
Counting must run very fast so a plugin would block all other tasks while running, it needs an interrupt and
a lot of variables taking up RAM.
So I think a separate MCU is the better way for such applications.
A new MiniPro Extender would definitely be appreciated giving a lot of possibilities
the ESPeasy framework and the ESP hardware just won't allow.
It might be a good idea to give the I²C part as a lib for the Arduino IDE besides the full extender firmware.
The full version changes the Arduino mini into a GPIO extension - which is definitely nice but will
reduce the Arduino Mini to "Some more ports of ESP" again.
A given lib for connecting to a generic externder-plugin for communication with ESPEasy
gives full flexibility to use the ATmega to the limits of hardware.
So giving the Extender firmware and the lib opens up both ways, just expanding GPIOs
and free use of the MCU hardware.
Using the ATtiny 2313... well, this might be possible on smaller ATTiny chips for sure.
The ATtiny 2313 is my universal workinghorse for small applications, I've always some in my shelf.
For more complex things I use ATmega168 or 328.
Another reason for the 2313: I need some more GPIO then an ATtiny85 offers.
Meanwhile I've changed the firmware a bit. Setting the threshhold values can be done now via
the usual programmer you use for flashing the ESP8266.
Shorting a jumper starts the programming mode, then you can send the value(s) via hterm or
a similiar terminal program. The LEDs show the programming state.
One thing I would really appreciate: A generic RS232 plugin.
I've several projects meanwhile where parameters can be set via RS232 as described above...
would be nice if I could do that directly from the ESP.
At this time I'm working on a windspeed / wind direction addon for my weather station.
I've got the cheap windmill and wind vane from Ali, both around 15 EUR each...
The windmill is working nice, the vane is terrible to read and unreliable.
I'm working on a new pcb for the vane with a magnetic sensor (AS5600 from AMS).
As the windmill is chained to the vane an ATmega168 can do all measurements.
It sends data per serial... until we might have a generic RS232 it will send a "taskvalueset <speed>, taskvalueset <direction>, taskrun"...
A little trick to get values via serial, allowing much longer cabling compared to I²C.. All calculation will be done inside the wind vane.
The ATmega168 is a bit of overkill - just the smd version is very small (TQFP-32) and there's not much space inside the housing.
Regards
Shardan
Shardan
Re: Capacitive Rain Sensor
@shardan,
Nice project. Thank you for sharing.
@martinus,
I have been using PME plugin for multi channel AC dimmer since you introduced it.It opened up possibility of lot more hardware implementation as ESP lacks pins and it is cheaper than in some cases external ADCs.
Thanks.
Nice project. Thank you for sharing.
@martinus,
I have been using PME plugin for multi channel AC dimmer since you introduced it.It opened up possibility of lot more hardware implementation as ESP lacks pins and it is cheaper than in some cases external ADCs.
Thanks.
Re: Capacitive Rain Sensor
Shardan, I do have implemented support for the NXP SC16IS752 I2C UART bridge
So we can now have as many serial ports on an ESP as we want.
I've tried it here with 3 of these chips (6 extra ports) and it is working very stable.
It can even cope with chatty devices like GPS, which do send 9 - 11 sentences per second and sentences longer than the buffer length of the NXP chip.
Every plugin that we have that needs UART, is now also working with this bridge, so we can make a plugin for your rain sensor also, where we can exchange information in both directions.
These chips (+ crystal) are also available at JLCPCB for pick-and-place, so you can also make very cheap PCBs for it with these already mounted.
So we can now have as many serial ports on an ESP as we want.
I've tried it here with 3 of these chips (6 extra ports) and it is working very stable.
It can even cope with chatty devices like GPS, which do send 9 - 11 sentences per second and sentences longer than the buffer length of the NXP chip.
Every plugin that we have that needs UART, is now also working with this bridge, so we can make a plugin for your rain sensor also, where we can exchange information in both directions.
These chips (+ crystal) are also available at JLCPCB for pick-and-place, so you can also make very cheap PCBs for it with these already mounted.
Re: Capacitive Rain Sensor
there is a video to see how it works??
Re: Capacitive Rain Sensor
Shardan,
Did you ever get the windvane going with the AS5600?
I am working on a weather vane project also.
Rob
Did you ever get the windvane going with the AS5600?
I am working on a weather vane project also.
Rob
Who is online
Users browsing this forum: No registered users and 36 guests