/*!
@file
@brief show 1-wire stuff
Here we have some sensors.
There are a number of ways to connect multiple 1wire devices.
If they are all on one bus then there's the issue of destinguishing them;
note that they come from the factory with "random" IDs.
We can go through a config phase to determine which one's which.
- store sensor's role in the DS18B20's EEPROM
- manually determine the ID and then write that to Arduino's
EEPROM or to SD card config file.
Or we go for multiple 1-wire buses with just one sensor per bus.
Then we label our bread-board/screw-block for each location.
Note that if you want all the DS18B20s on one bus they must have believable
IDs. So in `attrs` set "deviceID" to "28"<14 hex digits>, so giving 8byte ID
(see DS18b20 documentation)
*/
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal_I2C lcd(0x27,16,2);
OneWire _1wire0(2);
OneWire _1wire1(3);
OneWire _1wire2(4);
OneWire _1wire3(5);
DallasTemperature dallas0(&_1wire0);
DallasTemperature dallas1(&_1wire1);
DallasTemperature dallas2(&_1wire2);
DallasTemperature dallas3(&_1wire3);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
lcd.backlight();
lcd.print("hello");
dallas0.begin();
dallas1.begin();
dallas2.begin();
dallas3.begin();
}
float get_temp(int Idx,DallasTemperature & Dallas)
{
Dallas.requestTemperatures(); // Send the command to get temperatures
//Serial.println("DONE");
float temp_c = Dallas.getTempCByIndex(0);
Serial.print(" :");
Serial.print(Idx);
Serial.print(": ");
Serial.print(temp_c);
return temp_c;
}
int zzz = 500;
int N =0;
void loop() {
Serial.print(N);
lcd.setCursor(0,1);
lcd.print(N++);
lcd.setCursor(0,0); lcd.print(get_temp(0,dallas0));
lcd.setCursor(8,0); lcd.print(get_temp(1,dallas1));
lcd.setCursor(0,1); lcd.print(get_temp(2,dallas2));
lcd.setCursor(8,1); lcd.print(get_temp(3,dallas3));
Serial.println("");
delay(zzz);
}
//eof