Weather Station

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1354
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 375 times
Been thanked: 699 times
Contact:

Weather Station

Postby JohnCrow » Mon Aug 29, 2016 11:21 am

My latest project is a Weather Station with remote sensor and real time clock.

Currently the system only has 1 remote sensor, but this can be expanded.

This project is only compatible with Flowcode 7 as the nRF24L01 component is not included in earlier versions.

Equipment Required.

Remote Sensor(s)

1 EB-006 V9 Multi-programmer
1 EB-005 LCD E-Block
1 EB-016 Proto-Board
1 nRF24L01 RF Module (With suitable aerial) (Sparkfun)
1 HTU210 (SHT21 Sensor) Temperature / Humidity Module (Adafruit)
1 Ribbon Cables (M-F)

The RF and Temperature Sensors can be sourced from several places; I have just named the type I’m using.
Matrix also supply a Thermo-Hygrometer board using the SHT21 sensor. (EBM016)

Connections

HTU210 Thermo-Hygrometer

This uses the I2C Bus to connect to the microcontroller.
Port B4 SDA
Port B5 SCL
Power is taken from the 5V supply on the EB-006

nRF24L01 RF Module

Port C0 LED
Port C2 CE
Port C3 SCK
Port C4 MIOS
Port C5 MOSI
Port C7 CSN

This module has a 3.3v regulator on board so can be connected directly to the 5V supply from the EB-006.
Cheaper (E-Bay) modules are often only 3.3V so care must be taken when connecting them up.

I have built a customised E-Block with the remote sensor on this part of the project.
This is configured using the same type of “Patch System” built into most E-blocks.

Alternatively, it can be connected using the EB-016, in the same way as the HTU210 used on the Main Board

Note, if this method is used then a pair of ribbon cables will be needed as a single EB-016 cannot be connected to ports B and C simultaneously.

The LED is used to indicate when the board is transmitting.
It is simply turned on & off in the Flowcode program at a suitable point.


EB-005 LCD Display
This is just connected to Port D To give a local reading of the data being sent over the RF Link.


Main Board

1 EB-006 V9 Multi-programmer
1 EB-016 Proto-Board
1 nRF24L01 RF Module (With suitable aerial) (Sparkfun)
1 HTU210 (SHT21) Temperature / Humidity Module (Adafruit)
1 DS1307 Real Time Clock Module (Adafruit)
1 Custom 4 x 20 LCD Display
3 Ribbon Cables (M-F)

Connections

HTU210 Thermo-Hygrometer

This uses the I2C Bus to connect to the microcontroller.
Port B4 SDA
Port B5 SCL
Power is taken from the 5V supply on the EB-006

DS1307 Real Time Clock

This uses the component developed by Jordy
This uses the I2C Bus to connect to the microcontroller.
Port B4 SDA
Port B5 SCL
Power is taken from the 5V supply on the EB-006

Because of the delays between each page of data displayed on the LCD, display seconds has been turned off in the flowchart. Currently a 2 second delay between each page plus system overheads would make the seconds display inaccurate.


nRF24L01 RF Module

Port C2 CE
Port C3 SCK
Port C4 MIOS
Port C5 MOSI
Port C7 CSN

Port D Custom LCD Display

This uses a standard 4 x 20 LCD display, using the same control chip as the Matrix EB005

Operation

This is a simplified description of the operation of the Flowcode programs stored in the PIC connected to each EB-006.
For a full description of the operation of each component visit the Matrix TSL help pages.

Remote Unit

After initialising the various modules, the program goes into a loop.

Read the temp and humidity values from the HTU210 as integers.

Calculate Dew Point
This is done as an approximation
Dew Point = Temperature – ((100 – Humidity)/5)

An accurate calculation uses a quite complex formula, which is more than the requirement for this project.

Store Temperature, Humidity & Dew Point as Byte 0, Byte 1, & Byte 2 in the Transmit buffer of the nRF2401
It can store up to 32 bytes

The buffer is then transmitted

The Temperature & Humidity values are then displayed on the LCD
Short Delay
Clear LCD
Display Dew Point on the LCD
Short Delay
Clear LCD

The LED on the nRF24L01 is flashed.

The loop then starts again and reads the next set of data.

Main Board

After initialising the various modules, the program goes into a loop.

Read the Local Temperature & Humidity values from the Local HTU210 as Floats
Convert these to strings for displaying on the LCD

Read the buffer received from the remote sensor.

Store Byte 0 as Remote Temp
Store Byte 1 as Humidity Values
Store Byte 2 as Dew Point

Display both local, remote data values & the RTC values in 3 pages , with a short delay between them on the custom LCD display.

The remote values are sent as integers as the nRF24L01 cannot send floats directly.

If the sensor is offline a message showing this rather than the data is displayed.
This is done by checking for a signal at the start of the loop and jumping to a different path to show this.

RemoteBoard.jpg
Remote Board
RemoteBoard.jpg (41.67 KiB) Viewed 6896 times


LocalBoard.jpg
LocalBoard
LocalBoard.jpg (53.96 KiB) Viewed 6896 times


NRF24L01_ThermoHygro_Remote_V1.fcfx
RemoteSensor
(14.39 KiB) Downloaded 535 times


NRF24L01_ThermoHygro_Local_V6.fcfx
LocalSensor
(34.29 KiB) Downloaded 564 times
These users thanked the author JohnCrow for the post (total 8):
medelec35 (Mon Aug 29, 2016 1:12 pm) • Steve001 (Mon Aug 29, 2016 3:10 pm) • jgu1 (Mon Aug 29, 2016 4:23 pm) • kersing (Mon Aug 29, 2016 6:33 pm) • LeighM (Tue Aug 30, 2016 9:20 am) • Benj (Tue Aug 30, 2016 11:48 am) • dazz (Sat Sep 17, 2016 8:10 pm) • acestu (Thu Jan 12, 2017 4:47 pm)
Rating: 47.06%
 
