Page 1 of 1

Re: How to connect a temp sensor, save data and send collected data

Posted: Mon May 07, 2012 6:18 am
by frazelle09
upon request.

Hi guys!  Greetings from sunny Mexico!

We are finishing up a solar hot water heater  and are looking for an inexpensive (of course!) way to connect a couple of temp sensors to our RasPi, save the data to a log and then be able to "drive by" (or at least stay outside of the building) and download the data after a couple of weeks or a month.

Our RasPi looks to be the hardware we will need, plus the SD Card and a WiFi adapter.  Can we easily connect our two temp sensors to this thing as well?

i dislike asking two questions in one post, but will we be able to communicate with this thing, perhaps with our Android HTC Dream, for the download?

We were looking at the Arduino, but it seems to need several shields, which really increases the end price of the item.

Have a great evening! 

Re: How to connect a temp sensor, save data and send collected data

Posted: Mon May 07, 2012 7:48 am
by nick.mccloud
frazelle09 said:


Can we easily connect our two temp sensors to this thing as well?


If you have some good electronics skills you could connect some temp sensors via SPI. If less skilled there are some IO boards coming out that may well allow analog input - rather like a shield.


i dislike asking two questions in one post, but will we be able to communicate with this thing, perhaps with our Android HTC Dream, for the download?


Setup the Pi as a web server and then you can link to the local WiFi and look at the web page.

Re: How to connect a temp sensor, save data and send collected data

Posted: Mon May 07, 2012 3:03 pm
by frazelle09
Thank, nmcc!

Will have to look into the SPI, don't know what it is, but we can always learn, right?!

Have a great evening over there in beautiful Derbyshire! 

Re: How to connect a temp sensor, save data and send collected data

Posted: Mon May 07, 2012 5:57 pm
by Gert van Loo
frazelle09 said:


Thank, nmcc!

Will have to look into the SPI, don't know what it is, but we can always learn, right?!

Have a great evening over there in beautiful Derbyshire! 



The Gertboard has two SPI devices. One is an Analogue to Digital converter. That is 90% what a thermal sensor it. Also there is example software. For more sophisticated use I would recommend asking about SPI device drivers which seem to exist now but I have not seen how you call them.

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 4:12 pm
by foobar77
I thought I would post in here because I wish to do something similar and would like a second opinion on whether my idea is sound.

I need to collect temperatures from various locations on a site and log them to a database at a central location at the same site. I also want to hook up to an existing intruder alarm panel at the central location so I can set a zone open circuit to raise an alarm if any of the monitored locations fail to send a temperature reading after a set period of time.

Initially I started with arduino but no chance of getting something like SQLite into that small a memory footprint so abandoned the project until I could get my hands on a R-Pi. Well that day has arrived now so heres what I had planned....

