New Sensors

Previously, I described the wiring for attaching my new Rinnai heater to my raspberry pi.  I also changed the graph to display these new data trends (and stop displaying the old one).  There are 2 stages to the heater and I am graphing them separately.  Previously, I did successfully add a second sensor to the raspberry pi and programmed the pi to graph the second temperature.

The graph below (click to enlarge) shows the two temperatures (blue and purple) near the top following each other.  That is because the sensors were next to each other.  It also shows that on this day, Stage 1 (red) of the Rinnai was cycling, but Stage 2 (green) never kicked on.  The other interesting thing is that around 12:00 the ROOM TEMP control was raised.  A keen eye can see that the room temp. did not quite come down as far as it had been, and then Stage 1 came on and stayed on for a longer time, raising the room temp.  This was the point the setting was raised.

show_graph_2014-10-10.cgi

Displaying 2 heating stages and 2 temp. sensors

This past weekend, I finally put the second temperature sensor outside!  This is something I never accomplished at my previous apartment.  The graph below (click to enlarge) shows two things.  Firstly, at around 11:00 the ROOM TEMP control was lowered.  This caused the heater not to run the rest of the day.  Secondly, at around 18:45 I turned off the raspberry pi and put the sensor outside.  By the time I got everything wired back up and turned the pi back on, it was just before 20:00.  This is when the plot for the outside temp (purple) takes a steep dive.

ROOM TEMP lowered during day, OUT temp. sensor moved outside

ROOM TEMP lowered during day, OUT temp. sensor moved outside

Of interest is what happened the next morning.  In the graph below (click to enlarge), at just after 08:00 there is a sharp spike in the outside temp plot (purple).  This settles back down a bit, but then spikes again.  This then finally settles back down and regains a more steady slope upward as the air warmed up.

show_graph_2014-10-12.cgi

Sun hits outside sensor

With this proof-of-concept and some motivation, on Monday I took on the task of putting a sensor in my bedroom.  Both of the additional sensors are attached to the raspberry pi downstairs via a run of old Cat5 Ethernet cable I had lying around.  Since the 1-wire protocol the temperature sensors use is a bus, I simply wired a few of the conductors of the Cat5 in parallel into the screw terminals for the temperature sensor.  I decided to double-up each conductor (I used the twisted pairs in the wire) in order to reduce voltage drop over the length of the cable.

Photo Oct 11, 19 02 04

As can be seen in the photo above, I wired it as follows:

Gnd 1-Wire +5V
Cat5 Br-Br/W Bl-Bl/W Or-Or/W
Temp. Sensor Black Yellow Red

Three-way splice for room temp.

Three-way splice for room temp.

 

For the sensor in my bedroom, I cut the Cat5 cable and striped the wires on either side of the cut.  I then soldered both of these wires and the temperature sensor wires together, essentially making a 3-way splice in the wire (pi/bedroom/outside).  This was all covered with heat-shrink tubing.  I did this with the pi powered down to reduce the risk of damage to the pi.

With the soldering complete, I powered it back up and first made sure that the old sensors still worked with the new wiring.  This was simple because the graph started running immediately and I just had to wait a few minutes then check the graph.

 

 

To test the 3rd sensor that I just added, I went through a couple steps.

  1. Check if raspberry pi sees three sensors
  2. Identify which sensor is the new one
  3. Ask raspberry pi for a reading from the sensor
  4. Artificially change sensor temp and ask raspberry pi again, to confirm correct sensor

Step 1: To find out if the pi sees the sensor, I ran this command to see what devices were listed on the 1-wire bus:

house@raspberrypi ~ $ ls /sys/bus/w1/devices

this returned 3 items that I was interested in:
28-000004d009bd
28-00000512f401
28-00000513e9a3

Step 2: These are the addresses used by the 1-wire bus for the temperature sensors.  Since I already had 2 of these working, I checked my notes to see which were accounted for and which was the new one (28-00000512f401).

Step 3: Then I could run the following command to ask the pi to take a reading and then display the result to the command line:

house@raspberrypi ~ $ cat /sys/bus/w1/devices/28-00000512f401/w1_slave 2>&1

this returns the following block of data:
5f 01 4b 46 7f ff 01 10 9b : crc=9b YES
5f 01 4b 46 7f ff 01 10 9b t=21937

This is the format in which the temperature info. comes out of the temp. sensors.  The info afer the “t=” is a temperatre in milliCelsius (thousandths of a degree celsius).  In this example, the reading is 21.937 C.  My pi runs this command then strips out that value and saves it into the database once per minute for every sensor.

Step 4: The easiest way to accomplish this is to continually ask for a new reading, and then grab onto the sensor and warm it in your hand.  The reported temperature should rise.  So I wrote a quick loop function to run the above command over and over, with a 1 second delay between each:

house@raspberrypi ~ $ while true; do cat /sys/bus/w1/devices/28-00000512f401/w1_slave 2>&1; sleep 1; done

this returns a bunch of readings in a row, such as:
79 01 4b 46 7f ff 07 10 0a t=23562
78 01 4b 46 7f ff 08 10 51 : crc=51 YES
78 01 4b 46 7f ff 08 10 51 t=23500
78 01 4b 46 7f ff 08 10 51 : crc=51 YES
78 01 4b 46 7f ff 08 10 51 t=23500
79 01 4b 46 7f ff 07 10 0a : crc=0a YES
79 01 4b 46 7f ff 07 10 0a t=23562
79 01 4b 46 7f ff 07 10 0a : crc=0a YES
79 01 4b 46 7f ff 07 10 0a t=23562

The result proved that I had the correct sensor and it seemed to work well, so I made a new script to take readings from this sensor and save the data to the database.  I then modified my graph to display the new sensor as well.

The graph below (click to enlarge) shows a couple interesting things.  The first and most obvious thing is at just after 08:00, when the sun came around a tree and shone directly onto the outside sensor.  This is obviously a problem and I will need to move the outside sensor.  Then, at 19:30 I powered down the pi to work on wiring the bedroom sensor.  You can see the green Stage 2 plot break, showing that there was no data there.  Then, at 20:20 the new sensor script starts running.  There is a third temperature plot (light blue) near the top just under the legend.

show_graph_2014-10-13.cgi

Added bedroom plot, outside sensor in sun

  1. Adding More Temp Sensors « Laboratory B - pingback on 2014-10-20 at 14:23
  2. Problem with my 1-Wire | Gouhobandgraw - pingback on 2014-10-22 at 08:38

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Trackbacks and Pingbacks: