Raspberry Pi - Heater telemetrics

Telemetrics and management of a building heating system with Raspberry Pi and Arduino

** Documentation is work in progress ** Last update: 2012-11-29


My goal was to help the community manage and view a big building's heating control. Heating is controlled by 3 zoned thermostats, and gas boilers. For reliability and system safety, in this first phase, only the telemetrics (measusing and recording temperatures in quasi real-time, publishing on internet, with history) was implemented.

Another goal was to keep the costs down, because the community budget was very limited

You can see the hardware below. Not too attractive, but very good to be mounted on the wall. Theoretically IP 55, but because the USB cable didn't fit, not quite there.

System Components - Hardware:

  • Raspberry Pi (cca. $50)
    • Case: $10
    • SDHC card: $15
    • Power adapter (Nokia micro-USB: $10)
    • USB extender cable - not priced
  • USB 3G modem (ZTE MF195) (used: $15) with 3G mobile internet (T-Mobile Hungary) (cheapest data package: 50 mbytes - $3/month)
  • Arduino (Boarduino) for 1-wire to Raspberry interfacing (cca. $10-15)
    • Arduino to Raspberry Pi serial interface board with resistors and zener diode, screw connectors, ribbon cable, etc. - cca. $15
  • Many 1-wire DS18B20 temperature sensors ($3 / sensor, 9 sensors = $27)
  • UTP Cables to temperature sensors (cost not added, depends on length)

Total estimated hardware cost: $152

Software components

  • Raspbian Linux (hard float)
  • Custom scripts (Perl, bash) for reporting
  • Custom scripts for checking 3G connection and reconnecting, sending PIN code
    • usb_modeswitch + custom
  • Logmein Hamachi - free VPN service (free for up to 5 nodes), needed because T-Mobile only provides NAT
  • Nimbits.com - free service for 1000 data values/day, logging, graphing

Some notes on the solution

Temperature sensors

Temperature sensors - Raspberry Pi Interfacing

For using 1-Wire sensors, there are several solutions. There are USB-1-wire interfaces (like ... ), I2C - 1Wire chips, and my solution, using a microcontroller (Arduino).

The easiest solution would have been to buy a "cheap" USB-1-wire interface, and use it with OWFS / Linux (One Wire File System). However, my physical topology of 1-wire sensors means that 1 had 3 different buses, arranged in a star shape, the Rasp Pi in the middle. Because the USB-1-wire interface can only drive one bus, it wouldn't work. The other reason is that I already had experience with Arduino programming, I had several Boarduino boards at hand, and Arduino has a good 1-wire library, so it was very fast and easy to write a very simple software for Arduino which just reads all sensors (from all 3 buses) and sends it to the RaspPi with serial.

Theoretically, the Arduino and DS18B20 would have been able to run at 3.3 volt, but I felt more used to running it with 5 volts, and I have plans for the future to drive 5 volt relays easily.

[ TODO - Schematic here ... ]


Raspbian, command line customization

Setting a fix IP address

Command line and config parameters for kernel - TTY, memory split, USB problem

3G USB Modem

I used the ZTE MF195 USB modem for the project, because this was cheap (used) and it had Linux support. It also has a nice green/red led, which was very useful while configuring it. I had no problem with it being locked (to T-Mobile) since T-Mobile has good monthly data rates here.

I had to install and configure usb_modeswitch

Because the modem sometimes didn't want to switch, I had to set up the usb_storage module so that it doesn't use the device. The following must be added to cmdline.txt


My next problem was that the modem had to be setup for the network (T-Mobile) with a PIN code. I found the comgt package helps with this. You can set the PIN code into an environment variable, so you don't have to type it after every reboot (very useful).

export COMGTPIN=1234
comgt PIN -d /dev/ttyACM0
comgt -d /dev/ttyACM0

I forgot to enable the 3G data package at T-Mobile, and it didn't work at first.

Because of disconnects, I created a check script, which I am running every 2 minutes. This check for PPP connection, then reconnects.

ZTE Mf195 + Ubuntu 11.10 (Hungarian)

Serial interface to Arduino

Level conversion, 3.3volt (Raspberry Pi) vs 5volt (Arduino)

See also:

Raspberry Pi Serial Port

Logmein Hamachi

Temperature sensing custom scripts