1-wire and lots of 85.00c.

I've got nano with LCD and 2x ds18x20 sensors. When used without serial connection they work fine. LCD shows both sensors okay. But when alter it so that i can read sensors from debian it goes bad.

As seen here. When Debian reads 1-wire sensors LCD goes black and temperature returned is 85.00 for both or -127.00 for one and 85.00 for second. I tried to supply 9V to Vin because i thought it was lack of power. Then i removed all LCD and LDR stuff from code but same goes on. But what is causing it? If i open serial monitor from windows and try to see what comes out, its kinda 50%/50% that its gonna give me lots of right temps or lots of -127.00 and 85.00.

http://www.youtube.com/watch?v=ACMMp1S_9NU

I tried to supply 9V to Vin because i thought it was lack of power.

You mean because you wanted to fry the Arduino. No more than 5V can be put in the Vin pin.

But when alter it so that i can read sensors from debian it goes bad.

Debian is an operating system. It can't read the sensors on your Arduino. You can program the Arduino to send serial data to the PC, where an application can read that data.

If doing that affected the LCD, it's poor code.

PaulS:

I tried to supply 9V to Vin because i thought it was lack of power.

You mean because you wanted to fry the Arduino. No more than 5V can be put in the Vin pin.

No, the absolute maximum on Vin is 20V. The practical limit is 12V.

neepie:
I’ve got nano with LCD and 2x ds18x20 sensors. When used without serial connection they work fine. LCD shows both sensors okay.

The way I read statement is: “It works then I changed the code and it doesn’t work.” It might be helpful to see what your altered code.

Your YouTube video description gives the best clue: “Why does arduino reboot itself?”

Each time you open the serial port, the Arduino automatically resets. So each time your script connects to the Arduino, it resets. You should probably look into disabling the auto-reset to prevent this from happening.

You mean because you wanted to fry the Arduino. No more than 5V can be put in the Vin pin.

As stated, Vin is thru regulator. And it didnt change a thing.

Each time you open the serial port, the Arduino automatically resets. So each time your script connects to the Arduino, it resets. You should probably look into disabling the auto-reset to prevent this from happening.

How to make it not reset and why does it do it?

Yes i know it wont speak to debian but im just using cat /dev/ttyUSB0.

Does it somehow "soft" reboot? Because its not off long.

I think the problem occured after this. I first used sensors with only lcd.print(sensors.getTempCByIndex(0);); But i wanted it to be in a variable so i could easily use it to print results to serial, LCD and thru ethernetshield.

float anturi1 = sensors.getTempCByIndex(0);
float anturi2 = sensors.getTempCByIndex(1);


// print to usb
Serial.print(anturi1);
Serial.print("\n");
Serial.print(anturi2);
Serial.print("\n");

Suggestions on using variables with it?

Does it somehow "soft" reboot? Because its not off long.

No. It does a hard reboot. There is no operating system to load, so a reboot doesn't take long.

Please post all of your code. There is much missing from the snippets.

How to make it not reset and why does it do it?

It does it because of the drivers or the software in your PC. So you can fix the drivers or software. Getting it to not keep opening and closing the port would be a good start.

Alternatively you could disable the arduino auto reset feature http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

you could have problems with the wiring of the DS18x20 if you have reading of -127 or 85.00

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <OneWire.h>
#include <DallasTemperature.h>


// 1-WIRE
// anturin data-jalka
#define ONE_WIRE_BUS 10
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);


// LDR
const int ldrPin = A6;
int LDRarvo = 0;
int valo = 0;


// LED PIN/output
const int nanoLED = 13;

//---------------------------------setup------\
void setup() {                                
  lcd.begin(16, 2);                           
  Serial.begin(9600);                         
     
sensors.begin();                              
lcd.setCursor(0,0);                           
  lcd.print("antureita on: ");                
  lcd.print(sensors.getDeviceCount(), DEC);   
  delay(2000);                                
  lcd.clear();                                
                                              
}                                             


void loop() {

// call sensors.requestTemperatures() to issue a global temperature 
// request to all devices on the bus
sensors.requestTemperatures(); // Send the command to get temperatures

float anturi1 = sensors.getTempCByIndex(0);
float anturi2 = sensors.getTempCByIndex(1);

 

LDRarvo = analogRead(ldrPin);

// LCD -------------------- 
  lcd.setCursor(0, 0);        
      lcd.print("valo: ");    
  lcd.setCursor(6, 0);        
      lcd.print(LDRarvo); 
     
  lcd.setCursor(0, 1);
      lcd.print(anturi1);
      lcd.print("c");
      
  lcd.setCursor(10, 1);
      lcd.print(anturi2);
      lcd.print("c");

// communicate with usb
Serial.print(anturi1);
Serial.print("\n");
Serial.print(anturi2);
Serial.print("\n");


}

I added this code that tells me how many sensors were found. And i got new things to ponder.
If i unplug and plug it it usually says we got 2 sensors and everything is when only using LCD.

BUT when i try serial monitor it almost always shuts off and comes back telling me no sensors were found.
Anything new to suggest? Should i try to disable that reset?

Btw this is how i read the serial:

/usr/bin/head -n2 /dev/ttyUSB0 > lammot.dat

Should i be using this?

stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

make sure /dev/ttyUSB0 or whatever is your arduino, and 115200 is the baud you did your Serial.begin(XXXX) with

Okay, problem continues. I've got almos same setup with UNO this time. Same thing with 2 sensors. goes ballistic right away :P Stills seems to work better with only one ds1820. And yes, btw they are ds1820 not with a middle letter.

How are you powering the sensors - parasitic or normal mode?

Do you have a 4.7K resistor on the bus?

