arvin
Posts: 2
Joined: Sat Mar 10, 2018 6:58 am

is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sat Mar 10, 2018 7:05 am

it's possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy ?? if not please recommend another way to solve my problem. thanks in advanced

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13142
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sat Mar 10, 2018 3:22 pm

What actually IS your "problem"?

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sat Mar 10, 2018 3:30 pm

from doc
Nanpy autodetects the serial port for you, anyway you can manually specify another serial port:

from nanpy import SerialManager
connection = SerialManager(device='/dev/ttyACM1')
so you can manually connect to 2 ( USB connected ) arduinos
after you find the "ttyACM1 / 2"... info )

arvin
Posts: 2
Joined: Sat Mar 10, 2018 6:58 am

Re: is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sun Mar 11, 2018 11:23 am

so you can manually connect to 2 ( USB connected ) arduinos
after you find the "ttyACM1 / 2"... info )

im using this code. i want output is on/off 1 LED in every arduino . but the problem is one arduino only to on led i want both

Code: Select all

from nanpy import SerialManager
from time import sleep

from nanpy import ArduinoApi


connection = SerialManager(device='/dev/ttyUSB0')
connection = SerialManager(device='/dev/ttyUSB1')
a = ArduinoApi(connection=connection)
b = ArduinoApi(connection=connection)
a.pinMode(7, a.OUTPUT)
b.pinMode(7, b.OUTPUT)
a.digitalWrite(7, a.HIGH)
b.digitalWrite(7, b.HIGH)
print"LED ON"
sleep(3)
a.digitalWrite(7, a.LOW)

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sun Mar 11, 2018 12:31 pm

pls use code tags
should it be like

Code: Select all

connection1 = SerialManager(device='/dev/ttyUSB0')  # Arduino 1
a = ArduinoApi(connection=connection1)
connection2 = SerialManager(device='/dev/ttyUSB1')  # Arduino 2
b = ArduinoApi(connection=connection2)
your code is overwriting its variable ( link ) so only the second ( line) could work.

are that connections / ports already tested by a serial monitor tool ( like arduino ide... ) means verified?
Last edited by KLL on Sun Mar 11, 2018 2:01 pm, edited 2 times in total.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13142
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: is it possible to slave 2 arduino in raspberry pi 3 in serial port using nanpy

Sun Mar 11, 2018 12:51 pm

added code tags, but there are no indentations in this code, so it was not necessary.

Return to “Beginners”