Hello,
I use 8-Channel 12-Bit ADC for Raspberry Pi (STM32F030) with Pi3B.
On your website the I2C address is shown as 0x04(default) but my pi tells me that it is 0x08 (with i2cdetect)
With 0x04 the python example program gives me an error message with 0x08 it works.
I have now 2.5 V connected to AD1 and GND but the example programm shows me 0 for every channel and I don’t understand why? I only run the example program with the changed i2c adress.
Maybe you can help me? Thank you in advance.
Regards
Thomas
Hi guys, due to the epidemic, the chip used on this product has been modified from STM32 to MM32, so the I2C address has also changed - the address has been changed from 0x04 to 0x08.
Please check which chip you received before using this product, if you are using MM32, please change the I2C address 0x04 to 0x08 in the adc.py file.
thank you for the answer,
I changed the adress in adc_8chan_12bit.py and adc.py
The communication works now I think (there are no error messages) but I still measure no voltage on the adcs and I don’t understand why?
If I execute adc_8chan_12bit.py I get 0 for every channel although there is a voltage of around 2.5 volts betwenn A1 and GND ? I can measure the voltage on the seeed card with multimeter
If i run adc.py I get the right values for channel 1 but not for adc_8chan_12bit.py and adc.py
I have same problem Raspberry Pi4 8GB and 8-Channel 12bit Raspberry Pi (STM32F030) v1.0.
I get all clean zeros even I have 1.5v on the input.
Has anyone solved this problem yet?
did you changed the I2C address from 0x04 to 0x08 ?
I had the same Problem. I don’t use the offical code from SeeedStudio. I used the i2c code from the c-periphery library. The STM32 Version of the baseboard worked fine. The MM32 Version didn’t work, not even after chanigng the adress. The STM32 code combined the “Write Register Adress” and “Read register Adress” into one transfer. This doesn’t work with the MM32. After Splitting it intwo two i2c transfer calls it worked perfectly.
Old Code:
/* Read byte at address 0x30 of STM32 */
uint8_t msg_addr[1] = { 0x30 }; // in percent (int 0-1000) channel0
uint8_t msg_data[2] = { 0xff, 0xff };
struct i2c_msg msgs[3] =
{
/* Write 8-bit address */
{ .addr = STM32_I2C_ADDRESS, .flags = 0, .len = 1, .buf = msg_addr },
/* Read 16-bit data */
{ .addr = STM32_I2C_ADDRESS, .flags = I2C_M_RD, .len = 2, .buf = msg_data},
};
/* Transfer a transaction with two I2C messages */
if (i2c_transfer(i2c, msgs, 2) < 0) {
fprintf(stderr, "i2c_transfer(): %s\n", i2c_errmsg(i2c));
exit(1);
}
New Code:
/* Read byte at address 0x30 of MM32*/
uint8_t msg_addr[1] = { 0x30}; // in percent (int 0-1000) channel0
uint8_t msg_data[2] = { 0xff, 0xff };
struct i2c_msg msgs[3] =
{
/* Write 8-bit address */
{ .addr = STM32_I2C_ADDRESS, .flags = 0, .len = 1, .buf = msg_addr },
/* Read 16-bit data */
{ .addr = STM32_I2C_ADDRESS, .flags = I2C_M_RD, .len = 2, .buf = msg_data},
};
//Split write and read into two transfers
/* Write register to read */
if (i2c_transfer(i2c, &msgs[0], 1) < 0) {
fprintf(stderr, "i2c_transfer(): %s\n", i2c_errmsg(i2c));
exit(1);
}
/* Read Adress */
if (i2c_transfer(i2c, &msgs[1], 1) < 0) {
fprintf(stderr, "i2c_transfer(): %s\n", i2c_errmsg(i2c));
exit(1);
}
I have also some zero instead right analog values.
Thanks for the new code L_H
I use python3 instead C so is there Someone with the same code in Python please ?
or may be there is now an update of the seedstudio library ?
I tried to split the functions as recommended but in Python but still obtain zero values.
any error in the code ? an idea ? thanks
ADC_DEFAULT_IIC_ADDR = 0X08
DC_CHAN_NUM = 8
REG_RAW_DATA_START = 0X10
REG_VOL_START = 0X20
REG_RTO_START = 0X30
REG_SET_ADDR = 0XC0
from periphery import I2C
Open i2c-0 controller
i2c = I2C("/dev/i2c-1")
dataRX = [0,0,0]
msgs = [I2C.Message(data=[REG_VOL_START],read=False,flags = 0 ), I2C.Message(data=dataRX,read=True, flags = 1)]
i2c.transfer(ADC_DEFAULT_IIC_ADDR, [msgs[0]])
i2c.transfer(ADC_DEFAULT_IIC_ADDR, [msgs[1]])
for i in range(0,len(msgs[1].data)):
print(hex(msgs[1].data[i]))
i2c.close()
Hello,
Is there any update on this topic ?
I also have been struggling with this ADC using python (smbus) and Asus Tinker 2S. But I still get zeros on every channel, even with split functions.
Thanks !
Are there any news for the adc?
I have here one of these adc but it always measures 0
Same problem for me.
Is there any update on this topic ?