Soil Moisture Sensor Fails Whenever Bluetooth Low Energy is Integrated

Hello Everyone, I am developing a smart farming system where I am using ESP32 Board and a Capacitive Soil Moisture sensor v1.2 in order to get Soil moisture data and send the it to a Raspberry Pi 3 via Bluetooth Low Energy (BLE). I am able to get other data from other sensors like temperature and humidity sensors and successfully send them to RPi3 through BLE technology. However, whenever I try to run the Soil Moisture moisture sensor together with the BLE I get a constant value of 0%. As I try to investigate the issue, using the code for Soil Moisture by itself the code works smoothly however, whenever I add the line SerialBT.begin("ESP32test") the result will be 0%. I am using ESP32-WROOM-32 and attached here are my codes and the outputs. Thank you in advance guys!


This is the snipped code for the Soil Moisture Sensor with BLE integrated where I think limits the sensor to get a right value:

void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth syntax to run BLE which i think is the problem
Serial.println("The device started, now you can pair it with bluetooth!");

Is there any way that I can run The BLE without compensating the data from the Capacitive Soil Moisture Sensor guys? I would be glad and willing to try your innovative ideas! Thank you very much!

SensorsWithoutBLE.ino (1.38 KB)

ESP32BLEAndSensors.ino (2.52 KB)

Your soil moisture sensor ADC range is about 0.15V (for 0% to 100%, 0.72V - 0.87V). The low energy sent by the BLE device might be enough to change an input voltage in about that range if signal wires are not shielded completely. I guess this is a hardware problem.

Thank you very much for the idea! I will try to implement cable shielding and try to get back at this post.
For the mean time, I will try to find a shielded jumper wire that I can use, I am new to this shielding stuff, do you have a good recommendation about what shielded cable should I start with? Thank you very much! Kudos!

For the mean time, I will try to find a shielded jumper wire that I can use, I am new to this shielding stuff, do you have a good recommendation about what shielded cable should I start with?

You cannot shield a breadboard setup effectively.

Post a complete wiring diagram of your setup and links to all used components. You probably need an amplifier for the signal as it's to low for such a setup.

Sorry for the later reply.

Attached here is the complete wiring diagram for the Soil Moisture sensor and the ESP32 Module.For simplicity I detached the connection of the temperature sensor from the ESP32 since I think it is not the source of the issue and for easy evaluation of the wire connections also.

Thank you very much for your kind gesture regarding this matter.

Capacitive Soil Moisture Sensor:

ESP32 Datasheet:

According to the DFRobots website the voltage range from 0% to 100% must be much wider (about 1.3V). That's about 10 times your values. Are you completely sure you did the calibration correctly? Can you do the calibration again with BLE enabled?

Upon calibrating it again, i just arrived with the same result. I did the calibration with BLE but it just give me a constant output for the soil moisture sensor. I don't know what's the source of the issue. I would be glad to try your other suggestions.

I really appreciate you for reaching out! I hope we and the Arduino community will solve this kind of bug for the benefit of other people who will encounter the same issue in the future.

CalibwithBT.ino (256 Bytes)

Hmm strange. Why don't you transmit over WiFi instead?

I had a similar requirement and instead of connecting things separately, I bought the integrated solutions like these:

ESP32 + DHT12 Soil Moisture & Temp & Humidity & USB-C

Or you could opt for this one which is based on ESP8266

Both of them have battery holders and necessary battery circuit so you could operate it remotely with no wires nothing.

Thank you for the good suggestion! Energy consumption is the main reason. I want to create a system which designed to have low energy consumption. The difference is rather significant because WiFi devices can use 10 times or more electric power than BLE devices.

Hmm yeah you are definitely correct! BLE does use less power as compared to WiFi.

I didn't know the 10 times figure !! Thanks for informing me.

However, the ESP32 SoC (System on Chip) has both WiFi and BLE so you could discard the 2nd link.

The 1st link is based on ESP32 and has everything integrated temperature, soil moisture and humidity and also has battery connectors in case you want everything to be portable. I think a big powerbank connected to its USB Type C port would make it run longer.

The best way would obviously be plugging it into a USB wall brick.

The ESP32 has both WiFi and BLE, so you could just plug that board in via USB-C and upload a new software program to use BLE, rest everything (sensing soil temperature, moisture and interfacing with ESP32) would be taken care of since it is an integrated all in 1 solution.

Alright! I will be gratefully try your suggestion! Thank you very much hoping I can make it work!
Have you ever tried using the BLE feature of the device itself? I want to send the data to an RPI via BLE. Should I use my previous code?
Thank you for your kind gesture regarding this matter.

Hello there, You can still use your previous code since the main chip-set is same (ESP32) but you would have to do alot of tweaking with respect to the GPIO pins and other things according to the board connections.

I would suggest to use the libraries by the manufacturer itself. You just import it and call the functions directly. There are different functions for different things like different functions to read soil moisture, send data over BLE, read temperature etc etc

I had used the in built existing libraries which speed up my project of automated plant watering system. No breadboard setup, I used the integrated solution board directly since it is the finished final product which is already tested and quality controlled in factory.

I did communication between the board and my android phone but you can do it with RPi too. On the board side you just use the libraries and on the RPi side just handle the BLE sending receiving code and you should be done in a couple of days.

Noted! Thank you very much!
I appreciate it a lot!
I already ordered the product and will update you guys ASAP about it!

nebja:
Hello there, You can still use your previous code since the main chip-set is same (ESP32) but you would have to do alot of tweaking with respect to the GPIO pins and other things according to the board connections.

I would suggest to use the libraries by the manufacturer itself. You just import it and call the functions directly. There are different functions for different things like different functions to read soil moisture, send data over BLE, read temperature etc etc

I had used the in built existing libraries which speed up my project of automated plant watering system. No breadboard setup, I used the integrated solution board directly since it is the finished final product which is already tested and quality controlled in factory.

I did communication between the board and my android phone but you can do it with RPi too. On the board side you just use the libraries and on the RPi side just handle the BLE sending receiving code and you should be done in a couple of days.

My apologies for contacting again for a long time.

I already had the system running using the suggested ESP32 SoC (System on Chip) of Benja. On this case there again exists another issue. Before I upload the code in the device, the device works well using the battery itself as a source of power. However, whenever I do upload my code it seems that the ESP32 SoC's stand alone power is broken and won't turn on again using the battery itself.

Is this a known issue?

I tried to investigate it using 5 other ESP32 SoCs and unfortunately, the same problem occurred. I am not sure if it is because of the GPIO assignments that causes the device to be broken or some other problem concerning short circuit inside the device.

If someone would be kind to provide me a data sheet of this device it would be a great help. Attached here is my code and below is the link of the ESP32 SoC that I'm using. Thank you very much.

editingSM.ino (6.33 KB)

ESP(inoFile).txt (6.32 KB)