This component serves as the base for the tool. It has an ESP32 microcontroller which controls all the other components through the code you can upload onto it. This also means it has WiFi capabilities and has a supply voltage of 3.3V or 5V. It additionally has a capacitive and resistive soil moisture sensor built into it, as well as a temperature and humidity sensor (DHT11). There are two more sensors built-in: an ambient light sensor (BH1750) and a digital barometer pressure and humidity sensor (BME280), but these are not used in this version of the tool.
This sensor detects the amount of sunlight. Its output voltage can be used to know the UV index of that day.
This is the cheapest CO2 and TVOC sensor, but the price raises quickly with more advanced sensors. It uses I2C communication (will be explained later) and has a measuring range of:
TVOC: 0-60000ppb
eCO2: 400-60000ppm.
This module will hold the microSD card, it makes use of SPI (will also be explained later)
The microSD card that stores the data, beware of buying one with higher storage capacity as it may not work with the adapter module.
The battery, chosen for its size so that it canfit snugly in the case.
These sensors were selected as a starting point for collecting environmental data. Not every environment or species you are interested in will be affected by the conditions that the probe can detect, feel free to change or upgrade them. For now, let’s walk through why each of these conditions may be of interest in a very broad and general way to get you started.
Carbon dioxide is a naturally occurring gas, yet not every environment reacts equally to it. Plants can be a carbon-source and sink, and higher levels tend to affect plant growth.
The total volatile organic compounds (TVOC) that the SGP30 picks up describes carbon containing gases and vapours. In natural areas, vegetation is the largest source of VOCs, while in urban spaces it’s humans. It is important to keep track of this as it can affect insect and bird health.
As you may know, UV light is essentially sunlight, which is significant for the whole ecosystem. Specifically, you may be interested in how it affects plant growth and photosynthesis.
Soil moisture clearly has a direct effect on water uptake and plant growth, and sufficient moisture prevents soil erosion.
Perhaps a little less clear, the salt level relates to the soil fertility. It can also affect water quality that other species drink.
The habitat conditions are all in some ways dependent on temperature, it can affect plant growth and where species settle.
Keeping track of the humidity of an environment can help you to understand the water cycle. It affects plant-pollinator relations and is important for plant transpiration rates and the spread of plant diseases.
The casing around the electronics is 3D-printed. If you already have a 3D-printer, you probably won’t need help with this step. I chose to print it with PLA-black filament, with the components oriented so they are ‘standing up’. Refer to the downloads section below to find all CAD files (.SLDPRT for parts & .SLDASM for assemblies) or files for the models that can be put directly into a slicer software (.stl). The 3D models were made in SOLIDWORKS, a CAD software that is available for free if you are a student for mos tuniversities. These parts can also be edited in Fusion 360, a free modelling software available for everyone, even if you are not a student.
Additional helpful resources:
The documentation for the LILYGO TTGO T-Higrow ESP32 is unfortunately not the best out there, but here I will include some edited overviews with corrections and warnings to make the process as smooth as possible. For example, the GPIO13 pin is listed twice on the diagram, the pin on the left of the diagram is actually not pin 13 but pin 18. If you want to take a look at the documentation yourself, you can find it here: GitHub -Xinyuan-LilyGO/LilyGo-HiGrow
The ESP32 board allows for the I2C protocol (inter-intergrated circuit). Making use of this means you can connect several components without too many wires. It works with a SCL and SDA pin. The serial clock pin (SCL) pin synchronizes all components, so they all follow the same instruction at the same time. The serial data pin (SDA) moves data between the components and board. For a more detailed explanation, please refer to the official Arduino website: https://docs.arduino.cc/learn/communication/wire/
Unfortunately, the SDA and SCL pins on this board need a special type of connector that isn’t very easy to find. Luckily, the ESP32 has a flexible matrix, allowing you to manually change which pins are used for SDA or SCL. In the code available on this website, it changes pin 27 to SDA, and pin 14 to SCL.
Another communication protocol that is used for this device is the Serial Peripheral Interface (SPI), needed to use the microSD card adapter. There are four types of pins that are important for this, MOSI, MISO, SCK, and CS. While not originally provided in the documentation, this board does indeed have SPI pins which I have marked on the diagram. They are however marked correctly on the microSD card adapter module, making them easier to identify.
MOSI (Master Out Slave In)
Transfers the data from the microcontroller to the other components. On this board, MOSI is pin 23.
MISO (Master In Slave Out)
Transfers data from the components back to the microcontroller. MISO is pin 19 for this ESP32.
SCK (Serial Clock)
Synchronizes the clock signal from the microcontroller to the data transfer. Pin 18 is used for SCK (originally incorrectly marked as pin 13).
CS (Chip Select)
Selects the device that the microcontroller is communicating with. Pin 5 is used for CS.
- Select ‘ESP32 Dev Module’ in the board manager in the Arduino IDE when choosing a board
- Pins 36, 37, 38, and 39 can only be used for input, not as output pins
Refer to the wiring diagram to know which connections to make, my recommendation is not to use wires that are too long (around 10 cm is fine). There are two important things to note, the microSD card adapter is not connected to power in the traditional way, and some adjustments must be made to the wiring of the battery.
The battery does not come with the correct connection; this must be switched out for the proper header. To replace it, cut one of the wires as shown in the photo and solder the cable from the new connection.
Important: do not cut the second wire as well, if both wires are exposed and touch each other, it could create a short circuit which can be damaging or potentially dangerous.
Be sure to check how the new connection fits onto the ESP32, the red and black wires aren’t always correctly placed as the + (red) or – (black). Once you are sure which wire will go to the positive or negative connection, slide a heat shrink tube over the wire and solder the first wire. Place the heat shrink tube over the soldered connection and use a heat gun to shrink the tube and make sure it is covered completely. Then repeat with the second wire. The battery comes with protection so it can be tested safely by plugging it in.
The microSD card adapter has a voltage regulator which converts 5V to 3.3V. But the adapter will receive 3.3V from the ESP32, which means the regulator will cause a problem and lower the voltage even more.
To bypass this, the power wire has to be soldered to the microSD card adapter board above the voltage regulator. As there are only two 3.3V pins on the board, you can join the wire that goes to the adapter to the power wire of another component, such as the UV light sensor as shown in the example. Use a heat shrink tube here as well.
Tip: use hot glue to secure the connection. Please refer to the image for support.
Once the proper adjustments have been made, connect all the electronics according to the wiring diagram. The diagram shows the ESP32 from the back, just as the previous diagram. Now place the sensors into the slots on the inside of the loose components of the case. This might take some figuring out but they all should fit, there are even some clips to guide where the wires should go.
Upload the code (download below) onto the ESP32. The code includes more explanation of what it’s doing and how it works. To log the date and time of the data collection, a WiFi connection must first be made, this is the only thing that you need to alter yourself in the code. The two lines of code below show where to put your WiFi SSID and the password.
//WiFi connection & time synchronization code
const char* ssid = “________”; //fill in ssid
const char* password = “_______”; //fill in password
The implication for the interaction is that it must first connect to WiFi, but only to synchronize the time. Once it’s done that it can disconnect and you can go to your location whether it has WiFi or not, it should still work.
Use the serial monitor on the Arduino IDE to test if the code returns proper values. Note that it may take some time for the SGP30 to warm up before returning the correct values.
This is what the serial monitor should show if there are no errors:
Connecting to....
WiFI connected
SGP30 initialized successfully
SD card initialized successfully
datalog.txt exists on SD Card.
WiFi disconnected
Time: 00:00:00
Soil Moisture: 0000
Soil Salinity: 0.00%
Temperature: 00.00 *C
Humidity: 00.00%
TVOC: 0.00 ppb
eCO2: 000.00 ppm
Data written to SD Card
Click on the link to access all the files including 3D models in SOLIDWORKS, STL files for the slicers, and the code.