Problem reading Uno via Linux

Hey there,

I'm new here and having a strange problem with my Uno.

I want to measure and plot temperature with some DS18B20's. This works fine on Win 7 64Bit. Now, I am using openSUSE 13.1. On the serial monitor that comes with the Arduino IDE everything is fine, too. It looks like this:

ROM = 281CFFA450063 22.69 C ROM = 28BC7BA550064 22.62 C ROM = 28822CA4500D1 22.62 C ROM = 28D56DA45005E 22.50 C ROM = 281BD7A450020 22.56 C No more Sensors ROM = 281CFFA450063 22.62 C ROM = 28BC7BA550064 22.62 C ROM = 28822CA4500D1 22.62 C ROM = 28D56DA45005E 22.50 C ROM = 281BD7A450020 22.56 C No more Sensors

... and so on

When trying to use "screen /dev/ttyACM0 9600" on terminal or my python script, it needs some time to read it correctly. This looks like:

2 ROM = 28BC7BA5500646 C ROM = 28D56DA45005E 22.44 C ROM = 281BD7A450020 22.50 C No more Sensors ROM = 281CFFA450063 22.62 C ROM = 28BC7BA550064ROM = 281CFFA450063 22.62 C ROM = 28BC7BA550064 22.56 C ROM = 28822CA4500D1 22.56 C ROM = 28D56DA45005E 22.44 C ROM = 281BD7A450020 22.50 C No more Sensors ROM = 281CFFA450063 22.62 C ROM = 28BC7BA550064 22.56 C ROM = 28822CA4500D1 22.56 C ROM = 28D56DA45005E 22.50 C ROM = 281BD7A450020 22.50 C No more Sensors

So there is a problem at the beginning and then it works. It looks different every time, but never correct and so I can't save it to a file and plot it later...

I don't want to ignore this and just skip the first 10 lines or so, I want to have a solution^^ Does anyone has an idea??

Cheers, Chewy

no one?

Include your code, in code tags, both the Arduino and Python code. I will say that I use Arduino with all sorts of serial terminals and code I have written myself and have had no problems. So I have no idea what your problem could involve.

Hey,

here is my Arduino Code, it’s almost the example code from the OneWire library

#include <OneWire.h>

// temperature sensors DS18B20 to serial port
// one data request of all sensors per second

OneWire  ds(10);  // on pin 10 (a 4.7K resistor is necessary)

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

void loop(void) {
  byte i;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius;
  
  if ( !ds.search(addr)) {
    Serial.println("No more Sensors");
    ds.reset_search();
    delay(1000);
    return;
  }

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

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  ds.reset();
  ds.select(addr);    
  ds.write(0xBE, 1);         // Read Scratchpad, with parasite power on at the end

  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
  }

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  
  celsius = (float)raw / 16.0;
  Serial.print(" ");
  Serial.print(celsius);
  Serial.println(" C");
  
 }

And my Pyhton Code, but I don’t think there is a problem here, because it occurs in the terminal too:

# Windows
#arduino = serial.Serial(port="com3", baudrate=9600, timeout=5)
# Linux
arduino = serial.Serial(port="/dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_75338323535351C0F171-if00", baudrate=9600, timeout=5)

	NumberOfSensors = 0
	while 1:
		line = aruino.readline().decode()
		if not ("No more Sensors" in line):
			NumberOfSensors += 1
			# only prints the last 2 chars of the sensor ID
			sensor_ID = line.split()[2][11:]
			# temperature in Celsius
			temp_val = line.split()[3]
			now = time.ctime().split()[3]
			temp_file.write(now + ' ' + sensor_ID + ' ' + temp_val + ' ')
		else:
			break
		
	arduino.close()

I have another problem while using windows. After some time, maybe hours, maybe a day, the Code gets stuck. No Error, no more writing in the text file and I can’t close the cmd. Even unplugging the Arduino won’t help. It just does nothing. But I didn’t have the chance to try it on another pc, yet. Maybe it’s just a problem with my usb controller.

Cheers,
Metalchewy