Extension Sensors Nodemcu ESP8266 for Weewx

6.0K300

Intro: Extension Sensors Nodemcu ESP8266 for Weewx

This is an instructable to add Sensors to the weewx weather station software.

If you have not weewx, you can learn some stuff in this tutorial.

you need some basic knowledge of Arduino code and how to upload on a device.

You find weewx information here: http://www.weewx.com/

What you build is 2 Devices:

1 Device send Temperature and Humidity to the weewx software.

1 Device send Soil Temperatures of different ground deeps to the weewx software.

Our first Device is a BME 280 sensor.

Our second device is a chain of 3 DS18B20 Temperatur sensors. (You can add more if you like).

Lets start:

STEP 1: What You Need...

Weewx up and running + access to weewx server. (for example a raspberry PI 3).

2 Nodemcu ESP8266 modules

3 or more DS18B20 Sensors

1 BME 280 combo Sensor

1 Aluminium pipe or similar with a diameter of 10mm and 1mm wall thickness and ca. 1 Meter long

1 Waterproof case with cable gland and lock nut.

1 5V Power source ( Mobile loader for example ).

Some wires and soldering stuff.

You find BME280 sensor and Nodemcu modules on ebay.

For Aluminum pipe i choose a local hardware store

For the DS18B20 and waterproof case i use www.reichelt.de

https://www.reichelt.de/DS-18B20/3/index.html?ACTI...

https://www.reichelt.de/EL-FK-110/3/index.html?ACT...

and the group of cable gland with lock nuts

https://www.reichelt.de/Kabelverschraubungen-Bopla...

For the bme280 you can optional use a branching can

https://www.reichelt.de/Installationsmaterial/EL-D...

STEP 2: Start With the BME 280 Sensor Hardware Setup

Solder the strip in the BME280.

Then wiring the BME to the Nodemcu:

BME VIN to 3.3V

BME GND to GND

SCL to D4

SDA to D3

If you like you can put the Device in a housing, but make sure, that some holes are in the housing, so that the humidity and temperature values are correct.

STEP 3: BME 280 Nodemcu ESP8266 Code

For the code you can use my github repositories:

https://github.com/Landixus/BME280_TO_SERVER_WEEWX

The ino file needs some inserts from you:

The IP Address of your weewx server or URL

and the route where you have the php file, make sure the area is writable.

i choose the public_html dir because it is a home server.

if you want to clone the git repositories, and have git installed on your server, you can clone with the command:

"git clone"https://github.com/Landixus/BME280_TO_SERVER_WEEWX"

Now we need to do some stuff on our weewx server.

You need to make the paths to your settings!

in

/home/weewx/public_html

create a folder data

in the data folder create a bme.txt for example with:

nano bme.txt

the file should be empty.

make it writable with:

 chmod -R 777 bme.txt 

(you never do this on a server that is internet accessible!)

in the folder

/home/weewx/public_html 

you put the bme.php of my github repo.

The trick is that the INO file send values to the bme.php and the bme.php writes the data in bme.txt

On next we need to add the service in weewx

put the bme.py in folder

 /home/weewx/bin/user

open your weewx.conf in folder

 /home/weewx

it is always good to have a backup before editing this file!

go down to line Engine and make the line looking like mine:

[Engine]

[[Services]]

# This section specifies the services that should be run. They are

# grouped by type, and the order of services within each group

# determines the order in which the services will be run.

data_services = user.pond.PondService, user.bme.bme

restart weewx with:

 sudo /etc/init.d/weewx stop
sudo /etc/init.d/weewx start

with the command

 tail -f /var/log/syslog 

you can look in the logfile for errors or success, look for an output bme: found value of...

Give your server some minutes to generate, in "my" weewx.conf every 5 minute come an output.

If you have a error message check your paths.

If you have values, you can go to show it on the webpage:

open skin.conf in

 /home/weewx/skins/Standard

go to:

# This one is probably specific to my station!
add

extraTemp3     = BME1 Temperature<br>extraHumid1    = BME1 Humidity

save the file and open in the same folder

 index.html.tmpl

look for a line:

 #if $day.extraTemp..

...

#end if

after the first #end if you find, put your BME Sensor with:

