Introduction: LORA Temperature and Soil Moisture Sensor
In the preparation of making my own greenhouse I'm making some sensornodes to monitor the environment of the greenhouse. You can also use this sensor outside. Using the temperature inside or outside the greenhouse in combination with ground temperature and moisture levels are interesting to know when to plant your vegetables. I choose the capacitive moisture sensor because this kind of sensor doesn't corrode when in water.
In this instructable we are going to make a LORA node that sends following data:
- soil humidity
- soil temperature
For the completeness of this instructable I'm also going to post the code without the LORA tranceiver but instead sends soil humidity and soil temperature data over serial.The air temperature and air humidity will be measured with another node because I wan't a higher frequency of measurements to have more data. You can use this sensor together with the server node in this instructable.Read this instructable first to know what tranceiver to choose and to make the server node to receive data.
Step 1: Needed Parts
Sensornode:
- Waterproof temperature sensor (ds18B20)
- capacitive moisture sensor
- arduino pro mini 3.3v 8mhz
- esp breakout
- rfm95
- wire for antenna and connections (I use a 0.8mm solid core wire)
- male to male jumper cables
- female to female jumper cables
- terminal block
- pinheaders
- breadboard
Tools:
- soldering iron
- side cutter
- wire stripper
- precision screwdriver
- soldering tin
- ruler to measure antenna
- desoldering pump (if you make mistakes as I did)
Step 2: Making the Antenna
For the antenna I use some leftover cable of my 2x2x0.8mm or 2x2 20awg bus cable.
On the things network you can choose your tranceiver and antenna frequency band by country.
These are the lengths per frequencie:
- 868mhz 3.25 inches or 8.2 cm (this is the one I use)
- 915mhz 3 inches or 7.8 cm
- 433mhz 3 inches or 16.5cm
Step 3: Soldering the Esp Shield
- Remove the resistors of the esp shield (see R1 to R3 in the red field)
- Solder the rfm95 chip onto the esp shield.
- Solder the pinheaders onto the esp shield
- Solder the antenna onto the esp shield. Don't use without an antenna you can damage the shield.
- If the pinheaders aren't soldered onto the arduino solder these too
Step 4: Coding
I know I can use the DTR to automatically reset the arduino but in my case I had errors uploading the code. Therefore I also used a manual reset in this instructable so if you have the same problem you can solve it by a manual reset.
- Wire the arduino to the CP2102 as following:
- CP2102 txd -> Arduino pro mini rx
- CP2102 rxd -> Arduino pro mini tx
- CP2102 gnd -> Arduino pro mini gnd
- CP2102 3.3 -> Arduino pro mini vcc
The file agriculturesensor is the code without the LORA tranceiver. This way you can start your own project beginning from that file and you can better understand how the code works.
If you need more accurate readings you need to map the values of the moisture sensor when not in water and when in water.(minimum and maximum value) I have mapped the values between 400 and 880. Don't dip the sensor in water above the line. This will destroy your sensor. Later on I will show you how to waterproof this sensor.
The temperature readings are in degrees celcius.
One last remark: When you open the serial monitor of the server (last picture) you will see that the data is sent with a colon between the data. This is so we can send everything to the server node in one packet. In a later instructable I will make another server node where this data is processed.
Step 5: Wiring
In the image above you see how to wire everything. The resistor is a 4.7kohm resistor used as a pullup. In the schematic I use another LORA tranceiver and another soil moisture sensor but the wiring stays the same. I've included some detailed pictures in case the first one isn't clear.
Step 6: Conclusion
This instructable enables you to measure the soil temperature and humidity. In future instructables we will use this data to trigger a solenoid to water your plants also we will use this data in an upcoming project to propose the planting of certain vegetables when certain conditions are fulfilled. We will also reuse this instructable for another project where we will waterproof everything and I will make a PCB where you can mount everything onto.
8 Comments
Question 8 months ago on Step 6
I am trying to build the project, the transistor in the drawing is a temperature sensor, you already answered that one. When i only want to have soli moist readings, could i leave this out? My moisture sensor has 3 portsD0 and A0 what port should i use? The plan is to build a few sensors, that monitor my garden soil moist and send it to my lora gateway and pick it up at the things network and from there show the values in my home assistant.
Answer 8 months ago
Yes you can leave the temperature sensor part out. You have to use the A0 (analog) port. On an arduino you then get values between 0 and 1023 (10 bit ADC). This code isn't valid to send to the TTN network it's for point to point communication.
Reply 8 months ago
Ok, i will chech the lines, i asume in the current design the readings of the soil huminity are on the analog port. Main issue is get the readings in some sort of logical values like %moist or something like that
Reply 8 months ago
You can use map on an arduino. This way you can map 0-1023 to 0-100
Reply 8 months ago
Yes that was what tried but since the readings are not stable, the mapping seems also inaccurate
2 years ago
Hi,
It isn't a transistor but a ds18b20 temperature sensor the resistor is used as a voltage divider.
I'm currently graduating my project for this summer and next year is a solution for energy monitoring in combination with relais and a weather station. This project will be in pure C though but I plan to make a website where I explain everything. The project above has some flaws though. The rfm95w needs a separate power supply to run stable in the long run. If you're familiar with serial communication on arduino you can use another kind of lora tranceiver. search for E32-915T20D be sure to use the proper frequence for your country.
The integration with other sensors and solenoids was my long term plan. I wanted to automate a greenhouse and chicken coop. This still is my plan but in STM32 -> c code.
What are you trying to achieve? There is an arduino contest coming,...
kind regards
Reply 2 years ago
i have a small farm where i need to conserve water from different farm zones and i need to have soil moisture reading every hour posted to TTN using LORA so i can conserve water by using it as required in zones.
Question 2 years ago on Step 2
Hi.... Thank you for this project. Can you please explain the Transistor and Resistor used in the project?
also can it be integrated with more sensors like humidity and rain etc??