It is a very easy way to measure the temperature outside of my apartment. The protoboard is placed in a tupperware style box to protect against the rain and placed in the shadow part of my balcony.
In my Vera3 environment this looks like
Most of the projects I use a Arduino Pro Mini, but for this one a Arduino Nano was used.
Note: I forgot to draw in the resistor for the ds18b20
All the code can be found on my github: https://github.com/timdows/AMD/tree/master/OutsideTemperature
OutsideTemperature.ino sets up the MySensor, DHTClass and Dallas objects.
At the setup all these objects’ Init methods are called and the gateways is forced to take the gateway as its parent in the begin method.
The getBatteryVoltage function is able to get an impression of the current battery status, as it is accurate to around 10%. This value is than divided by 50 (batteryVoltage * 100 / 5000) where I still have to measure maximum voltage when the battery pack is fully charged. The result is than send to the gateway via sendBatteryLevel.
In order to save the battery, gw.sleep is called with an interval of 5 minutes. This puts the radio and Arduino (in PowerDownMode) in sleep and wakes up on the timer interrupt.
The Dallas class reads the onewire pin with one or more sensors connected to it. This is done by the DallasTemperature and OneWire objects.
In order to create the objects oneWire and sensors without calling the constructor, I have created an empty constructor for those classes as it did not exist.
The DHTClass class reads the current values of its DHT11 sensor, this value is then send back via the mySensorGatweway.
- As the DHT11 also measures humidity, it should not be in a closed box outside (that is my current situation to protect against rain), figure out a way to get some better readings of the DHT11
|Arduino Nano||$ 2.68|
|Other materials||$ 2|
- It took me a while to figure out how to measure the battery status. I have tried to use resistors in series and read it via an analog pin, but it always turned out to be the value 1023 (maximum value of analog pin). Only when I found that you could measure the bandgap I found http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage and implemented that example