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

Post Reply
User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Weather Station

Post by JohnCrow »

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.
Remote Board
Remote Board
RemoteBoard.jpg (41.67 KiB) Viewed 15699 times
LocalBoard
LocalBoard
LocalBoard.jpg (53.96 KiB) Viewed 15699 times
NRF24L01_ThermoHygro_Remote_V1.fcfx
RemoteSensor
(14.39 KiB) Downloaded 892 times
NRF24L01_ThermoHygro_Local_V6.fcfx
LocalSensor
(34.27 KiB) Downloaded 920 times
1 in 10 people understand binary, the other one doesn't !

User avatar
Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times
Contact:

Re: Weather Station

Post by Steve001 »

As always another fantastic well documented project thanks for sharing

Steve
Success always occurs in private and failure in full view.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Weather Station

Post by medelec35 »

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

Martin
Martin

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Weather Station

Post by JohnCrow »

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 853 times
Board2_TX_ThermoV2_LED.fcfx
Sensor2
(12.04 KiB) Downloaded 842 times
DualBoard_RX_ThermoV2.fcfx
Local Board
(15.21 KiB) Downloaded 854 times
1 in 10 people understand binary, the other one doesn't !

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

Re: Weather Station

Post by tech »

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: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: Weather Station

Post by DCW »

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..!!

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Weather Station

Post by JohnCrow »

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 !

Post Reply