Edible Algae Growing Cycle Monitor with the "Seeed Studio LoRaWAN Dev Kit"
This project is my entry for the IoT Into the Wild Contest for Sustainable Planet 2022. I am taking Challenge 5: Sustainable Agriculture as my project category
MY IDEAI've decided to come up with a system that will help grow Spirulina Algae in a self-contained space. I will be monitoring the growing process of the Algae in a water growing tank that is placed in an enclosure outside of my home. I will be monitoring the growing conditions of both the growing tank and the environment in the enclosure. The data is sent up to the cloud with the LoRaWAN grove device, included in the Kit.
UPDATE 9/27 I just received the news that I've been awarded a "SenseCAP S2103 Wireless LoRaWAN® CO2, Temperature, and Humidity Sensor for Outdoor&Indoor Air Quality, CO2 Meter, Carbon Emission", by winning the SenseCAP LoRaWAN Sensor Giveaway! . Unfortunately, It will arrive after this challenge is over! I'll be experimenting with it to monitor the environment outside of my Spirulina Growing container. So those interested, stay tuned
sensor detects CO2 together with air temperature and humidity to bring you the utmost convenience of monitoring invisible environmental parameters related to photosynthesis rate band indoor/outdoor air quality. It has a measuring range of 400-10000 ppm, the accuracy of 400 to 5000 ppm: ±(30+3%MV), and resolution of 1 ppm that jointly empowers it with great performance and high cost-effectiveness
Spirulina Algae is a superfood with all the nutrition value to sustain human beings. With this design, I will try to create the ideal environment to grow spirulina remotely. The system will be deployed outside my home, but is portable enough to operate anywhere in the world where there is LoRaWAN Gateway nearby.
I’ve completed a design challenge on another blog, element14.com 1 Meter of Pi, in December of 2020. For this challenge I designed, and implemented a Spirulina Algae growing monitoring system using a Raspberry Pi and 2 Hats (PIM487 Automation HAT Mini and PIM486Enviro HAT), a bunch of jumper wires, Household items such as (Lamp, Heater, Flower Vase, etc, ) and a MongoDB NO-SQL database in the cloud to store the telemetry data. This 13 blog series uses a Raspberry PI to monitor the growing process. The first blog in the Series INTRODUCTION BLOG -Edible Algae System introduces the blog series with links to the other blogs. I implemented this project but, I did have some problems that I overcame. The wiring was kind of clunky and not very portable and needed a LAN connection to my home network
The implementation took a long time but, when completed, I had a lot of knowledge on growing Spirulina Algae. I used this knowledge to come up with a new design for this challenge.
A monitoring system can aid in the successful growth of any Algae. Any manual maintenance such as the maintaining water temperature, oxidization, PH, Light exposure, status of the growth, etc., can be monitored and reported.
Although growing algae is simple, there are a lot of things that need to be measured and maintained during the growing process. Like for example,
- · the temperature of the water
- · the oxidization in the water
- · the amount of light exposure
- · PH levels
- · Enclosure environment (Humidity & Temperature) during the growing process.
- · Detecting when Algae is READY for Harvesting
- · Detecting and recording the growth rate.
Machine learning can be used to learn to detect some of ideal measurements during the growing cycle
The Machine Learning model can be used by the system during the growing cycle to produce the algae more efficiently.
My idea is to take one part of my other project and implement it using the FREE Seeed Studio LoRaWAN Dev Kit along with other sensors that I have in my lab. The Telemetry data can then be sent over the LoRaWAN using the Grove Lora-E5 via the Helium network to a cloud database.
Due to time constants to complete this challenge on Time, I have decided to choose a subsystem from my other project, to be implemented in this first Phase.
I have picked the Light Exposure subsystem from my other project. This subsystem maintains light exposure for growing Spirulina. It will assure that the spirulina gets the recommended amount of light every day to improve the growth rate. For example, studies have shown, to improve the growth rate, a light can be turned ON every hour for 45 minutes and OFF for 15 minutes, from 7am to 10pm every day.
My background is more on the software side, with a Bachelors of Science Degree in Computer Science from Boston University. I Graduated from BU in 1980 and had been working as a Software Engineer since then until I retired in 2018. I've been presently experimenting with IoT and I've used many Development kits. I have been participating in 10 Road-tests and 6 Design Challenges on element14.com. This is my third project on hackster.io. I have worked with EVK's from Microsoft (Azure Sphere), NXP, Lattice, Renesas, Infineon, Cypress, Omega, and Nordic. I have also done experimenting with several models of the Raspberry PI. Here is a link to My Element14.com Activities blog, that list my roadtest and design challenges that I've been participated in.
Research & ExperimentationThis section will describe my experimentation with the firmware development environment and the features of the Seeed Studio LoRaWAN Dev Kit that I'll be utilizing to implement my Edible Algae Growing Cycle Monitor
Since I have not used the Seeed Studio LoRaWAN Dev Kit before, I will need to research and experiment with the kit.
I used the extensive tutorial at https://wiki.seeedstudio.com/Getting-Started-with-Seeed-Studio-LoRaWAN-Dev-Kit/ get started with the kit. It taught me how to use the LoRa-E5 grove sensor to connect to helium and send data over the LoRaWAN.
I first intended to include it in this project, but found it to be too long, so I created another project Research & Experimentation with the LoraWAN Dev Kit. It contains my notes that I took while following the steps in the getting started guide.
NEXT , I decided to document my evaluation of the Beta release of the Quick Start with SenseCAP K1100 - The Sensor Prototype Kit (Beta) for the SenseCraft firmware in a Project In Progress SenseCraft v0.2 – Evaluation.
DESIGNI have chosen a subsystem from my other project, to be implemented in this first Phase due to time constraints for the challenge. The “Light Exposure Subsystem” will monitor the recommended light exposure for Growing Spirulina Algae.
The Amount of light exposure can have a direct effect on growing Spirulina Studies have shown, that the growth rate can be improved, by having a light turned ON every hour for 45 minutes and OFF for 15 minutes from 7am to 10pm every day.
A desk lamp will be used to provide the light. Firmware on the Wio Terminal will be used to:
- · Switch the lamp ON for 45 minutes and OFF for 15 minutes, between 7pm and 10pm every day.
- · The Light sensor will record the LUX value every 90 minutes.
- · When each data value is recorded, it is sent up to the cloud to be saved for visualization and Analysis.
- o Lamp Status data Timestamp, Lamp ON/OFF
- o Light Luminosity Timestamp ,Lux Value
FIRMWARE
This section describes the two tasks that will be used in the firmware that will run on the Wio Terminal to monitor the light that will shine on the Spirulina Growing Tank.
Maintain the right Amount of light exposure
- Use the Grove Relay sensor to turn the Lamp On/Off based on the time of day
- To maintain the right amount of light exposure for growing spirulina. The following sequence diagram describes the flow.
Make sure the light is operational.
· Use the LUX sensor on the Wio Terminal to monitor the Light sensitivity by capturing & storing, the values over the operation of the firmware. Log the Date time and Value to the data Repository. And display the value on the Wio terminal
· If the lux level is low and within the timeframe of 7am to 10pm.and it's within 45 minutes of the hour, then send an alert that the light should be ON. This is done in the cloud.
The following sequence diagram describes the flow.
I’ve broken up my design into subsystems. These subsystems (task,) will be developed and unit tested in this section. The subsystems are:
· Connect to the LoraWAN using the Helium Network.
· Maintain the right Amount of light exposure
· Make sure the light is operational.
For this subsystem, I used the Wio Termnal, and the Grove-wio-E5 from the Kit. I also have a Grove-Relay from my Grove Starter kit, that I will attach to Wio Terminal.
Hardware Hookup
The Wio terminal comes with 2 grove connectors Which I found out do not send the same pins. The pin diagram is described below.
To connect the Grove sensors, it is very important to connect them to their correct grove connector fpr their capabilities.
· The Grove-E5
o Can be connected to either one, and is a matter of setting which one the E5 library will use. This is set in the E5 lib begin() function, using one of the following
§ DSKLORAE5_SWSERIAL_WIO_P1
· LoRa-E5 on WIO Software serial 1 (RX:BCM3 / TX:BCM2)
· On the LEFT side
§ DSKLORAE5_SWSERIAL_WIO_P2
· LoRa-E5 on WIO Software serial 2 (RX:BCM27 / TW:BCM22)
· On the RIGHT side
§ DSKLORAE5_SEARCH_WIO
· Search for the LoRa-E5 on the different port of the WIO
· The Gove –Relay
o This is a digital sensor , so it needs to be plugged into the grove connector P1, on the left side. You can write to D0 or D1 for the digitalrite(). This is essentially what needs to be done in the code to switch on and off the relay
§ In setup()
· pinMode(0,OUTPUT);
§ In loop()
· To turn on
o digitalWrite(0, HIGH);
o delay(100);
· To turn off
o digitalWrite(0, LOW);
o delay(100);
Connect to the LoraWAN using the Helium Network.
Took the code from the examples presented in the tutorial that I’ve been mentioning.
o Once my Device was added to my Helium console.
o I added the device codes and set the frequency as directed.
o In the lorae5.begin() function tell the E5 library that the Grove-E5 is connected to the PI (LEFT) connector
§ lorae5.begin(DSKLORAE5_SWSERIAL_WIO_P1)
I can use the example to start with that connects to the LoRa-E5
This will start as my base. Even better I can start with the example that also uses the light sensor.
Test Hardware Connections
To make sure the Grove-e5 and the Grove –Relay are working properly I came up with a test that would turn on a lamp for 5 seconds, when the packet is sent. It will also flash for 10 seconds when the setup fails.
To do this I attached the Grove-relay to p2 and the Grove-E5 to P1
Test the relay only with this firmware Relay-test.ino Togles the light on and off.
The code is in: E5-Relay_test1.ino
RTC software
Since Arduino does not contain a Real Time clock, I need to use this wiki, so I could figure out the time of day. It introduces how to use the built-in RTC functionality inside the SAMD51 core within Wio Terminal.
https://wiki.seeedstudio.com/Wio-Terminal-RTC/#installing-the-seeed_arduino_rtc-library-for-wio-terminal
This wiki supplies a test program attached to this project E5_RTC_TEST.ino
PROBLEM
The RTC routine has a compile error. So I cannot check the time range! This wiki introduces how to use the built-in RTC functionality inside the SAMD51 core within Wio Terminal But I get the following error?
grpc: error while marshaling: proto: Marshal called with nil
Compilation error: grpc: error while marshaling: proto: Marshal called with nil
What to do now? My logic in my firmware needs to be able to check the hour and minutes of the current time?
I was able to figure this out by selecting a board and then the E5_RTC_TEST.ino compiled and uploaded successfully.
Here is the firmware running to print the current date
Maintain the right Amount of light exposure
First you will need to design a time of day time function to determine if the CURRENT time is Between the correct Time range. 7pm to 10 am the next day. We need to turn the light on during this time and check (There could be a problem with the light ) if it is ON
Now that I have a way to figure out the time of day, I can test the logic for Marinating the right amount of light.
Here is the pseudo-code I came up with:
Check if it's in the proper time range (between 7pm and 10pm every night.)
If ((hr >= 7 or hr <= 22) and mins <= 45)
True:
Set light ON
Msq to Wio Display
Send light status to E5
Check if the light is actually ON If not, then send a message to the display (for now, but I could sent an alert in the future)
Set a time for 45 minutes delay(2700000) // 45 mins in milliseconds
Set light OFF
Msg to Wio Display
Send light status to E5
Set a time for 15 minutes delay(900000) //15 minutes in milliseconds
Else
Send message to Wio Display " not doing anything NOW"
Set a time for 45 minutes (delay(2700000) // 45 mins in milliseconds
Set a time for 15 minutes (delay(delay(900000) //15 minutes in milliseconds
The Code example for this pseudo-code : E5-light_exposure_Test.ino is attached
I ran the code starting at about 10pm. It did it's thing, but there are a few issues that I will fix for the implementation. It's a successful test, in that all the logic worked and the connection to the Helium Network worked. It took several tries to accept the the connect request, 9 hours later ? But The uplinks started and were consistent every hour after. Not sure why It is taking so long to accept a Request? 9 hours is not acceptable when dealing with Growing conditions!
Here are some pics of the running of the Firmware
Serial monitor
The serial monitor is showing the results of the time between 10:13 and 11:13 in the morning. You can see:
Helium Console
I wanted to see if there were any indications in the helium console event log and the message in the Serial Monitor window while running my test.
When I login into my account on the Helium console, what I see in the log are the 5 join Request/Accept packets between when I started at 10:13PM (22:00) and 6:58.
According to the LoRaE5 -message in the Serial monitor the E5 logged 15 "6:14:20.399 -> LoRaE5 - recv +JOIN: Join failed". this one being the last one.
- At 6:59 serial monitor log list a successful Join. THe same time as the Helium Console reports a join accept The Helium Console However, still has the event #0 marked as RED?
6:59:13.838 -> LoRaE5 - send AT+PORT=8
6:59:13.884 -> LoRaE5 - recv +PORT: 8
6:59:13.884 -> LoRaE5 - send AT+JOIN
6:59:13.963 -> LoRaE5 - recv +JOIN: Start
6:59:13.963 -> LoRaE5 - recv +JOIN: NORMAL
6:59:19.417 -> LoRaE5 - recv +JOIN: Network joined
6:59:19.554 -> LoRaE5 - recv +JOIN: NetID 326548 DevAddr 48:00:00:05
6:59:19.568 -> LoRaE5 - recv +JOIN: Done
6:59:19.568 -> Uplink done
7:14:17.346 -> current time
- At 7:14 the serial monitor log list a successful Uplink. There is no indication of this in the Helium Console log? The "uplink done" messages (Listed above and Below )occur 4 times 7:14, 8:14, 9:14,and 10:14. Then it stops sending. which is what is suppose to occur, because the time is after 10:00.
7:14:17.346 -> current time: 7:13:
7:14:17.346 -> LoRaE5 - send AT+PORT=8
7:14:17.391 -> LoRaE5 - recv +PORT: 8
7:14:17.391 -> LoRaE5 - send AT+MSGHEX=0001
7:14:17.438 -> LoRaE5 - recv +MSGHEX: Start
7:14:20.557 -> LoRaE5 - recv +MSGHEX: Done
7:14:20.557 -> Uplink done
7:14:20.557 -> Light Value: 3
7:14:20.557 -> 1931505263
- The it sleeps as indicated in the next logs with no activity
11:14:08.559 -> current time: 11:13:
12:14:00.778 -> current time: 12:13:
13:13:52.961 -> current time: 13:13:
14:13:44.937 -> current time: 14:13:
Some questions at this point:
- Why are the successful links not reported in the Helium Console Log?
- What does the RED indicator mean?
- Why isn't the indication of the Data showing up on the Helium Console for this device? Do I need to define a function? and implement Integration? I have seen uplinks before with another account that has a function defined.
My Wio terminal Hanging off my PC
This is the position of the Wio Terminal during this test. As you can see It's by a window and the Serial monitor did report a low light value during the night. I did not have the Relay connected to the Light, but I could hear it click and the LED was on indicating it was switched HIGH and went of when It was switched LOW.
The NEXT STEP
I realized a few things that need adjustment in the code that I will fix in the Implementation Section next:.
- Write Serial messages to the Wio Display
- Somehow, align the time to the hour hh:00. Due to time constants, I was unable to figure this out using the RTC library.
Once I got the testing finished I added some Wio Display messages so I can see the status of what is happening. I implemented the firmware E5-light_exposure_main.ino that is in the attachments section below.
I mounted the Wio Terminal, Grove LoRa E5 module, and the Grove Relay to a Growing Tank that I have Spirulina algea, growing in. I plugged a lamp into the Relay using a switchable plug. I added some log information to the Wio Display., so that I could see the status of system.
I was able to just scratch the surface of the kit. In this project I was able to learn a bit about the following:
- the Seeed Grove E5 LoRa module
- The Wio Terminal
- The use of the Helium Network
- The SenseCraft v0.2 Firmware example
- The other Grove modules in the LoRa kit.
I spent most of my time with the E5 LoRa module. And I was able to make a connection to the Helium LoRaWAN. Something I was unable to accomplish on TTN "The Things Network". I was happy to see that there were server nodes in my area and I was able to connect to several of them and Successfully Uplink data from the my firmware.
Since Arduino does not contain a Real Time clock I was unable to implement the logic to check the Time of day so that I could turn on the Light. Apparently there is built-in RTC functionality inside the SAMD51 core within Wio Terminal. I am getting a compile error (from the wiki mentioned above) that is holding me back.
This is a very interesting kit and I have just scratched the surface of the possibilities for using it to monitor the Growing process of Spirulina. I plan to expand on the knowledge to build a complete Growing Monitoring system using the Kit. The primary components of growing spirulina successfully are: Water, Temperature, ,Co2 and Light. I have tackled the Light subsystem and could use the kit to design and implement the other 3 Water, Temperature, and Co2
Future Enhancements- A new subsystem of the Spirulina growing cycle, which is "when to harvest the algae". I could potentially use the Grove AI module to detect when the algae is ready. An alert can be sent indicating this.
- Experiment more with the SenseCraft firmware. Get it to work with Helium Network connection, which I was unable to get working?
- Get the Helium data to Azure IoT Hub. Use the tutorial on the getting started page. This will allow me to visualize the data that I am sending to the my device register on the Helium console.
Comments