Pi-SPi-8AI Raspberry Pi Temperature Sensor Interface Kit

  • $29.95


The Pi-SPi-8AI Temperature Sensor Kit is pre-configured for 8 Thermistor Inputs. The kit includes:

  • Qty 1 Pi-SPi-8AI Interface with thermistor inputs (fully assembled and tested
  • Qty 1 40 Pin to 26 Pin Interface Cable for the RPi
  • Qty 1 10K Thermistor Temperature Sensor with 36" wire leads
  • Qty 3 10K Thermistor Temperature Sensors

If purchased separately, this package would cost $40.70! You save over 26%!

Port Pins Used:

SPI-MOSI  (GPIO10)
SPI-MISO  (GPIO9)
SPI-SCK   (GPIO11)
CS_8AI     (GPIO7)

Complete list of features:

  • Identical foot print to the RPi 3
  • Each module has its own 3.3VDC LDO regulator operating from the RPi 5VDC bus
  • No loading on the RPi 3.3VDC bus
  • Terminal Blocks forThermistor Input
  • LED indicators for power
  • Dual GPIO connectors (left and right)
  • MCP3208 A/D Converter with 12 bit resolution
  • Each analog signal buffered (1/4 LM324 Op Amp)
  • Inputs 1 thru 8 are configured for Thermistor Inputs
  • Module is powered from the Raspberry Pi

Downloads

Schematic

PCB Layout

Sample Code in Python

SAMPLE CODE (Geany "C" Compiler)

/*
 * pispi_8ai_t8.c
 *
 * Copyright 2016  <pi@raspberrypi>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *  
 */

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <math.h>

#include <wiringPi.h>     
#include <wiringPiSPI.h>

// Define Pins as used by Pi-SPi modules
#define CS_2AO        4
#define CS_8DI        17
#define CS_SPARE2    27
#define CS_SPARE1    22
#define CS_LEDS        18
#define CS_LCD1        23
#define CS_LCD2        24
#define CS_8KO        8
#define CS_8AI        7
#define DIR_RS485    25

#define mA_20         3723    // 20 mA into 150Ohms = 3 Vdc / 3.3 Vdc full scale * 4096 Counts

// Steinhar-Hart Equation Defines for 10K Thermistor Beta 3380 Temp Sensor

#define R_LOAD             10000.0
#define R_ROOM_TEMP        10000.0 // for 25 Deg C
#define T_BETA            3380
#define T_AD_COUNTS        4095    // MCP3208 is 12 bit ADC
#define ROOM_TEMP_NOM     25.0
        
// Prototypes    
void Initialize_Pi_Hardware(void);
void Update_Analog(unsigned char channel);
void Update_Temperatures(unsigned char channel);
    
// Variables
unsigned AN_AD[8];
float AN_Temp[8];

// main
int main(void) {

    unsigned char i;
    
    wiringPiSetupGpio();           
      Initialize_Pi_Hardware();      
     digitalWrite(CS_8AI, HIGH);
              
    while(1)
    {        
            
        for(i = 0; i < 8; i++) {            

            Update_Temperatures(i);

            if(AN_AD[i] > 4000) {
                printf("Channel AN %d Temperature = OFF \n", i+1);
            }
            else {
                printf("Channel AN %d Temperature = %0.1f C \n", i+1, AN_Temp[i]);
            }
        }
        
        printf("\n");                
        delay(1000);
    }

    return 0;
}

void Update_Analog(unsigned char channel) {

    unsigned int  adc, input;
    unsigned char buf[3];
    
    wiringPiSPISetup(1, 100000);
    input = 0x0600 | (channel << 6);
    
    buf[0] = (input >> 8) & 0xff;
    buf[1] = input & 0xff;
    buf[2] = 0;
    
    digitalWrite(CS_8AI, LOW);    
    wiringPiSPIDataRW(1,buf,3);
    adc = ((buf[1] & 0x0f ) << 8) | buf[2];
    digitalWrite(CS_8AI, HIGH);
            
    AN_AD[channel] = adc;    

}

void Update_Temperatures(unsigned char channel) {
    
    float sample;
    unsigned int average;
    int i;
    
    // Calculate Temperature for Cold Water Line
    average = 0;
    
    for(i=0; i<5; i++) {            // take 5 reading and average
        Update_Analog(channel);            // to smooth out the reading    
        average += AN_AD[channel];
    }
    
    average = average / 5;         
    
    sample = ((float)T_AD_COUNTS / average) - 1;
    sample = (float)R_LOAD / sample;
    sample = sample / (float)R_ROOM_TEMP;
    sample = log(sample);
    sample /= (float)T_BETA;
    sample += 1.0 / ((float)ROOM_TEMP_NOM +275.15);
    sample = 1.0 / sample;
    sample -= 273.15;
    
    AN_Temp[channel] = sample;
    
}

void Initialize_Pi_Hardware(void) {
    
    // SPI CS Enable Lines
    pinMode(CS_2AO, OUTPUT);
    pinMode(CS_8DI, OUTPUT);
    pinMode(CS_SPARE2, OUTPUT);
    pinMode(CS_SPARE1, OUTPUT);
    pinMode(CS_LEDS, OUTPUT);
    pinMode(CS_LCD1, OUTPUT);
    pinMode(CS_LCD2, OUTPUT);
    pinMode(CS_8KO, OUTPUT);
    pinMode(CS_8AI, OUTPUT);
    pinMode(DIR_RS485, OUTPUT);
}

SaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSaveSave