i2c pyb or machine for sgp30 adafruit sensor?

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
IHOXOHI
Posts: 17
Joined: Sat Apr 25, 2020 7:31 am

i2c pyb or machine for sgp30 adafruit sensor?

Post by IHOXOHI » Sat May 09, 2020 6:58 am

Hi,
I have tried to use the sgp30 sensor from adafruit... with a pyboard.
So, I have download the sgp30 lib from github, which indicate a procedure of installation with a i2c.MASTER command, and after, when the sensor is initiated, have to accept a "writeto" command.
I have use the i2c's machine installation without success. With Master parameter error...
The same issue with pyb's i2c. With writeto command error...
So, i2c'pyb accept master parameter but not writeto command, and i2c'smachine accept writeto command but not master parameter...

I don't know well i2c behaviour....
Maybe there is a simple way for resolve it...

Thanks.

User avatar
pythoncoder
Posts: 4149
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by pythoncoder » Sat May 09, 2020 10:46 am

I suggest you use the machine library and eliminate the i2c.MASTER arg. Slave mode is not supported by machine, so the argument is not accepted.
Peter Hinch

IHOXOHI
Posts: 17
Joined: Sat Apr 25, 2020 7:31 am

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by IHOXOHI » Sat May 09, 2020 1:35 pm

Hi Peter,

Thanks for your availability.

I have tried yet a command with i2cmachine without master parameter, but it doesn't works. The sensor isn't initiate on i2c canal.
I have tried too this solution : viewtopic.php?f=6&t=3250&p=24707&hilit= ... ine#p24707. It doesn't work too.
I have tried other i2cmachine command's write, alls without success.

When I used pyb, the sensor looks initiate correctly on i2c canal. I have his i2c adress. But when I tried to initiate the object, I have the "writeto" error.

So maybe I could try to replace "i2cmaster" by "i2c" in the sensor library?
Or change "i2c.writeto" by "write.mem_write" and use pyb librarie?
...?
I will try ...

Thanks for your support.
Best.

User avatar
pythoncoder
Posts: 4149
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by pythoncoder » Sun May 10, 2020 10:23 am

It would help if you gave us a link to the library you are using.
Peter Hinch

IHOXOHI
Posts: 17
Joined: Sat Apr 25, 2020 7:31 am

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by IHOXOHI » Tue May 12, 2020 9:38 am

Hi,

I use the only one library that I have found for sgp30 and micropython:
https://github.com/alexmrqt/micropython-sgp30
... Maybe you have an other one which wok fine, like for uv sensor that I can use now until I have found a good advise in this forum about this uv sensor, which need an other libarary than the first one that I have found about SI1145 sensor and micropython.

Thanks.

User avatar
pythoncoder
Posts: 4149
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by pythoncoder » Wed May 13, 2020 6:03 am

That driver has evidently been adapted from the Adafruit one to work with MicroPython. At a glance the driver itself looks plausible, but the test program looks wrong. Aside from the I2C.MASTER which should be eliminated, the I2C bus number of 0 is wrong. Pyboard I2C buses are numbered 1 and 2.
Peter Hinch

IHOXOHI
Posts: 17
Joined: Sat Apr 25, 2020 7:31 am

Re: i2c pyb or machine for sgp30 adafruit sensor?

Post by IHOXOHI » Fri May 15, 2020 6:19 am

Hi,

Yes for sure.

So, how can I change this sgp30 lib for that it works with a pyboard?

Thanks.

Post Reply