Use AM2315 for temperatures below 0°C

am2315-temp-humidity-sensorIn an IoT node I use an AM2315 sensor to measure temperature and humidity. This sensor can be connected via   I2C bus to a NodeMCU module. The results of these periodic measurements are presented here.

On my location these days we had negative temperature on the Celsius scale for the first time in this autumn.

What happened? I had to see wrong temperatures in my graphs.

I looked for the root cause and found that in the used library AM2315.lua the range below 0°C was not handled. The MSB of the temperature value is set in the case of negative temperatures. Therefore I masked this bit and if set the value is multiplied by -1. If you use customized firmware the bit module must be included.

Here are the modified lines for AM2315.lua:

h = string.byte(b[3]) * 256 + string.byte(b[4]) --humidity
h = h / 10
-- MSB is set for negative temperature
t = bit.band(string.byte(b[5]), 127) * 256 + string.byte(b[6]) --temperature
t = t / 10
if bit.isset(string.byte(b[5]), 7) then t = -1 * t end

You will find these modifications on https://github.com/tectiv3/am2315-lua, now.

Finally, here is a temperature graph from today. Winter is coming now 😉

negtemp

Advertisements
Use AM2315 for temperatures below 0°C

AM2315@NodeMCU

AM2315The AM2315 is a temperature & humidity sensor with an I2C-interface in a nice enclosed style. The sensor contains a DS18B20 temperature sensor and a capacitive humidity sensor. A microcontroller inside builds the sensor interface and works as an I2C-slave.

For outside measurements it is also advantageous that the AM2315 comes in a rugged case with mounting bracket. While it is not rated as ‘weatherproof’, it is more suitable than SHT PCB-breakout sensors for measuring outside.

After crimping a Grove-connector we can connect this sensor to a Grove Arduino sheld hooked on a Wemos D1 board, for example. Or you connect the wires to a Wemos D1 mini.

AM2315-Grove

At Github you will find an AM2315 Lua module and it is easy to integrate the AM2315 into your own application. I have included the AM2315 sensor into my DHT11 network and it sends now outside data to the MQTT. Its ID is ESP8266-13972685.

The data coming from the AM2315 sensor are marked red in the screenshot while the data of another outside sensor ASH2200 are marked orange. The two sensors are outside but at different locations.

Screenshot_2016-04-06-16-14-55.png

The software am2315.lua and am2316_mqtt.lua is on Sourceforge and Github.

AM2315@NodeMCU