^^ sorry but is not possible to put this as a text :(

save the file and exit.

there is no need to restart weewx.

Now you need to feed the NODEMCU ESP8266 with the Arduino file.

Do not forget to setup your wifi and addresses in the file.

After loading check the serial output for errors.

After a short period you should see the values on your weewx website.

STEP 4: Success BME280 Sensor Device + Troubleshooting

Some tips for you:

Open more then 1 consoles via putty

on 1 console make your changes, and on the other console read your syslog live with:

tail -f /var/log/syslog

If you have an error, look to your logfile first.

Your output should look similar to mine:

STEP 5: Soilsensor Hardware Setup

For the DS18B20 Sensor we need to make a bus System with some wires and soldering.

Check your DS18B20

DATA, GND, VCC

Between VCC and DATA you need a 4.7K Resistor. It is enough if you have the resistor at the first DS18B20

The other DS18B20 are parallel to each other.

Measure the length for your needs. Solder a chain together, i have secured the pins with shrinking tube.

For a TEST you connect DATA to D3 and VCC to VCC(3.3V) and GND to GND.

For the deep sleep option you need to attach a bridge between RST and D0(GPIO16)

You should not put the chain in the Aluminium tube right now, make your tests before!

STEP 6: DS18B20 Nodemcu ESP8266 Code

For the code you can use my GITHUB repositories:

https://github.com/Landixus/multipleDS18B20WeeWX

Also the ino file needs some inserts from you: The IP Address of your weewx server or URL and the route where you have put the php file, make sure the area is writable i choose the public_html dir because it is a home server.

If you want to clone the git repositories and have git installed on your server you can clone with the command "git clone https://github.com/Landixus/multipleDS18B20WeeWX

Now we need to do some stuff that all is working on our weewx server.

You need to make the paths to your settings in

/home/weewx/public_html

create a folder "data" in the data folder create a ds18b20.txt for example nano ds18b20.txt the txt should be emtpy. make it writable with chmod -R 777 ds18b20.txt (you never do this on a server that is internet accessible!) in the folder /home/weewx/public_html you put the ground.php of my github rep. The trick is that the INO file send values to the ground.php and the ground.php writes the data in ds18b20.txt on next we need to add the service in weewx put the ds18b20.py in folder /home/weewx/bin/user

open your weewx.conf in folder /home/weewx

it is always good to have a backup before editing this file!

go down to line:

[Engine]

[[Services]] # This section specifies the services that should be run. They are

# grouped by type, and the order of services within each group

# determines the order in which the services will be run.

prep_services = weewx.engine.StdTimeSynch, data_services = user.pond.PondService, user.bme.bme, user.ds18b20.ds18b20 add the inline after a comma

"user.ds18b20.ds18b20" should look like the line upper^^

restart weewx with:

sudo /etc/init.d/weewx stop

sudo /etc/init.d/weewx start

with the command tail -f /var/log/syslog you can look in the logfile for errors or success look for an output ds18b20: found value of Give your server some minutes to generate, in my weewx.conf every 5 minute come a out put. If you have a error message check your paths. If you have values you can go to show it on the page: open

skin.conf in /home/weewx/skins/Standard go to:

# This one is probably specific to my station!

add

soilTemp1 = DS18B201

soilTemp2 = DS18B202

soilTemp3 = DS18B203

save the file and open in the same folder index.html.tmpl look for a line:

#if $day.extraTemp.. ...

#end if

after the first #end if you find put your GroundSensor Sensor with:

^^ sorry but is not possible to put this as a text :( save the file and exit. there is no need to restart weewx. Now you need to feed the NODEMCU ESP8266 with the Arduino file.

Do not forget to setup your wifi and addresses in the file. After loading check the serial output for errors.

After a short period you should see the values on your weewx website.

STEP 7: Success Soilsensor and Troubleshooting

If you have all working and see values, then go outside and put the Aluminium pipe in the ground.

A good way is to put hot glue in 1 side of the pipe and then press the tube together, then you have nice top to bring it easier in the ground.

Put first your pipe in the ground, you can hammer soft with a wood board.

If the pipe deep enough you can put your ds18b20 chain in and the powering wires in the waterproof box.

Make sure your wifi is working at this place!

If you dont know what sensor is how deep, there are 2 possibilities.

I test phase put 1 ds18b20 between your finger, the temperature goes higher for this one.

When the pipe is already in ground then normaly is the Highest value the deepest point.

STEP 8: Finish

Just the end

Post your questions and show your ground temps in the comments!

For more help join weewx google Groups on:

https://groups.google.com/forum/#!forum/weewx-user