novice needs help with U3 and Raspberry Pi | LabJack

novice needs help with U3 and Raspberry Pi

7 posts / 0 new
Last post
egg's picture
novice needs help with U3 and Raspberry Pi

hello, I am attempting to use a LabJack U3 with a Raspberry Pi4, and am running into issues reading an analog value.  I have installed Exodriver, and the LabJackPython2.0.0 files, however the code portion is giving me troubles.  When i run u3allio in Mu, it returns the error, "ModuleNotFound Error  No Module named U3."

I previously used the U3 on my windows laptop and upgraded the firmware on it if that makes a difference.

when i run in geany, it gives me the correct serial number, which makes me think that it is connecting.. I'm super new to all of this so i'm sure there is something easy i am missing.  I'm probably forgetting a lot of things I have tried also, but any help would be super appreciated.

Sorry if I am being too vague with my question, I'm just stuck is all.  Basically at this point, i just want it to read an analog input.

Thanks much!


LabJack Support
labjack support's picture
It looks like Mu and its

It looks like Mu and its Python cannot find the LabJackPython modules. If there are multiple versions of Python on your system, you need to install LabJackPython to the versions of Python you will be using. I am not familiar with Mu, but make sure to install LabJackPython to the version of Python it uses. If you used pip to install Mu, use that same pip to install LabJackPython.

egg's picture
Thanks much for getting back,

Thanks much for getting back, i ended up formatting the SD card and freshly installed all of the software.  the second time around things made more sense to me, and i can view analog values now with u3allio. 

I had to get libusb going with $ sudo apt-get-upgrade, sudo apt-get update, sudo apt-get install libusb-1.0-0-dev

Everything else worked great

thanks again!


egg's picture
So i was able to get the

So i was able to get the examples in the exodriver-master folder to work, but now that i have installed LabJackPython, it is giving me the error (missing or invalid integer value argument that specifies the number of analog inputs).  I am using Geany if that matters.

I have tried to change some values in this code to set the number of analog inupts, but nothing seems to work for me..

Thanks again for your time.

LabJack Support
labjack support's picture
I assume you mean the u3allio

I assume you mean the example. When running that example, the first command line argument specifies the number of analog inputs, otherwise you will get the error you mentioned. For example, this runs it with 4 analog inputs (AIN0-AIN3):

python 4

If you are going to modify it to not use command line arguments and hard code the number of analog inputs, replace this code:

    numChannels = int(sys.argv[1])
    print("Missing or invalid integer value argument that specifies the number of analog inputs.")

With something like this (4 analog inputs for this demonstration):

numChannels = 4

egg's picture
ya, that worked perfectly,

ya, that worked perfectly, thanks much. 

Do you know of any examples i can look at to continuously display an analog input, and record it to a .xls or similar file?  What I am trying to do eventually is set up this U3 in the field with a pressure transducer to measure lube oil pressure on a piece of machinery.  I'd like for it to record data to a file for say 15 minutes, and overwrite itself, but during an event of low pressure, record for 5 more minutes, and then save that file seperately, at the same time opening and recording to a new file for the next time the event happens.

This seems like it might be a common task for this kind of setup, and know this is very specific, but I am hoping i can put enough together to make it happen.  It seems likely that i am in a bit over my head here, but if there is any info you can point me towards, I'd really appreciate it.  Even if it's a python for begginers course :)

I will continue to look through the low level data-sheet in the meantime.

LabJack Support
labjack support's picture
We don't have an example

We don't have an example specific for that, but getting continuous analog input readings would involve a loop that performs readings. performs 1000 readings in a loop by default. You can display to the console output (print) for a simple display of the readings. If you want to control the rate of readings, a simple method is to put a delay in the loop (time.sleep). So say a reading every second, put a 1 second delay in the loop. Alternatively for running code at a timed interval you can use could use a Timer:

For writing to a file, take a look at this Python doc:

If you save data in a comma separated (csv) text format, you can import it to Excel or other spreadsheet. For an Excel file (xls), you would need to find a Python library/module for that.

To keep track of time, there are various functions to get the current time. Here is the documentation from the time module:

To have a loop run for say 15 minutes performing readings, you can have a start time before the loop and in the loop check the current time to see if 15 minutes elapsed, or before the loop calculate the time 15 minutes from now and in the loop check if the current time is greater than that.  Here is a Stack Overflow discussion that goes over ways to do this (their answers lean towards the second method I mentioned):

We have a LabJackPython quickstart for basics with a U3:

We do not provide general Python programming tutorials, but here is a good place to start for learning Python: