TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
Arduino Nano per USB …

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/935
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 20.01.2015, 22:13    Post subject: Arduino Nano per USB … Reply with quote

Hallo Forum.

Frage: Kann man einen Arduino Nano mit dem USB-Port eines IGW/935 verbinden?

Antwort: Ja, kein Problem. Für die USB-Schnittstelle benutzt der Arduino Nano einen FTDI-Chip. Die erforderlichen Treiber müssen auf dem IGW/935 nur geladen werden.

Code:
insmod usbserial.ko
insmod ftdi_sio.ko


Der USB-UART wird zur Device ttyUSB0 im Linux des IGW/935. Danach können zum Beispiel mit microcom (dieses Tool ist ab Werk im Linux des IGW/935 vorinstalliert) serielle Daten vom Arduino empfangen werden:

Code:
microcom -s 9600 /dev/ttyUSB0
692 67% 3.38V
690 67% 3.37V
606 59% 2.96V


Weiterhin ist ein passendes Kabel erforderlich. Am IGW/935 ist der USB-Port durch eine Typ-A Buchse realisiert. Der Arduino Nano verwendet einen Mini-B USB-Steckverbinder. Weitere Informationen zum Arduino Nano findet man unter http://arduino.cc/en/pmwiki.php?n=Main/ArduinoBoardNano

Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 22.01.2015, 07:04    Post subject: Zugriff per Python … Reply with quote

Hallo Forum.

Im Python eines IGW/935 finden Sie die pySerial-Bibliothek (siehe auch http://pyserial.sourceforge.net/index.html). Damit können Sie auch den auf USB-UART /dev/ttyUSB0 zugreifen.

Starten Sie einfach Python im Rahmen einer Telnet/SSH-Sitzung und probieren Sie die folgenden Zeilen aus:

Code:
>>> import serial
>>> ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=3)
>>> line = ser.readline()
>>> print line
351 34% 1.72V
>>> ser.close()


Die Zeichenfolge für die Ausgabe „351 34% 1.72V“ wurde zuvor per USB-UART /dev/ttyUSB0 vom Arduino Nano empfangen.

Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 22.01.2015, 07:20    Post subject: Arduino Nano Code … Reply with quote

Hallo Forum.

Hier der Code für den Arduino Nano, mit dem die Ausgaben (z. B. „351 34% 1.72V“) in den beiden Beispielen weiter oben erzeugt wurden:

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

void loop()
{
 
  int value = analogRead(0);
  int percent = map(value, 0, 1023, 0, 100);
  Serial.print(value);
  Serial.print(" ");
  Serial.print(percent);
  Serial.print("% ");

  float voltage = value * (5.0 / 1023.0);
  Serial.print(voltage);
  Serial.println("V");
  delay(1000);
}


Gruß KDW
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/935 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015