Temperature Sensor Help!

I'm working on a project for my aquaponics system and am using a teensy 3.1. I'm having issues with onewire and posted my code and error bellow. Thanks for your help!

#include <OneWire.h>
#include <DallasTemperature.h>




//Parts list
const int TTempGOOD = 12;
const int MTempGOOD = 11;
const int pHGOOD = 10;
const int TTempBAD = 0;
const int MTempBAD = 1;
const int pHBAD = 2;
const int MainTemp = 22;

//Variables
int pH = 6;
int TTemp = 75;
int MTemp = 75;

//Misc
OneWire oneWire1(22);
DallasTemperature sensors1(&oneWire1);

void setup() {
  pinMode(TTempGOOD, OUTPUT);
  pinMode(TTempBAD, OUTPUT);
  pinMode(MTempGOOD, OUTPUT);
  pinMode(MTempBAD, OUTPUT);
  pinMode(pHGOOD, OUTPUT);
  pinMode(pHBAD, OUTPUT);
  Serial.begin(9600);
  Serial.println("Luke's Aquaponics Program");
  sensors1.begin();
  

}
void loop() {
  Serial.println("Requesting Temperatures...");
  sensors1.requestTemperatures();
  Serial.println("");
  Serial.print("Main Tank Temperature is... ");
  Serial.println(sensors1.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire 
  Serial.println("");
  Serial.println("");
  if (TTemp < 80.1 && TTemp >74.9){
    digitalWrite(TTempGOOD, HIGH);
  }
  else{
    digitalWrite(TTempBAD, HIGH);
  }
  if (MTemp < 80.1 && MTemp > 74.9){
    digitalWrite(MTempGOOD, HIGH);
  }
  else{
    digitalWrite(MTempBAD, HIGH);
  }
  if (pH < 6.6 && pH > 5.4){
    digitalWrite(pHGOOD, HIGH);
  }
  else{
    digitalWrite(pHBAD, HIGH);
  }
}

And I am getting this error:
In file included from Aquaponics_Control_Computer_8_28.ino:2:0:
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here"
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:115:5: error: 'IO_REG_TYPE' does not name a type
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:116:14: error: 'IO_REG_TYPE' does not name a type

I'm using dallastemperature from: MilesBurton.com (3.7.2)
And onewire from: OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy

If anyone has experience with this I would really appreciate your help/input. Thanks!

Hi there! i'm having an issue with the onewire library used for the DS18B20. I'm planning to use two sensors to read back temperatures (eventually with an lcd screen), but for right now plan to have it turn on and off a "good" and "bad" light.

#include <OneWire.h>
#include <DallasTemperature.h>




//Parts list
const int TTempGOOD = 12;
const int MTempGOOD = 11;
const int pHGOOD = 10;
const int TTempBAD = 0;
const int MTempBAD = 1;
const int pHBAD = 2;
const int MainTemp = 22;

//Variables
int pH = 6;
int TTemp = 75;
int MTemp = 75;

//Misc
OneWire oneWire1(22);
DallasTemperature sensors1(&oneWire1);

void setup() {
  pinMode(TTempGOOD, OUTPUT);
  pinMode(TTempBAD, OUTPUT);
  pinMode(MTempGOOD, OUTPUT);
  pinMode(MTempBAD, OUTPUT);
  pinMode(pHGOOD, OUTPUT);
  pinMode(pHBAD, OUTPUT);
  Serial.begin(9600);
  Serial.println("Luke's Aquaponics Program");
  sensors1.begin();
  

}
void loop() {
  Serial.println("Requesting Temperatures...");
  sensors1.requestTemperatures();
  Serial.println("");
  Serial.print("Main Tank Temperature is... ");
  Serial.println(sensors1.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire 
  Serial.println("");
  Serial.println("");
  if (TTemp < 80.1 && TTemp >74.9){
    digitalWrite(TTempGOOD, HIGH);
  }
  else{
    digitalWrite(TTempBAD, HIGH);
  }
  if (MTemp < 80.1 && MTemp > 74.9){
    digitalWrite(MTempGOOD, HIGH);
  }
  else{
    digitalWrite(MTempBAD, HIGH);
  }
  if (pH < 6.6 && pH > 5.4){
    digitalWrite(pHGOOD, HIGH);
  }
  else{
    digitalWrite(pHBAD, HIGH);
  }
}

And I get this error:
n file included from Aquaponics_Control_Computer_8_28.ino:2:0:
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:108:2: error: #error "Please define I/O register types here"
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:115:5: error: 'IO_REG_TYPE' does not name a type
C:\Program Files (x86)\Arduino\libraries\OneWire/OneWire.h:116:14: error: 'IO_REG_TYPE' does not name a type

I'm using dallastemperature from: MilesBurton.com (3.7.2)
And onewire from: OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy

If anyone has experience with this I would really appreciate your help/input. Thanks!

Don't cross post, PLEASE.

You might find this useful. It is derived from a tutorial by hacktronics

http://homepages.ihug.com.au/~npyner/Arduino/Temps_Hacktronics.ino

The hacktronics websight appears to have been hijacked or something

The above requires you to identify the sensors' addresses separately

// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial: 
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {
  Serial.begin(9600);

  discoverOneWireDevices();
}

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  
  Serial.print("Looking for 1-Wire devices...\n\r");
  while(ds.search(addr)) {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");

    for( i = 0; i < 8; i++) {
      Serial.print("0x");
      if (addr[i] < 16) {
        Serial.print('0');
      }
      Serial.print(addr[i], HEX);

      if (i < 7) {
        Serial.print(", ");

      }
    }
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
        return;
    }
  }
  Serial.print("\n\r\n\rThat's it.\r\n");
  ds.reset_search();
  return;
}

void loop(void) {
  // nothing to see here
}

compiled for me...

look at this:

  if (pH < 6.6 && pH > 5.4){
    digitalWrite(pHGOOD, HIGH);
  }
  else{
    digitalWrite(pHBAD, HIGH);
  }

you never turn off the pHGOOD pin when pHBAD if on...

you will want to fix that:

if (pH < 6.6 && pH > 5.4)
  {
    digitalWrite(pHGOOD, HIGH);
    digitalWrite(pHBAD, LOW);
  }
  else
  {
    digitalWrite(pHBAD, HIGH);
    digitalWrite(pHGOOD, LOW);
  }

also you declare pH as an int:

int pH = 6;

but in your expression above... you compare floats.

its a good example for some of your other variable declaration issues

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator