So this project had been sitting on my desk for ages now with the sensors and RF module spread across two breadboards with a mess of wire connecting it all up. Today I finally found some time to add the RF module to a prototyping shield. The other sensors are still on a breadboard and that’s the extra wires hanging off it, but it’s one step closer to a finished project. Some of the soldering was a bit fiddly but worked straight off.
Last week just as we were getting used to sunshine again the weather reminded us it’s still winter. Sitting in a meeting Thursday afternoon hearing the wind and rain crashing around the building I pulled up the weather feed and you can see when it really hit.
This shot is from about 4:25pm. Temperature dropped about 10 °C in an hour. You can see the humidity shot up too with the rain.
This morning we woke up to a coating of frost on everything, and the weather station told me that despite the bright sunny morning it was -0.4 °C outside. Guess there’s still more days to go skiing this season!
The new Xively feed is here:
Data being logged is:
- indoor temperature
- indoor humidity
- outdoor temperature
- outdoor humidity
- air pressure
- total rainfall (since the weather station was set up)
- light levels (on my study desk, but will be outdoor soon)
- wind speed, gust speed and direction
The iPhone app simply creates a list of the elements in the datastream, so it is consistent. I also figured out how to display the units in the app.
After merging the XC0348 code I had which was receiving the data transmitted by the outdoor sensors with the Xively code there was a bit of tweaking to do to get the sketch to play nicely. The last step was to add the code back for the pressure sensor. This was problematic as the sensor uses I2C and soon as I added the Wire library the whole thing stopped running properly. After some reading I wondered if I was just running out of memory so I commented out a whole lot of serial print statements and it this got things working again. Of course, without the print statements there was a whole lot less debugging going on.
A couple of things that still need attention:
- the pressure sensor has been timing out often, so I get false values where a negative error code is returned. I’ve increased the timing loop and am seeing if this works better
- we had a heap of rain overnight and my rainfall figure suddenly dropped because I was only using the LSB, and the count had overflowed. A bit of trial and error and now it is showing the true total. A problem with rainfall is that the sensor reports total rainfall, so this will just keep going up and up. I need some way to keep daily totals. Perhaps I need to add a real time clock?
my light values are related to the resistance in the photoresistors, so the curves are inverted i.e. when it is light the value is lowestFIXED Apr 10 – I chose an arbitrary dark value of 1000 and am using that as a reference point to subtract from, so now a bigger value does mean more light rather than more dark!
- wind direction is returned as an integer between 0 and 31, which seem to correspond to 16 compass points. I think there might be some sort of moving average calculation used by the base station to reduce errors due to rapidly fluctuating wind shifts.
This is very cool …
I’m thinking I might have to back this one, which has already reached its target after less than 24 hours. It’s Aussie-designed although being made in the USA. Read more on Kickstarter. Now what could I use it for …
Home early from work and a beautiful afternoon, so I thought, it’s time to install the weather station sensor array on the roof. There is a pipe from a flue or something up there that is doing nothing and ideal. Didn’t take too long, used the compass on the phone and checked the satellite image on Google Maps to get a good idea of where North is. Even whilst I was up there I could see that it was picking up much more wind rather than when it had been down low and sheltered.
There’s a whole heap of updates still to write, but this is now sending data to my Arduino which is getting pushed to the internet along with some data from sensors inside the house.
These articles together form the source that I drew inspiration from. I didn’t have to do my own signal timing analysis which sounds fascinating but complicated. The above code examples however are written either for Raspberry Pi, or for Arduino using different models of Fine Offset sensors and transmitters.
The next step was to figure out how to receive the sensor data being transmitted to the display base station. There’s plenty of articles on the web describing parts of the puzzle, but I didn’t find any one article that explained it all. For testing I used a Freetronics LeoStick and a 433MHz RF receiver module set up on a breadboard, so I could leave the original sketch still running on my desktop feeding data to the web. The LeoStick was particularly easy to use as I could just plug it into a USB port and test code from anywhere in the house without being tethered to power.
My birthday was coming up and an online retailer had a tempting online discount so I ordered one of these:
It’s a common ‘generic’ model made by Fine Offset, WH-1081, sold here by many retailers as an XC0348. Of course I had to wait until my birthday to actually ‘receive’ it and then it was back to work and no time to play. Finally it did get put together, and it has sat out the back on a small table to test it. Firstly I haven’t had an opportunity to get on the roof, and secondly, if I want to do some decoding of the data it is much easier if you can observe it close up, and test the sensors individually. Although some data is probably inaccurate, such as wind, the readings generally agree with the weather bureau. Here’s its current position:
I ran some testing code on the MPL3115A2 breakout board and that worked fine first time, giving me altitude and temperature readings immediately. I then tried to incorporate that code into my existing sensor reading sketch, using the barometer mode. At this point things suddenly stopped working nicely. The serial monitor debugging showed it just stopped when trying to initialise ethernet. I began cutting out bits of code, so that it wasn’t reading other sensors. It then seemed to start sending data and then restart, but the loop would not run.
Next night I sat down and started over with the existing sketch, but with it only sending the barometer reading, and it worked. I was able to add the other sensors back in, one at a time, and it still worked. I did cut out some unnecessary debug statements here and there to try to cut the code size down. Finally, I have everything working, but can’t explain why it didn’t work before and why it does now. I was thinking that perhaps the EtherTen wasn’t up to the task, and I might need to go up to a Mega board.
The datastreams being collected are:
- DS18B20 temperature sensor
- DHT22 temperature and humidity sensor
- MPL3115A2 barometer and temperature sensor
- two LDRs giving me ambient light levels
Obviously there is a bit of redundant data here, so it is just a useful way of testing the different device interfaces. What is somewhat hard to explain is why I have 3 different temperature readings given these devices are supposed to be calibrated to a high degree of accuracy. For example at the moment readings are 24.37 °C (DS18B20), 23.80 °C (DHT22) and 22.75 °C (MPL3115A2).