1 in 10 people understand binary, the other one doesn't !

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 908
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 388 times
Been thanked: 445 times
Contact:

Re: Weather Station

Postby Steve001 » Mon Aug 29, 2016 3:11 pm

As always another fantastic well documented project thanks for sharing

Steve
These users thanked the author Steve001 for the post (total 2):
JohnCrow (Mon Aug 29, 2016 6:51 pm) • jgu1 (Mon Sep 12, 2016 6:06 am)
Rating: 11.76%
 
Success always occurs in private and failure in full view.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 7118
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 1917 times
Been thanked: 2766 times
Contact:

Re: Weather Station

Postby medelec35 » Mon Aug 29, 2016 6:19 pm

I have to agree with Steve on that one.
Thanks for posting.
I enjoy looking at the projects you post. :)

Martin
These users thanked the author medelec35 for the post (total 2):
JohnCrow (Mon Aug 29, 2016 6:51 pm) • jgu1 (Mon Sep 12, 2016 6:06 am)
Rating: 11.76%
 
If your hardware is not working as expected, try looking here first:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1354
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 375 times
Been thanked: 699 times
Contact:

Re: Weather Station

Postby JohnCrow » Sun Sep 11, 2016 4:45 pm

Weather Station (V2)

Introduction.
This is a follow-up to my original project, this time using 2 independent external sensors.
It should be read in conjunction with the first part for a full in-depth description of the project. Including connections etc.

Hardware Required.
3 x EB-006 Programmer Boards fitted with 16F1937 PICs
2 x EB-005 LCD Displays
1 x Custom 4x20 LCD Display
2 x EB-016 Proto-Boards
3 x nRF2401 RF Boards (With Aerials)
2 x HTU21D Thermo-Hygrometer Sensors
2 x RED LEDs
2 x 330R Resistors
1 x M-F Ribbon Cable
3 x Matrix PSU’s

Operation
Basically, I have 2 of the original remote boards, connecting to a local board.
For the purpose of this version I have removed the Real Time Clock from the local board.
Also the local board does not have its own sensor.
Temperature & Humidity data is not time sensitive, as the change in values does not occur instantly, so a small delay in transmission will not have any detrimental effect.
The programs running in each of the remote sensors is almost identical except for one point.
A third variable is needed to identify which sensor is being transmitted to the local board.

This is done as follows
A variable called Board_ID is set up and given the value 1 (or 2 for the second board).
This is then transmitted as follows.
Board_ID
Temperature
Humidity

To prevent transmit clashes, each sensor has a different delay in the transmit loop, plus a short random delay using the Random function in Flowcode to add a few extra microseconds to the loop.
Watching the Tx LED on both sensors, it can been seen when the data is sent. This is illuminated for 500ms after the data is sent.
This is connected to Port D0
The local board reads the transmitted data buffer, and depending on the first byte read (Sensor_ID) using a decision box displays the Temperature (second byte) and Humidity (third byte) of either sensor 1 or sensor 2.

Board1_TX_ThermoV2_LED.fcfx
Sensor1
(12.01 KiB) Downloaded 509 times

Board2_TX_ThermoV2_LED.fcfx
Sensor2
(12.04 KiB) Downloaded 505 times

DualBoard_RX_ThermoV2.fcfx
Local Board
(15.22 KiB) Downloaded 509 times
These users thanked the author JohnCrow for the post (total 7):
kersing (Sun Sep 11, 2016 6:46 pm) • LeighM (Sun Sep 11, 2016 9:52 pm) • jgu1 (Mon Sep 12, 2016 6:06 am) • medelec35 (Mon Sep 12, 2016 7:45 am) • Benj (Mon Sep 12, 2016 5:04 pm) • petesmart (Mon Sep 12, 2016 5:52 pm) • Steve001 (Mon Sep 12, 2016 5:54 pm)
Rating: 41.18%
 
1 in 10 people understand binary, the other one doesn't !

tech
Posts: 292
Joined: Tue Sep 23, 2008 9:39 am
Been thanked: 6 times
Contact:

Re: Weather Station

Postby tech » Fri Apr 28, 2017 2:14 pm

Hi John,

Great project!

I am working on a small project based on your program and I would like to know if you meet transmission delays?

I use the PIC16F876A and I wonder if that would not be the cause!

At the moment I only transmit values of 0 - 255 to see if the transmision this fact has real time but there is a delay of 1s to 3s ...

Thank you for your help

Chris

(Sorry for the language I use google translation)

DCW
Posts: 12
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 4 times
Contact:

Re: Weather Station

Postby DCW » Fri May 19, 2017 8:13 am

Hello John... a very smart well made project Sir.!!
much appreciated...
can we not use this type of project on the 'front page' of matrixtsl.. to show the world what happens in FC.!??

Thanks...
Spencer..!!
These users thanked the author DCW for the post:
JohnCrow (Fri May 19, 2017 10:07 am)
Rating: 5.88%
 

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1354
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 375 times
Been thanked: 699 times
Contact:

Re: Weather Station

Postby JohnCrow » Fri May 19, 2017 10:16 am

Hi Chris
Sorry only just spotted your post.

If I remember I have a small (different) transmit delay in each of the sensors to stop data transmit clashes.
This means there is less chance of both being received at the exact same time.

I didn't try it running the program without a delay so without testing it I don't know.
I don't think the difference between the PIC16F1937 and the PIC16F876A would be that great for a simple program.

For my application, the delay isn't a problem. I'll try it without the delay if I get time and post the results.
1 in 10 people understand binary, the other one doesn't !