Wind and rain detector

Hello,

is there any example program or anybody who tried to detect rain and wind (speed and direction) with BC modules? I have an anemometer and rain flip-flop vane with RJ11 connectors. I would like to connect it to the Sensor module and send the data to RPi.

This would make perfect addition to the climate monitor kit.

Thank you in advance.

Hello Owarek,

I used probably the same anemometer with RJ11.

My project is using Sigfox, but should be easy to convert to BigClown radio.
I’m measuring only wind speed and direction, not the rain because there was no need in that project.
For rain sensor you would need third input, Sensor module has only two (one for wind speed, other for the direction). So you need to use some other GPIO. OR you can use the latest 5 pin Sensor module, which has 3 inputs if you resolder one resistor for channel C.

We can do that soldering job for you on request when you order this module.

Here is the project, code. In the description there are pictures of device:

Let us know if you need help with something.
Also, you can get 100€ dicount coupon if you share the project code, pictures and some video of device in action with us.

Martin

1 Like

Hi Martin,

that sounds just great! I will try to document the whole process. I am making the order right now! Thank you for the example code I hope I will manage to convert it to my needs.

Have a nice day!

1 Like

On the shop we have 4 pin Sensor Module, add it to your shopping basket and add note to the order that you would like 5 pin version and tha you woulk like hardware customization to enable channel C.
Martin

Hi Martin,

I have the customized sensor and I am working on the firmware now. For start I would like to compile and run your code with some modifications (I have deleted Sigfox part) but when I hit make it says:

error: ‘BC_ADC_FORMAT_FLOAT’ undeclared (first use in this function); did you mean ‘BC_DAC_FORMAT_8_BIT’?
bc_adc_init(BC_ADC_CHANNEL_A5, BC_ADC_FORMAT_FLOAT);
^~~~~~~~~~~~~~~~~~~
BC_DAC_FORMAT_8_BIT

Can you please help me with this? Thank you in advance.

It looks like there is ADC init with no parameters now so it should look like this now:
bc_adc_init();

Everything looks promising now except last thing. There is no BC_MODULE_SENSOR_CHANNEL_C enum. how should I use this channel? Thank you.

Hello, we improved ADC in the SDK and made it more precise and simplier. If you are clonning project with --recursive, then git downlaods the exact SDK revision which will work. When you use odler application.c with newer SDK or you use make update, then you run into these errors.

Channel C is nothing special, just a wire connected to the GPIO P7, please see the schematics

So you can access it as a GPIO, init, set direction, enable pull-up.

Is the rain sensor connected to the channel C?
Because it is kind of “slow” sensor, you could be use bc_button on this pin, then you react to the PRESS and RELEASE button events in your handler.

The best solution would be bc_switch. It has advantage, that the internal pullup is enabled only when the pin is sampled. This is perfect in case, when there is no rain for weeks and the flip-flops switch is connected all the time and the current is draining throught the pullup.

Please see this example, keep the “dynamic” pullup parameter, just change the pin:

Does this solve your problem? Let us know if you need some more help.
Martin

1 Like

As always, thank you very much Martin. It helped a lot. I think I have the firmware ready for testing. Today I will connect sensors and will do first tests. BTW now is really good weather for wind and rain sensor testing :smiley:
I will then create some text, video and upload the firmware to GitHub and will look forward for another BigClown shopping spree :smiley:

Have a nice day!

1 Like

Eureka!

It’s alive: https://github.com/owarek/BC-WindAndRainSensor/

I am doing some tests now. Next week I will publish summary with photos and some (hopefully not utterly bad) video (is Czech language ok? I do not have guts to speak in English in public video :smiley:) with whole station in action.

1 Like

Thats perfect, thanks for sharing code.

It’s absolutely ok to have video in czech.

Just a small note to ADC. If you read adc raw values, then the value may change if you power kit from USB or from batteries. Because the USB linear regulator gives 3.3V to the voltage reference pin, and battery modules 3.0 V.

You have to test it if the wind direction analog value is not affected by this.
You can use API to read async voltage, which does some math and gives you really the voltage on the analog pin no matter how the Core Module is powered.
http://sdk.bigclown.com/group__bc__adc.html#gaa4f20608b977e00b100c0b91dd556bf4

https://www.bigclown.com/doc/firmware/how-to-ad-converter/

In m original project I had some small issues with wind direction. Not sure if it was affected by this issue, but I wanted to point that out in case you run into same troubles.

Martin

OK, thank you. I have not noticed any issues on battery module (which is the way I will be powering my node) but why not use a better option. I will test that thing too.

My two issues I am experiencing now:

  1. When I try to publish 6 MQTT messages at once the last one does not arrive to the hub so I had to divide the publishing in two smaller parts.

  2. Reporting of battery voltage fluctuates a lot:

246153
861538
246153
246153
123076
246153

and I do not know why. Could it be caused by powering up the radio and transmitting?

I have updated the code. For reading battery voltage I am using battery module SDK and it works flawlessly now. I have added temperature readings and cleaned up a bit the conversion from ADC to wind direction. Also cleaned up the code a bit. It looks good now. I hope I will get to create some article with testing results and videos next week.


code on github

1 Like

Thanks for an update and little bit of code cleaning :slight_smile: Let us know when you create some text and media.
Martin

A post was split to a new topic: Weather station tips - hardware & firmware