value = analogRead(0) #read the ADC value of channel 0
analogWrite(value) # write ADC value
voltage = value / 255.0 * 3.3 # calculate voltage value
print ('ADC Value : %d, Voltage : %.2f'%(value,voltage))
time.sleep(0.01)
That is System Management Bus.This module defines an object type that allows SMBus transactions on
hosts running the Linux kernel. The host kernel must have I2C support, I2C device interface support, and a
bus adapter driver. All of these can be either built-in to the kernel, or loaded from modules.
In Python, you can use help(smbus) to view the relevant function and their descriptions.
bus=smbus.SMBus(1):Create an SMBus class object.
bus.read_byte_data(address,cmd+chn): Read a byte of data from an address and return it.
bus.write_byte_data(address,cmd,value): Write a byte of data to an address.