Code Monkey home page Code Monkey logo

agrolora's Introduction

https://www.youtube.com/watch?v=z-katBlGzrI# AgroLoRa

Sustainable platform of sensing and irrigation automation based around the SenseCAP K1100 with predictive analysis via the Helium Network.

Watch our demo video:

Demo

Test the product:

Materials:

Hardware:

Optional:

Software:

Cloud Services:

Story:

This will be the third iteration of two past projects;

The first one was Agrofox: https://www.hackster.io/107329/aggrofox-large-scale-and-urban-agriculture-iot-solution-8155fe

The second one is AgroHelium: https://www.hackster.io/Edoliver/agrohelium-urban-agriculture-aiot-solution-d8fbf4

We are also borrowing a lot from this one from Seeed:

https://youtu.be/NQt-XLcSIwA?list=PLpH_4mf13-A0MzOdPNITVfoVBMvf7Rg9g

Our intention this time is to get as close as possible to a functional prototype (the step before Mass-manufacturing), of course, with several upgrades along the way!

Introduction:

In recent years Urban agriculture has made its mark in popular culture as an alternative to industrial farming. It offers several benefits and also helps to solve some of the most nefarious problems that we will have going forward regarding food supply, the growing population and the new trends favoring organic, naturally grown food. Despite all that it has been faced with a plethora of problems including its access to water, pollution concerns, and high maintenance costs. In addition to those most farming methods are very empirical in nature and it has been just a few years since the Internet of Things and other Industry 4.0 technologies have reached Agriculture. And among most of those, its degree of adoption is quite lackluster. Urban agriculture needs a cheap and readily available solution, for it to be sustainable.

Business Insider Singapore.