Each location to be monitored would have a dallas DS18B20 sensor connected to an arduino and would shout out the temperatures every minute or so over one of cisecos XRF modules (range shouldn't be a problem as all of the buildings are fairly close together) connected to the arduino. Manufactured arduino boards cost a little too much but the atmega chip, crystal and caps requried to make your own are dirt cheap thankfully

At the R-PI side I have my mysql database ready so my plan was to have another arduino with an XRF module receiving the incoming temperature broadcasts, using perl (probably) on the Pi to read from the serial port and also to write back to it to tell the arduino when to open the circuit wired to the alarm zone.

Does this sound sensible or should I ditch the arduino on the pi side and use the GPIO. Bear in mind I know very little about electronics and whilst I can code perl in my sleep, C (which is how I assume one would interface with GPIO) is not one of my stronger points.

Any feedback greatly appreciated.

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 5:04 pm
by jbeale
I gather from http://www.ciseco.co.uk/content/?p=1738 that the XRF module communicates using a standard serial link at 3.3V logic level and selectable baud rates, including 9600 – 115200. That should be directly compatible with the R-Pi serial port so you would not need the Arduino on the Pi side. You do need to make sure to disable the Pi serial console at boot because by default (at least on some distributions) the Pi sends out startup messages, etc. via its serial port.

You can talk through the serial port in many different languages, or shell scripts etc. The R-Pi serial port pins are shown on this page below. You need to connect RxD, TxD, GND and  3V3 if you are powering the XRF from the Pi directly. That is certainly possible as it only uses 32 mA at full power, and the Pi can provide up to 300 mA through that pin.

http://elinux.org/Rpi_Low-leve......28GPIO.29

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 7:00 pm
by foobar77
Hi jbeale, thank you for your reply.

Yes the XRF does operate at 3.3v and conveniently, ciseco sell a break out board for the pi that not only accepts the XRF but also brings the rest of the GPIO pins up for easier access (here) but im not sure how I would link to the alarm zones on the intruder panel using the pi, ive not researched into that at all but im guessing thats going to be easier for me to do with Arduino.

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 7:36 pm
by jbeale
If you have a logic-level output from your alarm panel, that can connect directly to a R-Pi GPIO configured as an input. You will need a resistive voltage divider to reduce the voltage to 3V3, if the panel output is anything higher.  If the panel connects to wires of any length (distant wired alarm sensors), a series resistor and voltage clamp (diode going to +V rail) is a good idea to reduce voltage spikes from possible electrical interference harming the Pi. Maybe your interface board already has such provisions.

Then there is the software, but there is some example code for reading GPIO pins here:

http://elinux.org/Rpi_Low-leve.....e_examples

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 9:59 pm
by foobar77
Wow, im really lost now :s  All I know is that the alarm inputs are configured as "Normally closed - Breaking negative or positive voltage loop"

I guess a LOT more reading is required, where to start is the ultimate question

Re: How to connect a temp sensor, save data and send collected data

Posted: Thu May 10, 2012 10:31 pm
by foobar77
I feel really stupid asking this but I'd rather not blow anything up until the PI boards are more readily available but after reading a little on the pages you referred to, am I correct to assume that if I connected one of my zone inputs to pin 12 and pin 6 then in python called…

GPIO.setup(12, GPIO.OUT)
GPIO.output(12, True)
I would shove 3.3v into my input on the intruder alarm panel?

Re: How to connect a temp sensor, save data and send collected data

Posted: Fri May 11, 2012 10:10 am
by ciseco
You are wanting to do what we are making very easy to do (lots of work in progress)

At one end raspberry pi+slice of pi+XRF

At the other you dont need an arduino the XRF can be turned into a node for FREE, the thermistor software is more flexible, there's even a base board for it

http://shop.ciseco.co.uk/tempe.....hermistor/

You'll see there a growing range of firmware, not least one to get at the ADC's and GPIO on an XRF, I'm sure lots of Pi users will find that useful (for your alarm too)

Matt's blog is here, he's soon to publish some stuff on Pi to XRF comms. Both the XRF + SOP work as does the URF when plugged into the USB socket.

http://lwk.mjhosting.co.uk/?ca.....spberry-pi

Our forum (as I dont come here often enough yet) is openmicros.org, you'll find getting hold of me there much easier.

Re: How to connect a temp sensor, save data and send collected data

Posted: Fri May 11, 2012 1:45 pm
by foobar77
Thanks Ciseco. The DS18B20 base board will make my project much easier. Is it possible to address multiple DS18B20s from a single base board?

Also... when are you likely to have stock of the slice-of-pi boards again?

With that side of things sorted I need only to determine how to hold-off the alarm inputs, after some further reading on the alarm panel the manual states the alarm input is normally closed (+12v or GND lost). The 12v method isn't much use to me but does anyone have any idea what GND lost means and if I can do this from the Pi?

I apologise if this question seems silly but as I stated before, I know very little about electronics.

Re: How to connect a temp sensor, save data and send collected data

Posted: Fri May 11, 2012 3:22 pm
by bredman
To answer the original question from frazelle09, there is a very old-fashioned method to read temperature without an analog input. This has been used for many years to read temperature using the parallel port of a PC. No electronics are required.

The idea is to charge and discharge a capacitor through a thermistor. A thermistor is a resistor which is susceptible to temperature changes. By measuring how quickly the capacitor charges and discharges, you can make a rough estimate of the temperature.

==Shopping list==

You will need a Raspberry Pi, a large capacitor, a thermistor (http://en.wikipedia.org/wiki/Thermistor) and some bits of wire (see note at end).

Warning: Make sure the capacitor is discharged.

==Wiring==

Connect one end of the capacitor (the negative end if it is marked) to one end of the thermistor and also to a GPIO input of the RPi.

Connect the free end of the thermistor to a GPIO output of the RPi.

Connect the free end of the capacitor to GND of the RPi.

==Software==

Write a program to do the following

- Start a timer

- Repeat 100 times { set output high; wait until input is high; set output low; wait until input is low }

- Stop the timer

==How to use==

The value of the timer will vary according to the temperature. By experimenting a bit, you should be able to build a lookup table which will approximate the temperature within 5 degrees.

Note that the voltages are low, therefore long wires could pick up significant noise. Use short wires if possible. Steal the cable from a set of cheap earphones to get protected cable with enough cores.

Re: How to connect a temp sensor, save data and send collected data

Posted: Fri May 11, 2012 3:44 pm
by Dave_G_2
bredman said:


==Software==

Write a program to do the following

- Start a timer

- Repeat 100 times { set output high; wait until input is high; set output low; wait until input is low }

- Stop the timer

==How to use==

The value of the timer will vary according to the temperature. By experimenting a bit, you should be able to build a lookup table which will approximate the temperature within 5 degrees.


This would work as is for a real time OS which Linux is not therefore there would be different delays in each iteration depending on what the OS is doing.

It would be better to take an average:

- Start a timer

- set output high; wait until input is high;

- set output low; wait until input is low

- Stop the timer

- store the reading in a variable/array

- repeat 100 times

- take an average of the readings (may need rounding off)

- compare to a look up table.