Showing posts with label weather. Show all posts
Showing posts with label weather. Show all posts

Friday, 5 May 2017

Weather page

I've had a weather station at our summer house for some time now, but I never got around to publishing the the data. Now I had some time and made a Spring Boot application to show the data.

Station consists of 1-Wire sensors from Hobby-Boards. Temperature, barometer, wind speed and direction and rain sensors. I'll probably add a relative humidity sensor sometime so I can calculate the heat index also, currently only wind chill is calculated.

Since the weather station is located at our summer house with a somewhat flaky internet connection I can't just directly save data to my home servers database. I first save it locally and then replicate it home by reading MySQL's binary log. https://github.com/mika-koivusaari/replicate_mysql_postgresql Machines are connected with an SSH tunnel, I use autossh to make sure the tunnel is always open.

Weather page is https://weather.khyron.dy.fi/weather (in finnish), and code in https://github.com/mika-koivusaari/weather.

Thursday, 8 September 2016

You have mail 2

After having done the hardware for checking mail I had to make some kind of user interface to show that data. I had previously used an old IPhone to display temperature and power usage, so it was an easy choice to continue using it.

Previously I had just used a simple php script to fetch and display data, now I wanted to try python and Flask. I used a tutorial found here to get started.

Code is pretty simple, temperature and electricity usage is fetched every time from database, but this page is usually only open on the extra phone that displays this data so there shouldn't be any reason to cache that data. That data is also updated to database every minute so it should be refreshed every time. Mail status is received over mqtt and it's sent only when it changes so it has to be cached.


I also made a couple of changes to the hardware/firmware section, for the firmware I set the retain flag in the mqtt message so that when clients connect they get the last know value of mail. For the hardware I added a bigger antenna because I have some trouble with the wifi reception. Reception is still not as good as I would like, I have to think about it. Maybe second wifi ap, I'm also thinking if I should build a separate network for IoT-devices, currently there is only one wifi device, but that could easily change. I also changed the psu to one that outputs more current and has a lower quiescent current as I thought that the wifi problem might be because the ESP8266 is not getting enough current to transmit, but that didn't solve the problem. Before I had a cheap chinese buck/boost converter, and now I have https://www.pololu.com/product/2830 which can ouput more current, but is only a buck converter and needs at least 4 volts to output 3.3 volts. So I had to replace the three aaa batteries with four aa batteries to get enough voltage.

Also there is a problem with the mailbox itself:) It let's sunlight through somewhere and that's enough so we can't see if the led is on or not. I'll have to think how to put some seals there.

Future improvements

Hardware
  • Monitor battery state.
  • Don't turn radio on on wake up, only when we need to send. NodeMCU bug might prevent this currently.
Software
  • Move temperature and electricity to mqtt also.
  • Add today's forecast.

Wednesday, 6 July 2016

Comparing solar radiation shields

I have three temperature sensors with calibration data that I want to test with different solar radiation shields.


From the left, normal shield made from plastic plates, tube made from twinwall sheet used in advertisement plates, same kind of tube but with fan.

Sensors (DS18B20) are read with OWFS and a small python script that starts the conversion for all sensors, reads them and then sends them to a Google Sheet using gspread. For some reason simultaneous conversion doesn't work for me, I get cached values. So I changed the script to just read sensors one after the other. Reading is done every minute. Also writing to Google Sheets is really slow, especially when done cell by cell. So I moved writing to Sheets to a different script that is run once a day.

Currently data is flowing in nicely, but I forgot to check which sensor is in which shield, so I have to check that the next time I travel to where those sensors are.

Writing to Google sheets is really easy with gspread, I can definitely recommend it if you need to work with Google sheets.

Raw data can be found in this Google sheet.

Python script in https://github.com/mika-koivusaari/read_ds18b20_gspread

Thursday, 16 June 2016

Calibrating DS18B20 sensors to show the same

I have a weather station in our summer house. It currently has a radiation shield made from plastic plates for the thermometer. It's "common knowledge" that if you have more air flow through you sensors it reflects more accurately ambient temperature. So forced airflow with a fan would more likely be better.

I want to test how much better. For this I need thermometers that show exactly the same value in the same temperature. So I'm going to put three sensors in salt water that's heated to about 40 degrees Celsius and then let it cool down to about -20°. Reading sensor values every minute should give a reasonable calibration table.

Motor in the top is for circulating water so I get more accurate results. It's a bit ugly setup but I only plan on using this for one time so I didn't bother with anything fancy.



Or at least that was the plan. 40° -> 20° went well but after I put the whole thing in the freezer all the DS18B20 sensors stopped working. I'm guessing some moisture related problem. I took the setup out of the freezer and let it heat from about -3° that it had cooled to room temperature. I'm probably not going to leave the test running for the winter so that range should be enough.

I used screen to read the values from serial "screen -L /dev/ttyUSB1". As cat seems to stop when arduino takes it's time to boot.

Data is in a Google spreadsheet DS18B20 calibration data.

There are three sensors A, B and C. Here are their maximum differences, and average differences.
A-B A-C B-C
Max difference 0.4375 0.3125 0.2500
Avg difference 0.0537 0.0353 0.0433

I'm thinking that the differences are not that big and I shouldn't worry about them. And some of it is most likely because I put a different amount of hotglue to the sensors to shield them.

Code used can be found in github https://github.com/mika-koivusaari/read_all_ds18b20


Thursday, 26 May 2016

Outside temperature and electricity usage

Our living room/kitchen is on the south side of our house, wireless outside thermometers can't reach it from the north side. But I have a server recording outside temperatures, and maybe a whole weather station in the future. So I only had to display the temperature I already had. We also had an old IPhone and a radio with IPhone dock. So I only had to write a small script that displays the current temperature in a web page and automatically updates. Then use the IPhone to display the page.


It also displays the electricity consumption in the last minute.

Maybe in the future I'll build a better app with more information, todays forecast or something. Data could be sent with mqtt maybe.