PiicoDev on the LoPy4

Hi everyone!

I’ve been tinkering with the LoPy4(ESP32 based MC) recently and have been trying to get the PiicoDev sensors working with it.
I started by installing and trying the Unfied libraries on the RPi Pico’s tutorial page for the VEML6030 and uploaded the files straight from the links, which resulted in the following error.

Confirmed that it was connected using i2c.scan() which showed the correct address. (0x10)

I’m not super well versed in how I2C works so was wondering if the lovely people from Core or the community could help out? :smiley:

Here’s the wiring

PS: Here’s a cool idea that you could work into a way to get the PiicoDev range working with the Pycom expansion board since the pins on the ESP32 are configurable.

Source: Pycom DS3231 RTC - mindeon

Unrelated side note: Has anyone found any superb documentation on getting a LoPy up and running with TTS, I haven’t been able to get connected to a gateway as of yet.

PS: I love the Factory episodes and seeing everything you guys make go open-source!



Hey @Liam120347 - rad to see you’re breaking out of the PiicoDev sandbox and tinkering on other platforms.
First things, are you using a freshly downloaded copy of the Unified and VEML6030 files?
If not, get them from the tutorial and let me know what happens.

Next, in the REPL run these commands and let me know what the output is:

import os

This is a crucial step in the Unified Library in identifying what kind of development platform we’re running on eg. on a Raspberry Pi Pico the output will be ‘rp2’ (because RP2040).

It looks like the call to i2c.writeto inside UnifiedWrite is the culprit.
Perhaps we’ll need a couple of changes to port PiicoDev for Pycom! The best I can think of right now is that the i2c.writeto implementation is slightly different. I’ve found the stop condition is positional in rp2 micropython, but here the complaint is that there is an additional positional argument. So let’s make it a keyword argument.
Let’s try something:
In PiicoDev_Unified.py we’re going to modify the UnifiedWrite function by changing line 81 from:
self.i2c.writeto(addr, buf, stop)
self.i2c.writeto(addr, buf, stop=stop)

I’ll bust out a Pycom of my own really soon and begin work on a Pycom port as soon as possible :wink:
If you find the proposed change works, open a pull request on the repo! We’d love to recognise your contribution!



It’s been awesome, absolutely amazing work Michael, the whole unified experience is great!

Yeah, I had to double check again but I can confirm that the error pops up with the unaltered code.

From the OS commands here’s the output:

Unfortunately modifying the line didn’t work straight out of the gate. No worries though this is an excellent chance to learn - and hopefully contribute!
I’m keen as for what’s coming :smiley:

Saucy documentation

Pycom’s machine-I2C: https://docs.pycom.io/firmwareapi/pycom/machine/i2c/
Looks suspiciously like the stock-standard implementation: class I2C – a two-wire serial protocol — MicroPython 1.16 documentation
Also no mention of there being any specific changes between the chips(pic below)
VEML6030 - registers and addresses: https://www.vishay.com/docs/84367/designingveml6030.pdf


@Liam120347 I updated the PiicoDev_VEML6030.py module code so it should now work out-of-the-box with LoPy on i2c bus 0.

If you were to follow the tutorial from the start redownload that file you should be golden :+1:
As a short cut, here’s a link that you can right-click and save link as…

If you’re interested in the details, here’s the commit.
It seems that LoPy’s implementation of MicroPython does not support a stop-condition argument in its i2c.writeto() function. See the docs
I changed the bus operations to use our more general-case readfrom_mem() and writeto_mem() Unified functions. It seems that this will be the better method to proceed with in general.

We’ll roll this knowledge into a not-too-distant PiicoDev update.
Happy making!


Hey Michael,

Awesome! Thanks for the help, I can confirm that one is up and running now!!