Page tree
Skip to end of metadata
Go to start of metadata

The great Reiner van der Lee created the Vinduino project out of necessity to manage the irrigation on his small Southern California vineyard, by monitoring soil moisture at different depths and at several vineyard locations: "Soil moisture monitoring systems have been around for decades, but they cost hundreds to thousands of dollars and -because these systems are proprietary- there will be ongoing cost to customize and maintain these systems. As a small vineyard owner, I needed something low cost and flexible. The open source Arduino platform, together with low cost gypsum soil moisture and salinity sensors, provides all that. While I first envisioned the Vinduino project (Vineyard + Arduino) for my personal interest and needs, but now the scope has broadened to providing easy to use, open source, low cost solutions for agricultural irrigation management."

To date, the Vinduino project has provided the following results, published on the Vinduino blog, Hackaday, and Github:

  • DIY calibrated gypsum soil moisture sensors (Watermark SS200 is also supported)
  • Hand held sensor reader (soil moisture, soil/water salinity, water pressure)
  • Solar powered remote sensor platform (Vinduino R3), available on Tindie.com Options include: 4 electrically separated inputs for soil moisture sensors Wifi (ESP8266) or Globalsat LM-210 LoRa module for long range (6 miles) Irrigation valve control, optional pressure sensor for valve operation feedback several options for temperature/humidity sensors Built in solar battery charger Built in real time clock for precise irrigation timing
  • Gateway to connect multiple LoRa end nodes to the Internet via Wifi (Vinduino Gateway)

All publicly released programming and documentation is available for free under the GNU General Public License 3.0.

Web site: www.vanderleevineyard.com

