Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

The Weather Station

These are the components used to build and deploy the Weather Station on the platform in the middle of the vineyard.

Components

  • Raspberry Pi 3 Model B Vi.2 

  • Raspberry Pi clear case

  • USB - microUSB cable

  • SanDisk Extreme 64GB MicroSD

  • MicroSD - SD adapter

  • Laptop computer w/ Arabic keycaps

  • Ethernet cable and adapter

  • The Weather Board Interface board 

  • Adafruit 12Bit I2C Analog to Digital converter ADS1015

  • DS3231 Real time clock

  • Grove AM2315 - Encased I2C Temperature/Humidity Sensor

  • header pins and cables

  • Anemometer

  • Rain gauge 

  • Wind direction indicator

  • WIFI Access Point

External 74GB USB drive (for backup)

Raspberry Pi 

Headless Raspberry Pi Setup

Step 1. Download Raspbian Image

Head on over here to grab a copy of the Raspbian image. The “Lite” version will do.

Step 2. Write Image to SD Card

Write the image to SD card. You can find detailed instructions here.

  1. Insert the SD card.

    1. Find the device name

mbarrow$ diskutil list

/dev/disk3 (internal, physical):

   #:                       TYPE NAME                    SIZE       IDENTIFIER

   0:     FDisk_partition_scheme                        *63.9 GB    disk3

   1:               Windows_NTFS                         63.9 GB    disk3s1

Unmount the device

mbarrow$ diskutil unmountDisk /dev/disk3

Unmount of all volumes on disk3 was successful

Copy the Raspbian image to the SD card:

(This process can take several minutes)

mbarrow$ sudo dd bs=1m if=/Users/mbarrow/Documents/proyectos/OpenVino/raspbian/2017-11-29-raspbian-stretch-lite.img of=/dev/disk3 conv=sync

Step 3. Add “SSH” File to the SD Card Root

Enable SSH by placing a file named “ssh” (without any extension) onto the boot partition of the SD card:

MTB-MBP:boot mbarrow$ pwd

/Volumes/boot

MTB-MBP:boot mbarrow$ touch ssh

MTB-MBP:boot mbarrow$ ls -la ssh

-rwxrwxrwx  1 mbarrow  staff  0 Jul 16 15:43 ssh

Step 4. Setup a fixed IP address for access over ethernet or wifi

(******THIS SECTION NEEDS REVISION******)

a) Change to the pi network directory:

MTB-MBP:~ mbarrow$ cd /Volumes/rootfs

b) Edit the network interface file /etc/network/interfaces

# Include files from /etc/network/interfaces.d:

source-directory /etc/network/interfaces.d

auto eth0

iface eth0 inet static

        address 10.1.1.30

        netmask 255.255.255.0

        gateway 10.1.1.1

allow-hotplug wlan0

iface wlan0 inet dhcp

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

c) Unmount SD card and pop it into the pi with a network cable.

Step 5. Configure your IP Address

Step 6. SSH into your Pi

Use SSH to access the Pi. The default credentials are:

username: pi
password: raspberry

Step 7. Configure the Pi

That’s it! You can now configure your Pi via sudo raspi-config

Change the hostname to openvinopi and the timezone to:

Current default time zone: 'America/Argentina/Mendoza'

Local time is now:      Tue Jul 25 22:52:19 ART 2017. (Happy Birthday!)

Universal Time is now:  Wed Jul 26 01:52:19 UTC 2017.

Step 8. Configure wifi

Edit the file /etc/wpa_supplicant/wpa_supplicant.conf to look like this:

country=GB

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network={

ssid="costaflores"

proto=RSN

key_mgmt=NONE

}

Step 8. Update the Pi

Secure your login with a rsa key authentication and enabling it only the port 22. Here a guide.

A classic system update is also suggested:

sudo apt-get update
sudo apt-get upgrade

Step 9. Set a static IP address

Start by editing the dhcpcd.conf file

sudo vi /etc/dhcpcd.conf

