alxlabs welcomes you

Page
Menu
News

Project "My Weather"

Important - by doing this project you take all responsibility for all the problems that it may cause.

This project is for building a weather station which conducts measurements of current temperature, pressure and humidity and posts those results onto a webpage which is of course will be made by us. On top of that, we will create a simple application on the Android phone and post it to the market.

Here is how it looks like on your PC or phone: http://www.alxlabs.ca/weather/

So..lets start Cool

First of all, let me show you a block diagram of what we are going to assemble - click here. You can see that we will have to develop 3 blocks. The first block "Sensor" is the physical measurement unit and it has to be placed outside of an apartment or house, preferably in the constant shadow to avoid direct sun exposure as this will greatly affect the results. The second block, "Receiver" which collects weather data and places it on the web shall be placed inside the house. Third block "Backend" - this is a web-based application which consists of the server to store the data and provide it over the Web or via the application for an Android smartphone is placed .. somewhere, we don't even need to know where is that.

All of the hardware parts can be purchased from DigiKey, except copper wire - this item has to be purchased somewhere else as it is extremely expensive on DigiKey. I will provide link to all components used, let's start from what we will need:

General:

You will need a good soldering iron (something like SBK939D), solder and soldering paste. Also you will need a set of small screwdrivers, wire cutters, tweezers and general mounting wires like this. I suggest to pick several wires of different colors while this is not mandatory.

Equipment:

At least as good multimeter and ideally but not mandatory an oscilloscope. Also you will need a PicKit 3 or 4 programmer to program PIC MCU. Those can be found here

Hardware (home side)

1x UMFT234XF (RS232) module, click here

1x RF RC1140-RC232 module, click here

1x Prototyping PCB, click here 

1x USB cable, click here

1x Copper wire for antennas, you will need "Magnet Wire or Enameled Copper Wire"  about 22 AVG in diameter. I do not suggest to buy this item from the DigiKey as it is very expensive at the moment, so some other place will work as well. As an example you may look at this on Amazon (if it is still available) click here

1x PC running Windows 7 or 8 or 10 connected to the internet. There is no requirement if it has to be 32 bit or 64, AMD or Intel or any performance - our application won't consume too much of the resources. Internet connection as well shall maintain any speed, everything will be fine as soon as connection is stable.

Hardware (remote side)

1x Prototyping PCB, click here 

1x RF RC1140-RC232 module, click here

1x PIC16F687, DIP package, click here

1x Socket for MCU, click here

1x Sensor BME280 mounted on the PCB, click here

2x Capacitor 0.1uF, while I suggest to buy 100 of them as they are cheap, click here

1x Diode, while I also suggest to buy 100 of them as they are cheap, click here

1x MOSFET, N-channel, click here

1x OKL-T/1-W12 DC-DC regulator, click here

1x Resistor, 3.6KOhm, while I suggest to buy 10 of those as they are cheap, click here

1x Header (male), click here

1x Header (female), click here

1x Battery container and 8x AA batteries. For battery container click here

Software:

Two items need to be paid, others are free. Don't worry too much about the cost of these items - those will be good for multiple projects, not just this one.

1. You will need a cheapest hosting solution along with domain name. I recommend to buy one and domain from any of the hosting providers, for example  https://www.hostgator.com

Pick the cheapest plan there (i.e. "Hatchling Plan"), go thru domain registration - pick cheapest domain possible, then decline all the extra options (again, just a suggestion) unless you want to hide yourself or get extra protection. Fill out the rest of the forms and voila - you have a website. Note, that it will take day or two to propagate your domain name thru the rest of the world so stay calm till the process is finished. Entire process shall cost you around ~$100 or higher depending on the options you took.

2. Account on the Google Play Console (https://play.google.com/apps/publish) - it costs you 20$, paid once and supposedly once per lifetime. However, you will need it only if you want to make your application available in the Google Playstore. If you don't and you are fine with just application developed for your phone but not making it public then you don't need this option. This item is straight forward so I will not spend too much time here describing this process.

3. MPLAB from Microchip (free version), the current version is 5.20. I won't give a link here as they constantly change the location (no idea why Smile) on their server, just go to https://www.microchip.com and search for current version. You will also need to install a compiler, currently it is "MPLAB XC8 C Compiler" and make sure that you install free version.

Next part - Temperature sensor

Part 2, temperarture sesnor.

Let's start building the temperature sensor, overall schematics is published here

To start you can assemble the whole thing at once, however I suggest to start assembling it then debugging part by part.

Lets first solder socket for MCU and make cable to connect it to PicKIT3 (or whatever you use to program PIC MCU). Solder 20-pin DIP socket to a corner of your PCB so you shall not consume center of it as we will need to add other components, but leave at least as several rows of holes on the side to solder wires or other components. Then you will need to add a 3v3 regulator and capacitors. Do not put PIC into the socket as of now as we will need to make sure that power provided by 3.3V regulator is in good shape otherwise we can fry out our MCU. To power a board I use 12V from 8xAA batteries, those connects to a switching regulator with a high efficiency so our batteries will last as long as possible. But before that resistor of 3.6K (not shown on the schematics) shall be connected between pads Rtrim and GND (see the datasheet) straight on the regulator PCB and then it shall be connected as shown on the schematics page, use GND as pin 3, Vout as pin 2 and Vin as pin 1. Connect the batteries (remember, do not insert PIC into the socket at this moment!) and measure input and output voltages - as for input you should measure around 12V and for output, it shall be 3.3V. If this is not the case, then you will need to find mistakes. 

Let's plug PIC MCU into the socket, but before that use a multimeter and ensure that 3.3V power is applied to proper pins as shown in the datasheet. Now let's assemble connection cable to connect to PicKIT3 that would require 4 wires, one for GND, two for data and one for MCLR. Connect pin 1 of the PicKIT3 to MCLR/Vpp pad, pin 3 to GND, pin 4 to ICSPDAT and pin 5 to ICSPCLK pads of the board. Note, that we will need to program our MCU only once (i.e. rarely) so please use pin connector/wires to assemble a connection which you can disassemble easily. Run PicKIT3 software kit and ensure that it connects to your setup and you see PIC16F687 in the PC tool. Of course, 3.3V power must be applied to our PCB.  Done? Let's assemble the rest of the schematics and write down our program to MCU. You can download mine program from here along with compiled binaries however I still suggest that you use MPLAB IDE and try to experiment a bit with compiling various changes to learn something about C coding. After you will be done with compiling - just use PicKIT3 software kit to download the binary into the board and then let's hope that everything works otherwise you will need to do some hardware debugging. You will also have to make an antenna and connect it to pin 9 of the UART RF module. As specified in the datasheet - antenna shall be made out of copper wire, length shall be 16.4cm. You can wind it in a coil(s) so it will consume way less space if done that way. If everything is assembled and programmed correctly then approx. every 10 minutes MCU shall wake up, apply power to the UART controller and weather sensor and finally transmit your weather information to the air.

Part 3, receiver.

So far so good - we have completed our TX part of the sensor and now want to see if anything is being sent to the air. To do that we will have to assemble a receiver, schematics for which can be found right here. As you can see RX module is very simple and there is no debugging needed unless you mess up a couple of wires. Just for the case - we will use RF modem module along with USB<>UART one, see below:

1x UMFT234XF (RS232) module, click here

1x RF RC1140-RC232 module, click here

We also will need to make an antenna exactly as we did on a previous page then connect it to RC1140 module pin 9, that's it for the hardware.

Software... it won't be that easy :)

First of all, we will need a compiler. In theory, any compiler will be good while I suggest using Microsoft Visual Studio, the latest version is available from their website, just google for MS Visual Studio then download and install free version of it, currently MS distributes this one via https://visualstudio.microsoft.com/ 

Second, we will need a driver for FTDI part FT234XF which is used for the UMFT234XF module and it can be obtained from https://www.ftdichip.com/Drivers/VCP.htm at the moment so have then downloaded and installed before you do any of the next steps.

Next step will be to assemble RX module and connect it to your PC - if everything is done successfully you will see a COM port appeared in the Windows Device Manager - if you use Windows 10 then simply click to search filed then enter Windows Device Manager and follow what it will found.  

I wrote two C programs for this project (use MS Visual Studio) - the first one to debug the whole system and the second one as plain windows system tray tool. Let's start from the plain console application, sources can be found here. This application uses curl.exe to upload current weather data and it can be downloaded from here https://curl.haxx.se/. Later on, we will prepare a full-blown Windows application where we will implement everything required but meanwhile let's make sure that we can communicate to the sensor and then upload everything onto the web. 

If everything works correctly you shall see a text line with humidity, pressure, and temperature received every 10-11 minutes.  

From this moment we can start doing the main application, sources can be found here. I'm more hardware guy than a software, so I had to use a good example from CodeProject, which can be viewed from this link. I also recommend for you to play a little bit with the source code given just to understand a bit how things are done especially in a multithread application - in our case process of obtaining data from the sensor is placed in a separate thread than the rest of the application. This is done to avoid blockage of the system response to the Windows during obtaining data from the sensor, processing this data and uploading it to the web.

 The rest of the system does not require anything special, so I will simply present it here. Let's do the webserver part now, for this we will need a hosting, FTP or SFTP access to it and of course Apache webserver which should be preinstalled on your hosting. Here you can find all the files needed, as you can see everything is very straight forward. Just a little note that to discriminate between cell phone and computer I used MobileDetect PHP source http://mobiledetect.net - the idea here is to direct requests to the cellphone page and the PC page, main purpose is to have formatting slightly different between those. The code for web part along with all of the pictures can be found here 

Android application is also very simple and very basic, while if you want to publish it on the market then it may become tricky discussing that with Google for which I wish you good luck, it actually might be good exercise - try it. Note that it will be good if you can just repeat everything but publishing your application on the market.  I did, see Alex Wx application :) .. and of course sources are presented here however you may want to try couple of tutorials as shown on https://developer.android.com/training/basics/firstapp 

 

« prev top next »
Page
Menu
News
Page
Menu
News

Powered by CMSimple | Template: ge-webdesign.de | Login