Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Error with reading and setting up voltage

2051 Views - Created 08/12/2018


Posted by:

fredsharifi Avatar

Hi, I'm a new user to Raspberry Pi, I bought this board to do some analog testing, I followed the setup instruction and when it comes to reading to setting a channel i get error calling the function (set_dac_voltage(1, 3.3) , Here is the error I get

>>>> adcdac.set_adc_refvoltage(3.3)

>>> set_dac_voltage(1, 3.3) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'set_dac_voltage' is not defined".

although the procedure is defined in the , How do I test the program to know if its communicating with the board?

Thank you


Posted by:

andrew Avatar

United Kingdom

andrew Twitter  andrew Website  


Can you try running one of the demo scripts in the python library demos folder? You can find a copy at

If the demos fail to run then you may need to go through our SPI tutorial to make sure the SPI bus is configured correctly.

One reason for the code failing with the "not defined" error could be that the library can not be found by your code. Try putting in the same folder as your code and import it with "from ADCDACPi import ADCDACPi".


Posted by:

fredsharifi Avatar

Thanks for the suggestion, I followed the instruction for the python command line inteface without running any specifit python program; the link to the instruction I found :

the import instruction is working fine, the mode instruction is working fine, setting up max ref voltage works fine, only when trying to read or write is where I get the error, the SPI interface is set to enable, I solder the pin header and nothing else, and plug into the IO Pin socket.

here is the copy of the python command line interface:

>>> from ADCDACPi import ADCDACPi
>>> adcdac = ADCDACPi(2)
>>> adcdac.set_adc_refvoltage(3.3)
>>> read_adc_raw(1, 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'read_adc_raw' is not defined


Posted by:

fredsharifi Avatar

Thanks again for the suggestion, I ran the demo as you suggested and its working and Im getting values. I guess it just does not work with command line interface. thanks again.

Sign in to post your reply

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view.
Download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.