Scroll all the way to the bottom of the file and add one, or both of the following snippets. Depending on whether you want to set a static IP address for a wired connection or a wireless connection eth0 = wired, wlan0 = wireless.

#configure a static ethernetIP address

interface eth0

static ip_address=192.168.8.252/24

static routers=192.168.8.1

static domain_name_servers=192.168.8.1

interface wlan0

static ip_address=192.168.8.253/24

static routers=192.168.8.1

static domain_name_servers=192.168.8.1

Step 10. Reboot

sudo reboot

sudo route add default gw 192.168.1.1

Weather Board

The Weather Board is a weather station controller board designed to interface to Arduino and Raspberry Pi computers. It is an interface board developed by SwitchDoc Labs

It contains a built in I2C BMP280 Barometer/Temperature sensor and a DS3231 RTC/EEPROM. The board contains interfaces for the following: 

  • WeatherRack Anemometer/Wind Vane/Rain Bucket 

  • Embedded Adventures I2C Lightning Detector MOD-1016 board

  • Adafruit HTU21D-F Temperature/Humidity breakout board

  • Adafruit 32KB FRAM /ADS1015 

  • SwitchDoc Labs Grove ADS1116 16 Bit ADC Board 

A Grove connector is a four pin standardized size connector used to plug into base units and Grove modules.  

http://www.switchdoc.com/weatherrack-weather-sensors/

DS3231/EEPROM Real Time Clock 

The DS3231 is a low-cost, extremely accurate I2C real- time clock (RTC). The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device. The DS3231 also has an on board temperature sensor.

Why use a Real Time Clock?

A realtime clock is necessary for any project requiring accurate time keeping especially when you don’t always have an Internet connection. The Raspberry Pi keeps pretty good time, but only if it is connected to the Internet. The Pi uses NTP to set the clock on power up if the Internet is available. It then calls the NTP servers (some are actually hosted by the National Institute of Standards and Technology (NIST) and linked to their atomic clocks). You aren’t going to get atomic clock accuracy using NTP, but it is pretty good.

The SwitchDoc Labs DS3231/EEPROM combination is included with the Weather Board board. It is plugged in by the user into JP11, taking care to having the battery facing the top of the board. Connected to the Weather Board, the DS3231 RTC looks like this:

The DS3231 library is on  https://github.com/switchdoclabs/RTC_SDL_DS3231.

Example Code for the DS3231

There is a testSDL_DS3231.py included with the library. Here is the bare code needed:

#!/usr/bin/env python
#
# Test SDL_DS3231
# John C. Shovic, SwitchDoc Labs
# 08/03/2014
#
#

# imports

import sys
import time
import datetime

import SDL_DS3231

# Main Program

print “”
print “Test SDL_DS3231 Version 1.0 – SwitchDoc Labs”
print “”
print “”
print “Program Started at:”+ time.strftime(“%Y-%m-%d %H:%M:%S”)

filename = time.strftime(“%Y-%m-%d%H:%M:%SRTCTest”) + “.txt”
starttime = datetime.datetime.utcnow()

ds3231 = SDL_DS3231.SDL_DS3231(1, 0x68)
ds3231.write_now()

# Main Loop – sleeps 10 minutes, then reads and prints values of all clocks

while True:

currenttime = datetime.datetime.utcnow()

deltatime = currenttime – starttime

print “”
print “Raspberry Pi=\t” + time.strftime(“%Y-%m-%d %H:%M:%S”)

print “DS3231=\t\t%s” % ds3231.read_datetime()

time.sleep(10.0)
<\code>

You should see a result like this:

Test SDL_DS3231 Version 1.0 - SwitchDoc Labs Program Started at:2014-08-03 19:29:58 Raspberry Pi= 2014-08-03 19:29:58 DS3231= 2014-08-03 19:29:58

The wind and rain sensors

A standard anemometer measures wind speed by closing a contact as a magnet moves past a switch. One contact closure a second indicates 2.4 km/h. If you use a different anemometer, this constant can be changed in software. The Wind vane has 8 switches, each connected to a different resistor. The Weather Board measures the resistance value of the resistor by measuring the voltage on a resistor divider (with 10 K Ohm resistor). 

The tipping bucket rain gauge makes one momentary contact closure per 0.2794 mm of rain. 

To Set North on Wind Vane

Wind Vane screw Should Point North – This is South

North is the screw hole on the base (without the tab).

There is a tiny little S near the top of the round base of the wind vane and a small N on the other side.

Another way you can calculate it is hand setting the wind vane to north,  reading from the software, and marking the base to indicate North.

If you accidentally mount it incorrectly, you can always adjust the direction in software.

Raspberry Pi Drivers are here at github.com/switchdoclabs/SDL_Pi_Weather_80422.

Cabling the weather vane and rain gauge

The rain gauge and wind gauges come cabled with short cables with RJ-11 connectors. This is a problem, because we need longer, more protected cabling to go to the WeatherPi. So we need to replace the current cabling, using a single Cat5 RJ45 to connect both instruments, in a sort of daisy chain.

Rain Gauge

  1. First run the RJ45 cable to the rain gauge.

  2. Remove a short section of the RJ45 cable shield, to enable access to the wiring pairs. 

  3. Replace Rain Gauge RED wire with RJ45 GREEN, and Rain Gauge GREEN wire with GREEN/WHITE

  4. Tape the cabling in place for stability, but insure that no taping interferes with the rain gauge mechanism.

Original Cable

New Cable

RJ-11 pins

Green

Green/White

3

Red

Green

4

Wind Gauges

The wind direction indicator is cabled to the anemometer through a short RJ11 cable. We can leave this connection as is. But the cable that goes to the WeatherPi needs to be replaced with the tail of the cable we used from the Rain Gauge.

  1. First remove the wind indicator from the T-bar support.

  2. Remove the three screws holding the first cable guide.

  3. Remove the three screws holding the sensor board in place.

  4. Remember the position of the sensor board with reference to the weather vane.

  5. Cut the weather board cable.

  6. Route the new Cat-5 cable through the first cover.

  7. Cut away to the GREEN/WHITE and GREEN cables. These are already used by the Rain Gauge.

  8. Remove the silicon protector and unsolder the existing four cables.

  9. Replace with new cables as below:

  10. Replace the covers, and route cables accordingly. Connect anemometer RJ11

Original Cable

New Cable

RJ-11 pins

Black

Blue

5

Red

Blue/White

4

Yellow

Orange/White

3

Green

Orange

2

Split the other Cat-5 cable extreme with two RJ11 connectors per the original configurations seen above.

AM2315 Temperature/Humidity Sensor

The AM2315 I2C is a temperature and humidity sensor.. It uses special temperature and humidity acquisition technology, to ensure that the sensor has high reliability and excellent long-term stability. While it is not waterproof, it is weather resistant.  This sensor does far better for sensing temperature and humidity where there might be wind and rain.

  • Comes with attached Grove connector

  • 3.3V to 5.5V I2C interface and power 

  • 10 mA max current use during conversion

  • Good for 0-100% humidity readings with minimum 2% accuracy

  • Good for -20 to 80°C temperature readings ±0.1°C typical accuracy

  • Updated every 500ms (0.5 Hz)

  • Body size 98mm x 16mm diameter

  • 20 inch long - 4 wire cable

  • This board/chip uses I2C 7-bit address 0x5C.

Here is the complete datasheet.

Connect the AM2315 to connector J7 on the Weather Board. 

To test the AM2315, load the program testAM2315.py onto the Raspberry Pi:

import time

from tentacle_pi.AM2315 import AM2315

am = AM2315(0x5c,"/dev/i2c-1")

for x in range(0,10):

    temperature, humidity, crc_check = am.sense()

    print "temperature: %0.1f" % temperature

    print "humidity: %0.1f" % humidity

    print "crc: %s" % crc_check

    print

    time.sleep(2.0)

This program requires the following modules:

sudo apt-get install python-pip

sudo apt-get install libi2c-dev

sudo apt-get install python-dev

sudo pip install tentacle_pi

Now you can test:

pi@openvinopi:~ $ sudo python testAM2315.py 

temperature: 13.1

humidity: 52.5

crc: 1

Yes, the temperature in my house is 13.1ºC, and my hands are cold.

Connecting the Weather Board and Sensors to the Raspberry Pi

This is how the Weather Board gets wired to the Raspberry Pi. 

Weather Board

Reference

Color

GPIO-PIN

JP2-2

Rain Bucket

Grey

37

JP2-3

Anemometer

Gold

40

JP1-1

Power GND

Black

6

JP1-2

Power VDD

Red

1

J7 (Grove)

AM2315 Temp

-

-

JP4-1

I2C-SCL

Yellow

5

JP4-2

I2C-SDA

Orange

3

JP11

DS3231 RTC

-

-

JP5

ADS1015

-

-

Configuring I2C

I2C is a very commonly used standard designed to allow one chip to talk to another.

So, since the Raspberry Pi can talk I2C we can connect it to a variety of I2C capable chips and modules.

We need to configure the Raspberry Pi to use I2C. To do this, run the following commands to install the i2c-tools utility:

sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools

Then edit /etc/modules

sudo vi /etc/modules

Add the following lines:

i2c-bcm2708
i2c-dev

You will also need to update the /boot/config.txt file. Edit /boot/config.txt and add the text:

dtparam=i2c1=on
dtparam=i2c_arm=on

Then reboot and test:

sudo reboot

pi@openvinopi:~/RaspberryPi-WeatherPiArduinoV2 $ sudo i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 

50: -- -- -- -- -- -- -- 57 -- -- -- -- 5c -- -- -- 

60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 

70: -- -- -- -- -- -- -- 77

It is necessary to execute twice in rapid succesion the i2cdetect command to insure that the "sleeping" AM2315 temperature sensor responds.

After you hook up your SwitchDoc Labs DS3231 Module to the Raspberry Pi (3.3V, GND, SCL, SDA), run the following command:

pi@openvinopi: sudo i2cdetect -y 1

The results should be similar to this.  

This shows that four I2C addresses are in use:

Device

Address

DS3231 Realtime Clock

0x68

AM2315 Temperature Sensor

0x5C

AT24C32 eeprom.

0x57

BMP085 Barometric Pressure Sensor

0x77

Temperature Sensor

0x48

Install the WeatherPi test software:

Now test:

pi@openvinopi:~/RaspberryPi-WeatherPiArduinoV2 $ sudo python WeatherPiArduinoV2.py

---------------------------------------- 

----------------- 

 WeatherRack Weather Sensors

----------------- 

Rain Total= 0.11 in

Wind Speed= 4.14 MPH

MPH wind_gust= 8.45 MPH

Wind Direction= 225.00 Degrees

Wind Direction Voltage= 2.022 V

----------------- 

----------------- 

 DS3231 Real Time Clock

----------------- 

Raspberry Pi= 2017-08-11 18:24:08

DS3231= 2017-08-11 18:24:07

DS3231 Temperature= 15.00 C

----------------- 

----------------- 

 AT24C32 EEPROM

----------------- 

writing first 4 addresses with random data

address = 0 writing value=153

address = 1 writing value=34

address = 2 writing value=34

address = 3 writing value=55

----------------- 

reading first 4 addresses

address = 0 value = 153

address = 1 value = 34

address = 2 value = 34

address = 3 value = 55

----------------- 

----------------- 

 BMP280 Barometer

----------------- 

Temperature = 15.22 C

Pressure = 90.10 KPa

Altitude = 979.76 m

Sealevel Pressure = 90.10 KPa

----------------- 

----------------- 

 AM2315 Temperature/Humidity Sensor

----------------- 

AM2315 temperature: 13.8

AM2315 humidity: 53.4

AM2315 crc: 1

----------------- 

----------------- 

 HTU21DF Temp/Hum Not Present

----------------- 

----------------- 

----------------- 

 AS3935 Lightning Detector Not Present

----------------- 

----------------- 

----------------- 

 FRAM Not Present

----------------- 

----------------- 

Sleeping 10 seconds

  • No labels