Materials for four Vinduino stations

  • 3m PVC x 4
  • 2m PVC x 4
  • 1.5m PVC x 4
  • 1.0m PVC x 4
  • so...3m x 10
  • 6 x 4 clear plastic plates 
  • 27 x 6mm bolts, screws, and washers
  • 27 MTB corks, tu use as separators
  • Silver, Purple, Orange, White, and black spray paint
  • 16 PVC caps
  • 4 x enclosure (Lalo's birdhouse)
  • 4 x vinduino boards
  • 16 x watermark sensors
  • 4 x solar panel
  • 4 x battery
  • 3.3v USB-FTDI cable
  • 4x GlobalSat LM-210 LoRa module and antennae 

Building the soil moisture probe mounts

  1. Cut the PVC pipes into the appropriate lengths.
  2. Cut the plate plastic into the appropriate lengths.
  3. Drill holes into the plates and corks.
  4. Paint the exposed portions of the PVC pipes, according to length.
  5. Paint the PVC caps.
  6. Drill the drainage holes in the PVC tubes.
  7. Drill the cable holes in the top of the PVC tubes.
  8. Install each tube and sensor. 
    1. soak the sensor for 30 minutes in the morning
    2. allow to dry during the day
    3. soak overnight
    4. Test the sensor readings dry, vs. wet.
  9. Route the sensor cable through the pipes.
  10. Attach the sensor to the end of a PVC pipe with glue

Installing the humidity sensors.

  1. Dig the pit 2m deep.
  2. Collect soil samples from 30cm, 60cm, 90cm, and 180cm deep from each pit.
  3. Perform chemical and fertility analysis on each sample.
  4. Photograph and video test pits
  5. Wash away dirt from the root structure in the PV and MB2 (Vinduino 1 and 4) test pits.
  6. Dig a groove into the side of each pit for four PVC tubes for the four sensors.
  7. Fill up the test pits (except for the big rocks, which should be taken to the center of the vineyard.
  8. Fill up around the tubes with slush and mud to make sure there are no channels for the water to pass.

Vinduino R3 hardware connections.

This is the Vinduino R3 board:

It is based on the Arduino Pro Mini, with the ATMega328, 3.3V 8Hz processor.

The Vinduino software can be found here:

https://github.com/ReiniervdL/Vinduino

Connect the LoRa radio and antennae.

The telemetry radio unit used in the Vinduino project follows the recent LoRa standard, which allows long range wireless networking. The unit is FCC approved in the USA for license-free use in the 915 MHz band.

Range is dependent on the conditions. With the supplied antennas typically 1-3 miles is possible. With line-of-sight and external antennas, considerable longer distances are possible.

The unit can be re-programmed for different output power levels and frequency. The default settings are 915 MHz and 100mW power. Frequency change is only needed in vase of strong local interference from other users of the frequency or in case of installation in Europe where 868MHz is used for LoRa.

The LM-210 module works on 3.3V and the Vinduino board is designed for that. Before programming the Arduino microcontroller board with a USB adapter cable, the LM-210 module should be removed to avoid USB level voltages (5V) reaching the module. 

Working with the Globalsat modules is straightforward, data in = data out. The interface bitrate comes as default 9600 bps. The RF signal rate can be programmed between 0.81 and 18.23 Kbps. RF output power is 20 dBm (100mW), and can be reduced in 7 steps of 2 dB. The LM-210 connects with a 7-pin header. 

The module has two mode selection pins, that are pretty interesting to play with.
Mode 1, P1=0 and P2=0: the channel is opened and the module is active. This is also the mode with highest power consumption: 13 mA typical for receive and 120 mA for transmit.
Mode 2, P1=0 and P2=1: difference with mode 1 is that every transmission now starts with a preamble needed to wake up a receiver in wake-up mode (see mode 3), and RSSI data is added.
Mode 3, P1=1 and P2=0: Power saving mode. The receiver is in sleep mode and wakes up at a set interval. If a transmission preamble is detected, receiving starts until the transmission is ended.
Mode 4, P1=1 and P2=1: Setup mode. Changing frequency, output power etc is done by sending hexadecimal string in this mode. This is also the setting that takes the least power (2.2uA) as RF and UART as closed.


Notes:

For Vinduino, the Arduino board in the remote stations toggle between Mode 4 (sleeping mode) and Mode 1 (transmission).

The  Rasberry PI Vinduino gateway is always on, actively receiving, and remains in Mode 1.



Connect the four watermark sensors.

The Vinduino R3 has inputs for 4 soil sensors. The soil sensor wires connect to the wire connection block. Sensor 1 wires are connected on the right side. The type of wiring is not critical for the accuracy or performance of the soil moisture measurement, however we connected the ridged wire (white stripe) to the ground on the vinduino.

Connect the battery and solar panel

  1. Connect the solar panel
    1. Test the solar panel polarity.
    2. Test the battery pack polarity.
    3. Remove the solar panel alligator clips
    4. Connect the solar panel 


The vinduino station is designed for continuous unattended operation. It is powered by a small solar panel, and the battery charger keeps the battery fully charged to keep the system working during the night and during periods with dense cloud cover. A green LED on the electronics board indicates that the charger is operational.
The battery voltage is measured and sent together with the sensor data. A healthy battery should provide a voltage between 4.2V and 3.6V. Below 3.6V, the battery is close to empty.

The battery connector is also used to switch the system on or off. Disconnect the solar panel before disconnecting the battery to avoid the system continuing on solar power.

Important: the solar panel is connected to the wire terminal block. The red wire connects to the “+”, and the black wire connects to the “-“. Connecting the solar panel with the wires with reversed polarity will damage the battery charging chip. 

Connect temperature sensors (optional)

The Vinduino printed circuit board is designed to support a DHT11 or DHT22 sensor (temperature and relative humidity). These sensors are not waterproof and can only be used for measuring inside the enclosure. These were not configured for OpenVino.

For temperature measurement outside the enclosure, soil or air temperature, a waterproof temperature sensor like the DS18b20 can be used. 

Other sensors can be attached using the “Accessories” connector on the electronics board. This connector gives access to 2 digital pins, an analog input, and a switched 3.3V power supply pin that can be used for sensors that require electric power. Future use of the accessories connector is to control an irrigation valve and water pressure sensor.

Testing the Vinduino board

First connect to the Vinduino board using a USB-FTDI cable.

The color code is as follows: BLACK = GND, BROWN = CTS, RED = VCC, ORANGE = TXD, YELLOW = RXD, GREEN = RTS 

Using the Arduino serial monitor (9600) you should see this:

The values returned from Vinduino are: 

Start of packet $
API key
sensor 1
sensor 2
sensor 3
sensor 4
battery voltage
temperature
rel humidity
End of packet  !

In this instance, the temperature and relative humidity values are not returned because of the lack of these sensors.

Test the watermark sensors

Start the Arduino IDE and set it to:

And run the program :  https://github.com/ReiniervdL/Vinduino/blob/master/Vinduino-R3/Vinduino-R3__Test/Vinduino-R3__Test.ino 

Submerge sensor 1 in a wineglass full of water. The values should now reflect a number reaching closer to zero in the sensor 1 field, something like this:

For each watermark sensor, test as follows:

  1. soak the sensor for 30 minutes in the morning
  2. test the sensor reading from vinduino
  3. allow to sensor to dry during the day
  4. test the sensor reading
  5. soak overnight
  6. Test the sensor reading again
  7. record the values in the following table
Sensor30 minute test12h drying testOvernight soak
1.1309

1.2255

1.3260

1.4--

2.1274

2.2356

2.3274

2.4--

3.1

282



3.2293

3.3345

3.4--

4.1404

4.2280

4.3293

4.4300

Creating a Thinkspeak Channel

  1. Create a user account at thingspeak.com
  2. Create a new Channel for each Vinduino Sensor station:

Vinduino SensorChannel IDWrite API KeyLat.Lon.Alt.(M)Channel URL
Vinduino1_PV310994
V55XYQX29JTFNVX
-33.087423-68.924521000https://thingspeak.com/channels/310994
Vinduino2_CS311015
2MFWMJNVGMWNEFO
-33.087551-68.923538998https://thingspeak.com/channels/311015
Vinduino3_MBE311018
IORG1AH0DC1B6LL
-33.088161-68.923575996https://thingspeak.com/channels/311018
Vinduino4_MBW311022
XBA5TH2RV65Q52K
-33.088043-68.924530999https://thingspeak.com/channels/311022
Vinduino5_Baussitges540473
FZJL3SAQEJ1T2A8




FieldValue
Field 12m sensor
Field 21m sensor
Field 3.5m sensor
Field 45cm sensor
Field 5Battery Voltage
Field 6Temperature
URLOpenVino.org

Prepare to flash each Vinduino board

  1. Create a separate vinduino.ino file for each vinduino board (Here a sample: https://github.com/ReiniervdL/Vinduino/blob/master/Vinduino-R3/Vinduino-R3__DS18B20/Vinduino-R3__DS18B20.ino )
  2. Edit each file, modifying the file name and substituting the "your ThinkSpeak API here" with the Write API Key
  3. Install the following library files in Arduino IDE: DallasTemperature, OneWire, LowPower
  4. Disconnect the LoRa module from the Vinduino board. (If you don't do this, the upload will fail)
  5. Connect the vinduino board using the USB-FTDI cable
  6. Verify the compilation
  7. Upload the appropriate vinduino.ino file

NOTE:

If you are having difficulty uploading, make certain that you have the FTDI driver loaded

If you want to get the temperature in degrees Cº, please update the following code lines:


Setting up the Raspberry Pi LoRaLAN gateway for Vinduino

The Vinduino gateway receives LoRaLAN sensor data from the Vinduino sensor stations and forwards to a ThingSpeak account. The gateway uses a LD20-H USB LoRa dongle from Globalsat. This dongle is basically a USB version of the Globalsat LM-210 LoRa module used in the Vinduino sensor station, and, alike the module, works as a wireless UART. Combined with a serial terminal program, this makes a great debug tool to check out the LoRa network and sensor stations.


The Vinduino LoRa gateway can handle up to 300 sensor stations within a range of 5 miles. The software is based on the operating agnostic Python-3 programming language,and can function as a gateway on Raspberry Pi. For increased traffic handling, more USB dongles can be added, working on different frequencies.

The Python-3 gateway script, although tested to be working reliable for its basic gateway function, can be customized/improved as needed. For locations where access to Internet is not reliable, or intermittent, we added a SQLite database to store all sensor data locally. 

The Globalsat LD20-H is available on Tindie


LD-20H features
  • Ultra-high sensitive receiving ability by LoRa spread spectrum modulation technology
  • Long-distance transmission (1KM to 10KM)
  • Easy to use and easy to configure
  • Multiple dongles for multi-channel gateway
  • Programmable parameters:
    • Frequency: 862-1020 MHz
    • RF data rate: 0.81K, 1.46K, 2.6K, 4.56K, 9.11K, 18.23K bps
    • Max TX power: 5-20 dBm (100mW max)
    • UART baud rate: 1200-57600 bps, parity non, odd, even


LED Definition

Color

Definition

Description

Orange

Rx

On: Receiving data.
It would be Off after receiving data.

Green

Tx

On: Transmitting data.
It would be Off after transmitting data.

Red

P1

On: Power-saving mode

It would be Off in normal mode and wakeup mode.

Blue

BZ

On: Idle state

It would be Off while transmitting/receiving data.



Gateway Installation

  1. Setup the Raspberry Pi
  2. The Raspberry Pi assumes that the LD-20H connected to the USB serial port is an AT-command modem. A solution for this is to bypass the ModemManager: 

    sudo systemctl mask ModemManager.service

  3. Check to see if the Raspberry Pi recognizes the LD-20H USB connection:


pi@openvinopi:~ $ lsusb
Bus 001 Device 004: ID 04b4:0003 Cypress Semiconductor Corp. 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


4. Test the connection to the LD-20H.
A great way to test out the serial port is to use the minicom program:
sudo apt-get install minicom
Now run up minicom on the Raspberry Pi using
minicom -b 9600 -o -D /dev/ttyAMA0 
If this doesn't work, make sure that the LoRa dongle is set to 9600,8N1
Also it must have 915MHz as the set frequency, and 0.81Kb as the data transmission rate.
These settings can be made using the LoRa Configuration Tool (a windows application) as follow:
Install the driver CypressDriverInstaller_0.exe for a LD-20H LoRa device in a Windows system an after with the LoraConfig_1509181.exe you can set the frequency of the LD-20 yourself.


CypressDriverInstaller_0.exe LoraConfig_1509181.exe

Example: A LD-20 programmed to work on an allowed frequency in the 868MHz European Lora band.


5. Install the Vinduino gateway scripts:


Thingspeak-SQLite.pySQLite-Vinduino3.py
Upload the starter database to /usr/local/bin
vinduino.db
 
scp SQLite-Vinduino3.py pi@10.1.1.30:/tmp

scp Thingspeak-SQLite.py pi@10.1.1.30:/tmp    

pi@hotel:/usr/local/bin $ mv /tmp/SQLite-Vinduino3.py .
pi@hotel:/usr/local/bin $ mv /tmp/vinduino.db .
pi@hotel:/usr/local/bin $ mv /tmp/Thingspeak-SQLite.py .
pi@hotel:/usr/local/bin $ sudo chown root:staff SQLite-Vinduino3.py 
pi@hotel:/usr/local/bin $ sudo chown root:staff vinduino.db
pi@hotel:/usr/local/bin $ sudo chown root:staff Thingspeak-SQLite.py 
pi@hotel:/usr/local/bin $ sudo chmod +x Thingspeak-SQLite.py 
pi@hotel:/usr/local/bin $ sudo chmod +x SQLite-Vinduino3.py 

pi@openvinopi:/usr/local/bin $ ls -la
total 92
drwxrwsr-x  3 root staff  4096 Aug  1 20:38 .
drwxrwsr-x 10 root staff  4096 Apr 10 06:10 ..
-rwxr-xr-x  1 root staff 35098 Aug  1 14:51 miniterm.py
-rwxr-xr-x  1 root staff 28907 Aug  1 14:51 miniterm.pyc
drwxr-sr-x  2 root staff  4096 Aug  1 14:51 __pycache__
-rwxr-xr-x  1 root staff   339 Aug  1 20:38 SQLite-Vinduino3.py
-rwxr-xr-x  1 root staff   317 Aug  1 13:50 thingspeak
-rwxr-xr-x  1 root staff  1885 Aug  1 20:36 Thingspeak-SQLite.py
-rw-r--r--  1 root staff     0 Aug  1 20:34 vinduino.db

6. Make sure we have the correct version of python

edit the SQLite-Vinuino3.py and Thingspeak-SQLite.py files to begin with:
#!/usr/bin/python3

7. Also, the following Python modules are needed for the Vinduino gateway script:

  1. serial 
  2. time
  3. thingspeak 

  4. sqlite3

    sudo apt-get install python3-pip
    sudo pip3 install pyserial
    sudo pip3 install thingspeak
    sudo apt-get install sqlite3


8. Edit the Thingspeak-SQLite.py file to reference the proper serial port.

ser = serial.Serial('/dev/ttyACM0', 9600, timeout=900)
#ser = serial.Serial('/dev/cu.usbmodem1411', 9600, timeout=900)


9.Test the gateway script

pi@openvinopi:~ $ Thingspeak-SQLite.py 


Assuming the gateway script works properly, you should see data published into your Thingspeak URL's.


10. Create the startup script for the LoRa gateway


pi@openvinopi:~ $ sudo vi /etc/init.d/LoRa_Gateway 
#! /bin/sh
# /etc/init.d/LoRa_Gateway 

### BEGIN INIT INFO
# Provides:          LoRa_Gateway
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting LoRa_Gateway"
    # run application you want to start
    /usr/local/bin/Thingspeak-SQLite.py &
    ;;
  stop)
    echo "Stopping LoRa_Gateway"
    # kill application you want to stop
    killall Thingspeak-SQLite.py
    ;;
  *)
    echo "Usage: /etc/init.d/LoRa_Gateway {start|stop}"
    exit 1
    ;;
esac

exit

11. Register the service

sudo chmod +x /etc/init.d/LoRa_Gateway
sudo update-rc.d LoRa_Gateway defaults

12. Create a Vinduino user

sudo adduser --system --home /home/vinduino vinduino

13. Move the vinduino.db to the new user home

sudo mv /usr/local/bin/vinduino.db /home/vinduino
sudo chown vinduino /home/vinduino/vinduino.db 
sudo chown vinduino /usr/local/bin/SQLite-Vinduino3.py /usr/local/bin/thingspeak /usr/local/bin/Thingspeak-SQLite.py 

14. Edit the gateway file to point to the new directory for the database:

sudo vi /usr/local/bin/Thingspeak-SQLite.py 
Edit the line (two locations!)
conn = sqlite3.connect('/home/vinduino/vinduino.db')

15. Start the gateway

sudo /etc/init.d/LoRa_Gateway start

16. Check to see if the gateway is running:

pi@openvinopi:~ $ ps -ef | grep Thingspeak-SQLite.py 
root      3109     1  0 11:29 pts/1    00:00:00 /usr/bin/python /usr/local/bin/Thingspeak-SQLite.py
pi        3165  2405  0 11:39 pts/1    00:00:00 grep --color=auto Thingspeak-SQLite.py
17. Reboot!
sudo reboot


pi@openvinopi:~ $ ps -ef | grep Thing
root       482     1  7 11:39 ?        00:00:01 /usr/bin/python /usr/local/bin/Thingspeak-SQLite.py
pi         761   748  0 11:40 pts/0    00:00:00 grep --color=auto Thing

  • No labels

8 Comments

  1. Anonymous

    Great post! I used this to talk to the Watermark sensors with my mac through the LoRa wan. Very helpful steps here. Now I am trying to figure out why Vinduino is giving us resistance rather than centibars.

  2. Anonymous

    Great Post  ! Thank you for the information. Regards Chris

  3. Anonymous

    is there a more detailed description off how to get this setup and running

    1. What details do you think we are missing?

  4. Anonymous

    I cant get the lora setup on raspberry pi

    1. Now you can get how to setup the Lora LD-20 on a Windows system and after, you can move the dongle to the Rasberry Pi

  5. Anonymous

    Hola Mike,

    Vengo siguiendo Vinduino y encontré tu proyecto Openvino,luego vi tu video en Zaragoza,etc.

    Te felicito por la capacidad de manejar tantos conceptos e integrarlos en Openvino.

    Mi pregunta,por ahora,es de LoRa: Los modulos LoRa funcionan bien en 915 Mhz ,acá en Mendoza ?

    Tengo entendido que esa frecuencia se la otorgaron a un operador telefónico, por lo que podria haber interferencias/ruido que alterarían las mediciones de los nodos. Hicieron mediciones ?.Gracias.

    Saludos

    Marcelo (from Guaymallén,MZA)