Parasitic with 4.6k resistor. should i try 4.3k?

I had the same problem which sporratic results, but I was using the regualr power mode, I fixed it by adding a 10uf cap from 5v to gnd right at the sensor

Have you tried normal mode? If so does it have the same problems?

Can we see the code?

neepie: Btw this is how i read the serial:

/usr/bin/head -n2 /dev/ttyUSB0 > lammot.dat

you can use

tail -f /dev/ttyUSB0

but this will use 9600 baud rate

MarkT: Have you tried normal mode? If so does it have the same problems?

Can we see the code?

Code is showed earlier. I havent tried normal mode because its not possible when this is done. And i dont think its the reason.

can i use tail -f to output it to file?

neepie:

Each time you open the serial port, the Arduino automatically resets. So each time your script connects to the Arduino, it resets. You should probably look into disabling the auto-reset to prevent this from happening.

How to make it not reset and why does it do it?

Yes i know it wont speak to debian but im just using cat /dev/ttyUSB0.

Does it somehow "soft" reboot? Because its not off long.

Read my post about auto-reset in this thread: http://arduino.cc/forum/index.php/topic,74551.0.html

You can use the stty command to control the use of the DTR signal. See the hup/-hup options.

--- bill

Code atm is:

#include <Ethernet.h>
#include <Server.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>

#define DHTPIN 3     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11 
DHT dht(DHTPIN, DHTTYPE);


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,100, 150 };
Server server(80);

// sensors pin
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

int anturit = sensors.getDeviceCount();


// LDR
const int ldrPin = A0;
int ldr = 0;


// SETUP ---------------------------------------------
void setup() {                                
  
Ethernet.begin(mac, ip);
server.begin();
  
  Serial.begin(9600);                         

sensors.begin();  //1-wire
Serial.print(sensors.getDeviceCount(), DEC);


dht.begin();
}                                             
//SETUP -----------------------------------------------

void loop() {
ldr = analogRead(ldrPin);

int h = dht.readHumidity();
int t = dht.readTemperature();


// call sensors.requestTemperatures() to issue a global temperature 
// request to all devices on the bus
sensors.requestTemperatures(); // Send the command to get temperatures

float anturi1 = sensors.getTempCByIndex(0);
float anturi2 = sensors.getTempCByIndex(1);


// printaa usbiin tuloksia
Serial.print(anturi1);
Serial.print("\n");
Serial.print(anturi2);
Serial.print("\n");
Serial.print(ldr);
Serial.print("\n");

//DHT
/*
  if (isnan(t) || isnan(h)) {
    Serial.println("DHT FAILURE");
  } else {
    Serial.print("Humidity: "); 
    Serial.print(h);
    Serial.print("\n");
    Serial.print("Temperature: "); 
    Serial.print(t);
    Serial.println("\n");
  }
*/
//----------- ETHERNET ---------------------------

  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
client.println("<HTML>");
client.println("<HEAD>");
   client.println("<TITLE>Arduino webbaservero!</TITLE>");
client.println("</HEAD>");
          client.println("<BODY>");
            client.print("anturitietoja!");
            client.println("
");
            client.print(anturi1);
            client.print("c    ");
            client.print(anturi2);
            client.print("c");
            client.println("
");
            client.println("
");
            client.println("
");
            client.print("kosteus: ");
            client.print(h);
            client.print("%");
            client.print("  lampotila: ");
            client.print(t);
            client.print("c");
client.println("
");
            client.print("valoisuus 1-1000: ");
            client.print(ldr);
            
client.println("
");
client.println("
");
client.println("
");
            client.println("<img src='http://heller.huono.org/servduino.jpg'>");

          break; 
        }
       if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
       else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
}


}

As i changed this setup from nano to uno i’ve got new problems.
tail -f /dev/ttyACM0
tail: tiedostoa ”/dev/ttyACM0” ei voi avata lukemista varten: I/O-virhe
which says ACM0 cant be opened for reading.

And the problem goes on with 1-wire. Its showing -127.00 / 85.00 even from ethernetshield site.

edit: changed sensors to not use parasitic. well see what it gives.

Tried to fix reading serial to file with this line “stty -F /dev/ttyACM0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts”
Didnt help and dont know how to reverse it :o

And i changed baud rate to 115200 when compiling but… when doing head -n5 /dev/ttyACM0 > lammot.dat it wont do anything. It starts doing but no output is given and i have to do ^C.

So i think we got progress here!

Tried this command: stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts And now i can read it! But when reading this is my problem

verkkolevy:~# head -n5 /dev/ttyACM0 > lammot.dat && cat lammot.dat
223.87 
25.31
348
34
24

So its all good but how to get rid of the first unwanted number 2? Its not really 223.87c :) And sensors are working fine so far WITHOUT parasitic power. When trying parasitic power i've noticed that sometimes it detects 2 sensors and parasitic ON but sometimes it just doesnt and then it gives -127.00 and 85.00

Whats up with that? Problem is that I will be using rca-connectors to connect sensors to arduino casing. So parasitic would be awesome.

edit: got rid of that extra number. Now i need to know how to make parasitic work and i'll start a new thread for it.

Serial.print(anturi1);
Serial.print("\n");
Serial.print(anturi2);
Serial.print("\n");
Serial.print(ldr);
Serial.print("\n");

It would be nice to know what number corresponds to what variable, wouldn't it?

Serial.print("anturi1: ");
Serial.println(anturi1);
Serial.print("anturi2: ");
Serial.println(anturi2);
Serial.print("ldr: ");
Serial.println(ldr);

Once you know which value is being reported incorrectly, your chances of fixing the issue go way up.