Side 2 af 2

Re: HJÆÆÆÆLP - Præcise termostater - hvor findes de?

: 22. feb 2015, 22:15
af sstje
Nimbus39 skrev:Til Arduino bruger man ofte DS18B20 følere og de skulle have en præcision på +- 0,5 grader fra -10 til 85, og tåle -55 til 125 grader.
De koster 1-3$ stykket, men kræver lidt kendskab til programmering for at få det hele sat sammen til noget der virker, men man kan bygge en styringsboks for et par hundrede kroner.
http://www.maximintegrated.com/datashee ... vp/id/2812" onclick="window.open(this.href);return false;
En fordel er at man kan sætte andre dimser sammen med Arduinoen, f.eks. en flammesensor til gasblussene så man kan bygge en boks der netop passer til det man skal bruge.
Kunne du lokkes til at hjælpe med at aflæse 2 følere, tilsluttet samme board?

Der er noget med, at man skal kunne aflæse følerens unikke adresse, men jeg synes ikke jeg kan "hive" dem ud :-)

Re: HJÆÆÆÆLP - Præcise termostater - hvor findes de?

: 22. feb 2015, 22:25
af Nimbus39
sstje skrev:
Nimbus39 skrev:Til Arduino bruger man ofte DS18B20 følere og de skulle have en præcision på +- 0,5 grader fra -10 til 85, og tåle -55 til 125 grader.
De koster 1-3$ stykket, men kræver lidt kendskab til programmering for at få det hele sat sammen til noget der virker, men man kan bygge en styringsboks for et par hundrede kroner.
http://www.maximintegrated.com/datashee ... vp/id/2812" onclick="window.open(this.href);return false;
En fordel er at man kan sætte andre dimser sammen med Arduinoen, f.eks. en flammesensor til gasblussene så man kan bygge en boks der netop passer til det man skal bruge.
Kunne du lokkes til at hjælpe med at aflæse 2 følere, tilsluttet samme board?

Der er noget med, at man skal kunne aflæse følerens unikke adresse, men jeg synes ikke jeg kan "hive" dem ud :-)
Jeg har noget kode der kan gøre det, lægger det op i morgen eftermiddag når jeg kommer hjem.

Re: HJÆÆÆÆLP - Præcise termostater - hvor findes de?

: 23. feb 2015, 17:34
af Nimbus39
Her er koden til at finde og aflæse flere DS18B20 følere (følerne sidder på Digital 2)

Kode: Vælg alt

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

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

int numberOfDevices; // Number of temperature devices found

DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
  
  // Grab a count of devices on the wire
  numberOfDevices = sensors.getDeviceCount();
  
  // locate devices on the bus
  Serial.print("Locating devices...");
  
  Serial.print("Found ");
  Serial.print(numberOfDevices, DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: "); 
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");
  
  // Loop through each device, print out address
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
	{
		Serial.print("Found device ");
		Serial.print(i, DEC);
		Serial.print(" with address: ");
		printAddress(tempDeviceAddress);
		Serial.println();
		
		Serial.print("Setting resolution to ");
		Serial.println(TEMPERATURE_PRECISION, DEC);
		
		// set the resolution to TEMPERATURE_PRECISION bit (Each Dallas/Maxim device is capable of several different resolutions)
		sensors.setResolution(tempDeviceAddress, TEMPERATURE_PRECISION);
		
		 Serial.print("Resolution actually set to: ");
		Serial.print(sensors.getResolution(tempDeviceAddress), DEC); 
		Serial.println();
	}else{
		Serial.print("Found ghost device at ");
		Serial.print(i, DEC);
		Serial.print(" but could not detect address. Check power and cabling");
	}
  }

}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(sensors.getTempC(deviceAddress));
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}

void loop(void)
{ 
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  
  
  // Loop through each device, print out temperature data
  for(int i=0;i<numberOfDevices; i++)
  {
    // Search the wire for address
    if(sensors.getAddress(tempDeviceAddress, i))
	{
		// Output the device ID
		Serial.print("Temperature for device: ");
		Serial.println(i,DEC);
		
		// It responds almost immediately. Let's print out the data
		printTemperature(tempDeviceAddress); // Use a simple function to print out the data
	} 
	//else ghost device! Check your power requirements and cabling
	
  }
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}
Resultatet aflæses ved at åbne serial vinduet.

Re: HJÆÆÆÆLP - Præcise termostater - hvor findes de?

: 26. feb 2015, 22:45
af sstje
Nimbus39 skrev:Her er koden til at finde og aflæse flere DS18B20 følere (følerne sidder på Digital 2)

Kode: Vælg alt

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

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9
.[/quote]

Super. Mange tak. Det skal prøves til weekenden :-)