San Jerónimo Tecuanipan is a town located on the northern slope of Popocatépetl in Puebla, México. Its name comes from the Nahua words: Tecuani (beast or wolf) and pan (in or on) and means "where there are wolves and fierce animals."It is recognized for having a context of high marginalization and educational backwardness and depending mostly on agriculture as a means of subsistence. In short, the population's quality of life depends on this sector/economic activity.
Unfortunately, they have recently been affected by water scarcity problems caused mainly by the incorrect and inefficient use of the soil and the intensive extraction of water resources for domestic use. Consequently, this has caused a loss of crop productivity, thus deteriorating the quality of life of the people, not only because of their access to domestic water consumption but also due to the difficulty of maintaining the main economic activity.
This context has caused other problems, such as the lack of well-paid jobs and the abandonment of the countryside as the population looks for other subsistence ways, such as migration to the United States.
Sensors could be very useful in this context to strengthen the productive processes of farmers. Still, unfortunately, not everyone can access them, so this time, I used the SenseCAP S2120 8-in-1 LoRaWAN Weather Sensor to create a smart addition to improve the quality of a family's crops in this town.
The SenseCAP LoRaWAN S2120 Weather Station is perfect for home, office, or business use. It allows you to monitor weather conditions from anywhere using the SenseCAP APP or Website and not only one or two but eight variables: air temperature, humidity, wind speed/direction, rainfall, light intensity, UV index, and barometric pressure data supported by worldwide LoRaWAN networks. You can use it for applications in gardens, agriculture, meteorology, urban environmental monitoring, and other scenarios.
The measurement and control of these parameters, through proper management, can allow efficient use of irrigation and fertilization, which should be reflected in higher productivity, cost reduction, and crop quality.
This document will discuss how to install the sensor, including the configuration with the APP. So what are you waiting for? Get one, and let's get started!
In the first place, let's check the part list to ensure nothing is missing. We should receive the weather station, external battery box, rain gauge, pole mounting stand, mounting clamp, plastic pole, four screws, hex nut and flat washer and one screw and hex nut, and two cable ties. Additionally, we will need a precision screwdriver and three 1.5V AA alkaline/lithium batteries for the built-in battery box or six 1.5V AA alkaline batteries for the external battery box.
Here are some pictures of the parts so we can identify them faster:
01. We are ready to start.
Carefully take the weather Station and the rain gauge, install the rain gauge funnel, and rotate clockwise to lock the funnel to the weather station. Like this:
Easy, right?
02. Now, we have to install the batteries. As mentioned, you will need a precision screwdriver!
The weather station has both an internal and an external battery. When the solar panels are working, the device is powered by the solar panels; When solar energy is low, it is powered by batteries.
It is also important to mention that different types of batteries affect the operating temperature range of the sensor. In addition, a different number of batteries determines the sensor's battery life. You can see that information in the following table.
Let's use the internal battery first. To do that, carefully unscrew the battery door at the bottom of the weather station, insert the 3 AA batteries according to the +/- polarity indicated, and then close the door. Finally, tighten the battery door screw.
If you see the red led flashing, Congratulations! It means you installed the batteries correctly. You can see all this process in the next GIF.
That was easy; now, let's install the external battery.
First, take the battery box with you and slide the lock switch to unlock position (don't force it), push to open the battery box door according to the arrow direction, insert the 6 AA batteries and then place and lock the battery box door again. Make sure to insert them according to the +/- polarity indicated, such as in the picture.
Next, unscrew the battery door at the bottom of the weather station and insert the dummy battery into the battery compartment; ensure the “OUTSIDE” marking faces outside and the +/- polarity is in the correct orientation.
Use the battery door, which comes with the external battery box, then tighten the crew on it (make sure to don't break the cable). Once the installation is completed, the red LED indicator at the bottom of the weather station will flash.
03. Now, let's adjust the plastic pole with the weather station and the pole mounting stand. Apply two rubber pads on the inner sides of the mounting base and clamp of the weather station and loosely fasten them together. Finally, insert the Plastic pole into the Pole mounting stand.
If you want to use the internal batteries, this is all you need to do.
If you want to use the external battery, use the cable ties to mount the battery box onto an amounting pole. The latter is not included, and I don't have one at the moment, so I will use the plastic pole.
04. Finally, you need to adjust the solar panel.
Remove the solar panel protection film (I'm not doing it yet because I will place it in a different location) and use your screwdriver to loosen the screw lightly until the gears on the opposite side are separated from the lock position.
Subsequently, adjust the vertical angle of the solar panel (0°, 15°, 30°, 45°, 60°) according to the latitude of your location and then push the gear and tighten the screw until the gears are securely locked.
The station is ready. Now let's configure it with the SenseCAP Mate App and connect it to a network to start receiving data.
2. Download SenseCAP Mate App and create a new account.As a tool, SenseCAP Mate App is used for remote management, config LoRa parameters, setting intervals, binding devices to your account, and checking basic device information.
- For iOS, please search for “SenseCAP Mate” in the App Store and download it.
- For Android, please search for “SenseCAP Mate” in the Google Store and download it.
After downloading the APP, please select Global of Server Location and register a new account. Once the registration is finished, return to the login interface and complete the login.
Note: The identification email may be automatically identified as "spam, " so make sure to check your "trash can" if you can´t find it.
You can also create an account through the SenseCAP Portal: http://sensecap.seeed.cc
3. Bind Sensor to SenseCAP Portal.You can connect your sensor to different platforms; on this occasion, I will use Sensecap for Helium.
For those who don´t know what Helium Network is, it is a global, distributed blockchain-based network of Hotspots that create public, long-range wireless coverage for Internet of Things (IoT) devices. These devices can communicate with each other thanks to the LoRaWAN protocol.
After the battery is installed for the first time, you must connect the Bluetooth and configure the frequency to join the LoRaWAN network and work normally. If the frequency is not set, the red LED will be steady on.
As we want to use the Helium Network, you need to make sure there is coverage on the place where you will place the sensor, so you have two options:
Option 1: Use Helium explorer to check if existing miners are nearby (A green hexagon indicates the presence of the network).
Option 2: Deploy a new Helium gateway. You can purchase the SenseCAP M1 LoRaWAN Indoor Gateway or SenseCAP M2 Data Only LoRaWAN Indoor Gateway(SX1302) to cover your surroundings with the Helium network: https://www.sensecapmx.com/ I will use my M1 this time.
Once you have your M1/M2 ready, you only need to bind your sensor to the SenseCAP Portal. Please open SenseCAP Mate App, click “Add device” on the upper-right corner of the device page to enter the device binding page and scan the QR code on the device to bind the device to your account. If you do not set it to a designated group, the device will be put into the “default” group.
This may be difficult, so I will try to simplify the process as much as possible.
1) First, ensure Bluetooth is enabled on your phone and open the SenseCAP Mate App.
2) Please select “S2120 Weather Station”, click the “Setup” button to turn on Bluetooth, and click “Scan” to start scanning the sensor's Bluetooth.
3) Select the device.
4) Pair your phone with the sensor (press pair) and enter the pairing password. The default password is 000000.
5) The basic information of the sensor will be displayed after entering. You can select measure for more information.
6) Go to settings, click on Platform, and select “SenseCAP for Helium.”
7) Select the Frequency Plan; if the gateway is US915, then set the sensor to US915.
8) Select the uplink interval you want (default is 60 min). It is the amount of time the sensor will send the information to the APP.
9) Click the “Send” button to send the set to the sensor for it to take effect.
Now, you just need to ensure your sensor is already sending data. You can check it using the SenseCAP App or the website http://sensecap.seeed.cc/
The main function of the SenseCAP Portal is to manage SenseCAP devices and store data. It includes Dashboard, Device Management, Data Management, Access Key Management, and API use.
The Dashboard section includes a device overview, an announcement part, and options to add Scene Data and Data Chart (Only one measurement type can be added per chart. Add up to 5 curves per chart.). For example, it says that my sensor is online, but my batteries are low. This is because I used old batteries.
The dashboard is even more useful if you want to place the sensor in a remote place.
You can also find a data section where you can see all the uplink data, create charts and even export the data to excel.
To create your own graphs, you only need to go to "Graph" and Click "Add new page." Then you just need to enter a page name and select the number of rows and columns (the maximum of columns and rows is 3×3). You can add multiple pages.
Now you can create your Graphs. In my case, I can create four since I selected 2*2.
Next, give a name to one of the possible charts and then click to add a measurement. Finally, select the measurements, time intervals to be displayed, and the specific sensor data.
The chart should be ready now. You can pick between a line or a bar chart, restore it, or download it as an image.
You can check our dashboard usage guide for further information.
Mine is already sending data! If you too, then you are ready to go.
Now, we are ready to go and deploy the sensor.
The farm needs to monitor the status and weather conditions in the place constantly. As they usually have to go to the city to work or to leave the place, they need a way to easily and fast access the data and status of the place. So, We confirmed that they use WhatsApp a lot! That was the way to help them, so I decided to build a small python app that checks the data from the sensor using the Sensecap API and then sends a message regarding the conditions.
The app is pretty simple; we used the Twilio API to send a message to the WhatsApp number they gave us, and with a few steps to extract the data from the API, as you can see in our tutorial here, we can send all the messages during the date so they can be planing if need to go to water the plant, cover them, or any other action as a result of the weather conditions.
The good news is that you can implement the project in your yard with any SenseCAP sensor, and all the codes and functionality examples are in this public repository.
The code is pretty simple; the following lines extract all the information from the API; we save the information in a dictionary with the correct labels to identify each sensor and then be able to call the info of each sensor locally without messing with the request call limit.
import json
import requests
import time
from SensorInfo import get_sensor_name, get_sensor_value, get_sensor_unit
from SendMessage import sendWhatsApp
# Request Parameters
host = 'https://sensecap.seeed.cc/openapi/view_latest_telemetry_data'
device_eui = '?device_eui=2CF7F1C0443001A0'
measurement_id = '&measurement_id='
channel_index = '&channel_index=1'
auth = ('username',
'password')
# Sensor parameters
sensorsInfo = ['4097', '4098', '4099', '4101', '4104', '4105', '4113', '4190']
DataExtracted = {}
SensorUnitValue = {}
for sensor_id in sensorsInfo:
service = host + device_eui + measurement_id + sensor_id + channel_index
response = requests.get(service, auth=auth)
if response.status_code == 200:
sensorName = get_sensor_name(sensor_id)
DataExtracted[sensorName] = get_sensor_value(response.json()['data'])
SensorUnitValue[sensorName] = get_sensor_unit(sensorName)
else:
print(f'Request failed with status code {response.status_code}: {response.text}')
Also, you have the opportunity to use the function to send WhatsApp messages in any other project; copy it and make sure to create your credentials.json file.
from twilio.rest import Client
import json
# Open the JSON file and load its contents
with open('src/credentials.json') as json_file:
data = json.load(json_file)
# Get the values of account_sid and auth_token from the loaded JSON data
def sendWhatsApp(message_string):
account_sid = data['account_sid']
auth_token = data['auth_token']
client = Client(account_sid, auth_token)
message = client.messages.create(
from_='',
body=message_string,
to=''
)
print(message.sid)
If you have any questions about the code or anything, just let me know in the comments below.
8. Conclusions and thoughts.Small farmers must adapt to new technologies that allow them to make rational/efficient use of resources, thus contributing to reducing the negative impacts on the ecosystem caused by poor agricultural practices. These new technologies, such as sensors, applied in the agricultural sector help to make more efficient use of both inputs and water, achieving significant savings compared to not doing so and being reflected in crop productivity.
The transfer of agricultural sector technologies to small farmers allows them to increase the profitability of their farms by increasing productivity, saving energy, reducing water and fertilizer consumption, and at the same time, helping to dignify their lives and increase their knowledge.
That just about concludes this article. Thank you for reading it!
Comments