Hello all, so I'm a little stuck on this one, possibly due to lack of sleep, but I'm working on something that basically needs to know the sensor position to work properly.
Basically in the setup loop I have it run a search for the sensor address of what is connected, that's fine and dandy and it prints to serial just fine, however I can't get the sensor address to print to the LCD, granted that's not critical, but when I change serial.print to lcd.print it prints out zeros instead.
The main issue is that I want to grab the first sensor address, and set it as "sensor 1", then prompt to plug in the second sensor and set it's address as "sensor 2", that way I can have the separate readings and if the sensors get mixed up, or I have to replace one, it will go through the routine of plugging them in order when it boots.
Here's the code I have so far though doubt it will be much help, mostly looking for someone who has done this before to share their method.
I'm thinking I'll need bytes for addr1, addr2 etc, but the implementation is eluding me at the moment.
#include <Wire.h>
#include <OneWire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library
#include <Servo.h>
//------------------------------------------------------------------------------------ HW Info
//Pin 2 = Relay 1 (right), blue wire
//Pin 3 = Relay 2 (left), green wire
//pin 4 = servo motor, yellow wire
//pin 5 = onewire bus, orang wire
//pin 6= NC, brown wire
//------------------------------------------------------------------------------------ End HW Info
//------------------------------------------------------------------------------------ LCD Setup
#define I2C_ADDR 0x20 // Define I2C Address for the PCF8574A
#define BACKLIGHT_PIN 7
#define En_pin 4
#define Rw_pin 5
#define Rs_pin 6
#define D4_pin 0
#define D5_pin 1
#define D6_pin 2
#define D7_pin 3
#define LED_OFF 0
#define LED_ON 1
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
//------------------------------------------------------------------------------------ End Of LCD Setup
//------------------------------------------------------------------------------------ One Wire Setup
OneWire ds(5);
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte data2[12];
byte addr[8];
byte addr2[8];
//------------------------------------------------------------------------------------ End Of One Wire Setup
Servo myservo;
int relay1 = 2;
int relay2 = 3;
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
myservo.attach(4);
myservo.write(0);
lcd.begin (16,2); // initialize the lcd
// Switch on the backlight
lcd.clear();
lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
lcd.setBacklight(LED_ON);
lcd.setCursor(0,0);
lcd.print("OneWire Setup");
lcd.setCursor(0,1);
lcd.print("Connect EXT(10s)");
delay(10000);
ds.reset_search();
delay(250);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Sensor found");
lcd.setCursor(0,1);
for( i = 0; i < 8; i++) {
Serial.write(' ');
Serial.print(addr[i], HEX);
lcd.print(addr[], HEX);
}