Growing pains

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

arduino130114Obviously 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).

More sensors

I put in an order to Little Bird Electronics at Christmas to take advantage of a 10% discount coupon, so I added a few bits and pieces that might come in handy. First off was a DHT22 temperature and humidity sensor, which is readily available with lots of examples around. First I tested it with some sample code, and then modified my existing ‘weather’ station code. So now I have two different measures of light levels, two temperature readings and humidity. There is a slight difference of about half a degree between the two temperature sensors, so I wonder which one is more accurate? The Xively feed immediately picked up the two new data streams, and as a bonus my iPhone app also recognised them.

I also bought an MPL3115A2 barometer/altitude sensor which looks interesting, but it is my first experience of the I2C bus and it appears that to run long distances to an outside sensor it needs a bus driver of some sort, so this one is going to take more effort. The code looks rather  daunting too.