KImbal Musk (Elon's brother) is hyped about this.

Problem:

IF we want to have the most impact with a project regarding sustainability, namely Water sustainability we have to focus on the industry that requires more of it, which is Agriculture.

And regarding that the main problem in agriculture is actually Water. Most countries have their periods of drought, but as years become even hotter because of climate change, drought greatly affects several regions. California is an example of this:

So we get into a $42 Billion USD problem adding all the parameters. Industry 4.0 tools and automation are greatly needed to attack this.

Here comes a new challenger!

After COVID-19 hit most industries were shown a loss in revenue of almost 30%. The pandemic is impacting global food systems, disrupting regional agricultural value chains, and posing risks to household food security.

International Labour Organization.

Now we have to take much more seriously the fact that Urban Agriculture can provide us a "cushion" during all this problematic time.

Now, my personal problem

This is a photo of one of the Tomato fruits I have in my backyard which I cannot continuously check. Sometimes I am away or very busy, and I tend to neglect its care. Another thing is regarding collecting fruit at the proper moments because they may become uneatable at some point. The problem regarding water can be taken care of if I automate irrigation and some more things.

Solution:

Our solution to the problem will be to create a sustainable platform of sensing and irrigation automation with predictive analysis via the SenseCAP K1100 - The Sensor Prototype Kit with LoRa® and AI instead of relying entirely on cloud and we will be connecting everything through the Helium Network. With one objective in mind: SAVE WATER.

  1. Using temperature with humidity, soil moisture and soil temperature sensors, we will obtain sensor data. LoRa technology has been chosen because the characteristics of long range and low power are excellent for remote areas and cities alike.

Then using the Openweathermap API and Node-RED we will create a Dashboard and notification capabilities.

  1. We will connect to our nearest Lora Gateway via the Helium network and send sensor data to AWS.

  2. Once we have the data at AWS, we will then send it to a web application hosted on a Virtual machine or locally. We made it possible to develop almost any application with the obtained data. Examples of these applications:

Generate databases of our crops and their conditions. Do data analysis to obtain predictive models in the long term. Water automation systems with the data obtained (as we will do in this project). Crop yield analysis. 3.1- We then will make a Dashboard with the data obtained for the complete and simple visualization of the data. For the application, we will perform data crossing with the OpenWeatherMap API, to perform the control of an electrovalve connected to another microcontroller. The data crossing obtained is used to check if that day is going to rain, and thus not use irrigation water in crops. Also if the system detects that water is needed, in the field by the humidity sensors, the irrigation system is turned on. In turn once a day an email will be sent to the farmer with the general information of his field or he can check anytime on his dashboard. Also everytime the irrigation system is online, a notification will be sent.

Connection Diagram:

Hardware Diagram:

Lora E5 Mini:

System Diagram:

Why Helium Network:

One huge emphasis of this project is for it to also be used in Urban Agriculture and LoRa is the best choice for that one as we live in one of the biggest cities in the world (Mexico). And Sigfox which is perhaps your biggest competitor was found to be unreliable.

In the past (when we developed the past version of this project) we had no Helium Network in the country (BTW we put up the FIRST hotspot in the country, see image below). Nowadays it almost ubiqutuous in almost any urban setting around the world and seeing its growth has been incredible. We might take the next step now and even commerciallize a product.

And regarding scalability, LoRa is one of the best and easier networks to work it demanding low power and also performing as good as the components in your dvices and gateway are, for this application we can envision a manufacturing run of devices similar to this in every Urban Agriculture setting.

Helium Account and Credentials.

Before starting to configure the services, platform and integrations. First we need to create our Helium account and then create a device.

In the devices menu you will have to create a new device.

Immediately the platform will give us the 3 necessary credentials for our device to send data to Helium.

Now if we can move on to making our devices, lets go to Assemble the kit, circuits and connect the sensors:

Valve Module:

Once the main circuit is completed, make the automated irrigation valve.

Bill of Materials:

  • Photon Particle (or any other Wifi board).
  • TIP120
  • 12v Source.
  • Solenoid Valve Nc 1/2.
  • Diode 1N4007.
  • 1 Resistances of 2.2kohm.
  • Cable, Solder, Jump wire or similar.

Real implementation:

Refrain from uploading both the Photo code at this moment, because we will need certain credentials.

Sensor and Screen via the SenseCAP K1100:

Take out your Wio terminal from its box and follow these instructions to setup Arduino IDE as we will be using that to set up everything:

https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/

Among all those inctructions these two next steps are CRITICAL:

  • Open your Arduino IDE, click on File > Preferences, and copy below url to Additional Boards Manager URLs:

      https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
    
  • Click on Tools > Board > Board Manager and Search Wio Terminal in the Boards Manager.

  • By the way, just type Seeed Boards or Seeed SAMD Boards.

  • Select WIO terminal and turn it on.

  • And select the port:

Now you are setup you can download any program to it and follow through with all the libraries it has!

  • Assembling the Sensors and LoRa channels:

Basically just take everything out of the box and then just plug it like so:

Notice the DHT11 conected to 5V. GND and A2.

The Soil Moisture Sensor HAS to be conected there as A0 is there.

The things we must do are three in essence:

  • Read the Sensors
  • Connect to our LoRa Helium Gateway
  • Show sensor data on the Wio Terminal

Before proceeding we will need some libraries

The DHT11 library for our extra sensor:

For the other two we do not need libraries per se.

Check and read this documentation on the LoRa Grove e5 module a bit and to connect to the Helium Network

https://wiki.seeedstudio.com/Connecting-to-Helium/

Lora E5 mini Setup:

As part of this project, it was decided to add another type of LoRa board from the WIO family to show that among all of them and according to the needs, it is possible to create an ecosystem of sensors.

CODE: https://github.com/EddOliver/AgroLoRa/tree/main/FreeRTOS_LoRaWAN_AT

https://wiki.seeedstudio.com/LoRa_E5_mini/

First of all, this board is part of the family of STM32 chips, it requires the ST-LINK/V2 Programmer, luckily this type of programmers are already embedded in many other boards and it is possible to use them to program them, in our case we already had a board B-L072Z-LRWAN which already has the ST-LINK/V2 Programmer integrated.

To program our board we have to connect the programming pins as follows.

This board can be programmed through Arduino IDE and STM32CubeIDE, in our case since SeeedStudio provides us with an example of how to configure LoRa credentials from STM32CubeIDE, we decided that it would be better to use ST's own software.

The credentials that we obtained in Helium Account and Credentials are going to be configured in the file

https://github.com/EddOliver/AgroLoRa/blob/main/FreeRTOS_LoRaWAN_AT/LoRaWAN/App/se-identity.h

Once this is done, we will only have to build the project and program it on our board.

If all the previous process is well done, we can check on a serial monitor that the board responds to AT commands.

Since we have our board working as a LoRa node, we can send data through it from any MCU through serial communication, in our case we use an ESP32 which will be in charge of reading the data from the sensors and sending them through the board to LoRa.

Code: https://github.com/EddOliver/AgroLoRa/tree/main/AgroLoRaESP

Helium Console

All the data at this moment should already be arriving at the Helium console.

The data that we receive in helium will always be encoded in base64, so already in our dashboard we will have to perform some algorithm to transform it back into the original data.

Helium - AWS IoT Integration:

Since the messages arrive without problem to the network and Helium, we must integrate AWS IoT, for this we must go to the Integrations section and select AWS IoT Core.

We will see that the credentials requested are IAM credentials to be able to perform operations in AWS without problem, for this and for security we must create an IAM credential which only has access to AWS IoT services.

AWS IAM Creation:

We will create a user which should have programmatic access.

We will add the policy to be able to perform actions in AWS IoT.

Finally we will create the user.

Lastly he will give us the credentials that we use for the Helium console.

The configuration that I used in my console was the following.

Performing a system test.

Dashboard:

For our dashboard we made a simple web page with ReactJS, we decided that the green color was the most representative of a sustainability challenge.

For the graphics page, we made a crop selector, where we can see the real-time data of each crop, the data in the graphics is sent directly from Helium, in our integration with AWS.

We also added a page, where we will see the location of our devices, in order to better track the weather.

Here is an example of how the data arrives from AWS IoT to our page.

AWS Amplify:

We are going to use the Amplify service to make the deployment of our application, but this requires having a repository where we have our code to be able to carry out the CI / CD process, we can use any of the following Git repository hosting services.

However, to maintain a better organization of the apps deployed on AWS, we will use Github with Private Repository.

We select the repository that we create with our code.

Since it is a deployment with ReactJS the Build settings are configured automatically.

Once we finish creating the WebApp, all the steps of the Ci / CD cycle should appear and if everything went well they should look like this.

The result will be a link similar to this one.

WebApp: https://main.d1xaout2n54w4m.amplifyapp.com/

Irrigation system via Openweathermap Forecast and Particle Photon.

We have to explain first the why's before the know how's.

The use of tracking the forecast of the weather is the main purpose of the project itself, that is to optimize water usage.

What use there is of having a sensor that tracks that the soil is dry and activate an irrigation system with that info, but it is going to rain that same day?

We can save a lot of water simply by using the weather forecast systems available to notify our platform that it is going to rain and stop from using water that day.

And of course we want to automate everything.

Without further ado:

  • Go then to your Node-RED flow. Remember the openweathermap node? Drag it to the Node-RED dashboard and configure it like so:

  • Remember to paste an "Inject" node before, a "function" node after and also a "debug" node if you wish to check what has been transfered.

  • Double click the function node and paste the following code:

      msg.payload= msg.payload[0].weather[0].main
      msg.count = msg.payload
      return msg;
    

What this does, is to seek the weather condition that we desire which is "Rain" and it puts it into the payload of the flow.

You can also grab a Text Dashboard node and connect it to this flow to get this info to the dashboard.

  • Go to your particle IDE and paste the code for the Photon.

The main point of the code is understanding that it creates a function that can be accessed via the particle cloud. Whenever you input certain conditions to that functions externally you can do some previous programmed actions.

Flash it and go back to Node-RED. If you need aditional help with the Photon go directly to www.particle.io/start for a great place to begin.

  • Now in Node-RED make a flow like so:

The Particle node is indeed the function node.

  • Double click on the Particle node and click on the pencil on "Add new particle cloud". Then fill it like so:

Your access token is in your particle IDE, Devices section and clicking on the current device you are using. Update and in the next screen fill it with your device name that you can get on the Particle IDE and also on "CLoud Function" input "led".

  • Now your Particle Photon node is configured to get an "on" or "off" payload and do the appropriate action with it.

  • To configure properly the email node you have to log in to your gmail account and then go to: http://myaccount.google.com/u/1/lesssecureapps and turn it on, if you followed this guide accordingly, you set a password and username to your Node-RED so this procedure should be safe.

Then just fill the required fields.

  • The most important step:

Finally, you have reached the end of this part of the tutorial so you have an idea of how to do the main parts of the project. Next is to do your own and use the concepts to get to a final product like the one presented here. There is also the main Flow that we did but we strongly suggest the reader to cultivate their own so you can have a great information harvest.

If you still want to have a complete solution in the "code section" there is the Node Red flow used in the project, which you should load into the Jetson Nano or any other computer (hint: that includes cloud services).

Going Green: Solar Power:

This device has to have a solar panel to reduce the cost of infrastructure.

We recommend that you use at least a 2.5W Solar panel (I tried on a 2W panel and failed, it got very low power and lifetime) in tandem with a LiPo Battery like in the following circuit:

The power segment of the circuit is intended to power the circuit via a Solar Power during the day and then charge the LiPo battery so it can continue working at night.

For this purpose you can see the Regulator in the image that is a connection module that regulates the LiPo battery charge and the Solar Panel feeding energy to the system.

The Sigfox version of the project, the same can be done with the Sensecap Kit.

As previously stated I tried with my small 2W panel, but we are in the rainy season where I live so we need a bigger panel. I urge someone who already has the bigger panel to try it. For the Demo I will be using a Battery. BE very wary when trying this setup, I would go to battery just to be sure and by the way it will be an external one, because for it to work with the AA it may, you have to destroy a resistance.

Here are some reccomended links to these components:

Sunny Buddy: https://www.sparkfun.com/products/12885

Lipo Rider pro: https://www.seeedstudio.com/LiPo-Rider-Pro-p-992.html

Solar panel: https://www.seeedstudio.com/2-5W-Solar-Panel-116X160.html

LiPo Battery: https://www.adafruit.com/product/258

Now its time to upload the code into your dev board! (If you have already input your credentials properly beforehand, if not go to the next step). Get everything into their cases (3D CAD models provided).

At this point we have the two "Things" of our AIoT solution that sense and actuate

Get Cases:

I took the time to make some NEW cases for the project and the result is quite good as you can see:

Video:

Demo

Final Product:

Here is the final version of the complementary sensor:

LoRa E5 Mini:

Testing the Valve:

Installing the Valve:

This is the case with everything inside while testing:

And this is the result with an external battery:

EPIC DEMO:

Demo

Benefits and Sustainability:

As long as we can push initiatives like this forward we can get:

  1. Reduction in Carbon emmisions The average meal has traveled 4, 200 miles just to get to your table. Urban agriculture helps consumers reduce their “foodprint” by providing them the opportunity to purchase food that was grown within their community.

  2. Creating Jobs These farms create opportunities to involve the community. Urban farms create jobs (and volunteer) opportunities in big cities, where poverty and hunger are often persistent issues.

3.- Stimulates your local economy which also builds the community around. An increase in small businesses stimulates local economy and supports the community by creating jobs right where people live.

  1. Healthcare.- Bringing nutritious food to local communities has many direct health benefits, including reducing the risk of harmful conditions like heart disease, obesity, diabetes, and more.

  2. Food quality.-These farms preserve biodiversity by cultivating heirloom varieties or those with lower shelf-stability. The proximity and connectedness to market allows for fresh, nutritious produce to become available to communities that have never had access to this in the past.

  3. Green spaces: This contributes to the health of city ecosystems in a variety of ways. Greenery adds aesthetic appeal, reduces runoff from precipitation, provides restful spaces for the community, and counters the heat island effect by fixing carbon.

Commentary and Future Rollout:

Sustainable disruption is needed because current methods are insufficient for the rising demand, infrastructure is costly and most fields are in remote areas. Also despite what it promises urban agriculture needs a cheap and readily available solution, for it to be sustainable. And COVID-19 just came to aggravate this situation even more.

The current project offers an initial solution to these problems by starting with one of my own, but it is not difficult to see how one of these can expand. This offers a cheap and affordable solution that can serve the local, home or urban farmer as it can automate several of their processes and most important of all provide valuable information about their crops that they can use to make good decisions.

Thinking about the future of the project, of course I still like Helium after all these years. And despite some of the controversies that have been coming up since last year, as a builder first I can see the potential of the biggest LoRa Network in the world and now with their 5G and Cellular side pivot. Regarding the SenseCAP K1100 - The Sensor Protytype Kit with LoRa® and AI, I think it offers a great solution for builders, makers and even home growers and tinkerers alike. With it we were able to pass less time on the bench soldering and getting everything together and more time designing the product and on its presentation and concept. Not to mention that the Wio Terminal is excellent to give your product a much more refined touch and further possibilities of commercialization.

References:

agrolora's People

Contributors

altaga avatar eddoliver avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.