We are connecting six arduinos via an usb-hub to our raspi. Each of the arduinos will get analog data from one sensor and also control the movement of one motor. Thus we have an input and an output on all six arduinos. The program for our arduinos is already done; we will pass on specific strings to get sensor data or to drive steps with our motor. Most of our open questions are due to our master/raspi.

On our raspi we plan to store sensor data of all six sensors (each per arduino) in a SQLight database. We wish to use python 3 for "listening" to sensor data and storing it in the database. Moreover we need to keep track of the specific sensor, so that arduino 1 has it´s data stored in DB1, arduino 2 in DB2 and so on.

I have looked for similar solutions out there; but found very little. I think we have to use 6 threads, one per arduino, to run in our python script at our master. Or is there another way? We are still at the planing phase and very much appreciate if someone can pinpoint to some solutions / ideas / concepts that we could use and share.

  • it needs to be over usb? Can't you use i2c?
    – Luis Diaz
    Sep 20, 2017 at 6:52
  • We have 6 Arduinus with one sensor and one linear motor per Arduino (with an OP between). In addition, we have one motor for a cam. Since I´m pretty new to the field I am not experienced with i2c solutions on the RasPi. Could you please share a link/tip how to start a dialog with 7 slaves to one RasPi on the basis of i2c? Everything is very welcome! Sep 20, 2017 at 7:09
  • Sure, will send you in a while, I'm not at the computer right now.
    – Luis Diaz
    Sep 20, 2017 at 7:13

2 Answers 2


Here you can find an example on how to drive one or multiple arduinos using i2c. It's really well explained there, so, I don't see a point on duplicate the info here. Please take a look at the link and, if you have any doubts, I'll be glad to help you out.

There is a couple of steps to do, but basically yo need to configure i2c as master on the pi, then configure arduino as i2c slave.

You're supposed to add a level converter in between, but most people is getting ok results without it, and bad result with it, so... I don't know what to say about it.

Benefits on i2c are that you can connect up to 112 nodes on an 7 bits i2c bus. So, just need to use 4 wires from pi to arduino 1, then 4 wires to arduino 2, etc.

Also, you can add i2c sensors and actuators as well on the bus.

  • 1
    Tank you very much! Sep 20, 2017 at 10:12
  • You're welcome. If you like a answer, please consider click the ^ button (at the left side of my answer) or maybe mark the answer as correct, since this is the only "reward" to our, the users, and also, makes it easier to someone surfing the web to find out what it's ok and what it's not.
    – Luis Diaz
    Sep 20, 2017 at 10:14

As stated above, we had the problem to identify our Arduinos wired via USB to our RasPi. However, we found out that (e.g.) the Arduino MKR zero do have product-IDs which are unique. This helps us to open threads for each Arduino and to ensure, via the product-ID, that the dialog stays unambigously.

One can use this pretty simple python(2) script to check the ports and get the product-ID plus the current USB-port of the Arduinos:

from serial.tools import list_ports

def device_exists():
        for port in list_ports.comports():
            print port
        return True
    return False

print "\n========= The following devices are connected to my USB: =========\n"
print "\n=========  Thanks for checking. Life long and prosper.   =========\n"

Here is the github-link: https://github.com/RiK4kings/checkPorts/blob/master/p2_checkPorts.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.