Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Itsy M0 i2c scan code inconsistant results
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Itsy M0 i2c scan code inconsistant results

by hawleyw on Wed Aug 12, 2020 3:09 pm

Board is working, yes.
Tracked down the weirdness with oled: sparkfun's library has a reset sequence.

I dumped that sequence into the scan code, before the loop where I am calling i2c.scan() and got one good read. Then I just moved it into the scan loop and am getting a consistent read of that address. The reset only seems to be called in the constructor for their library (void MicroOLED::begin()) so I'm not sure why I have to call it before each i2c.scan but it does give me the address each scan so that's progress.
https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library/blob/master/src/SFE_MicroOLED.cpp

I expect to poke around more in their library to figure it out, or to poke around in the adafruit library's and see if I can fork & modify them to handle that board. I have two of these boards left over from a couple of years ago and want to put them to use.

I can't quite figure out the best way to work on this. Both Mu and the arduinoIDE seem awkward because I am used to working in a terminal w/ vim, multiple files open plus saving my changes to (local) git. I'm happy to work in circuit python, micro python or cpp; python flavors are soo tempting because of the REPL but I can exercise by c braincells (which haven't gotten much of a workout since the late 80's) if that's the only way to dig in to the libraries/ help out. Is there any way to load my code files / code.py files / libaries into the repl, from the repl? or any suggestions on workflow for code(edit), git commit, compile (if in cpp), and copy to itsy / load to circuitpy drive?

hawleyw
 
Posts: 22
Joined: Mon Jan 18, 2016 4:15 pm

Re: Itsy M0 i2c scan code inconsistant results

by adafruit_support_carter on Wed Aug 12, 2020 3:29 pm

For CircuitPython, the only building that is done is if you are working on the core firmware:
https://learn.adafruit.com/building-cir ... troduction
That's all C code. It's pretty low level. Not something you'd typically need to worry about for general use, since pre-compiled firmware is available. But you can if you want. It's a very active open source project.

For writing CircuitPython code and libraries, it's just Python code. So use whatever text editor you like, vi, emacs, sed, butterflies, etc. Some have quirks though:
https://learn.adafruit.com/welcome-to-c ... 2977443-12

For contributing, yes, you'll want to use git. But also, you'll want to become familiar with GitHub. Good info here:
https://learn.adafruit.com/contribute-t ... and-github

FWIW - my setup is a combo of a graphical text editor (VSCode) and having multiple terminal windows open for doing things via CLI (git, linting, running make if building firmware, etc.). For connecting to REPL, I use screen.

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Re: Itsy M0 i2c scan code inconsistant results

by hawleyw on Fri Aug 14, 2020 4:18 pm

Ok. I am back to my original question/problem.
The itsyBitsy M0 is not consistently picking up the address of a sparkfun MicroOLED when I run a simple i2c bus scan in a loop. (.ino file / code is attached)
On some iterations through the loop it picks it up and on other iterations it does not.
The only library involved is the Wire library (plus a call to serial to print out the results)

I have run this code on an arduinoUNO, a sparkfun redboard and the itsy M0, simply moving the wires from one board to the other and recompiling/uploading via the arduino IDE. On the arduino and the redboard the i2c devices connect through a level shifter but on the itsy they connect directly. The results that I get are:

ItsyBitsy M0 --> detects the microOled as well as the adafruit bme280 on some loops but on other iterations through the loop it only detects the bme280.
ArduinoUno --> detects both the micro oled as well as the adafruit bme280 on every iteration through the loop.
SparkFun Redboard --> detects the micro oled as well as the adafruit bme280 on every iteration through the loop.

Along the way I have discovered that if I connect the reset pin from the oled to the board and add the reset procedure inside the loop (ie its being performed every time through the loop), I can get the itsy to pickup the address consistently but that seems like a superstitious ritual not based on any documented need. The scan runs fine on the uno and redboard without the reset pin attached or diddled.

There must be something different about the itsy or its firmware which is causing this and I would like you to know that it is happening and I'd also like to know the most minimal/correct way to get rid of this intermittent bug.

I have posted to the sparkfun support board but haven't gotten any real ideas and since the oled works fine with the arduino as well their redboard, they are likely to say it's an itsy problem/feature...

Hoping you can help.
Respectfully,
Hawley
Attachments
sketch_aug09b.ino
(1.47 KiB) Not downloaded yet

hawleyw
 
Posts: 22
Joined: Mon Jan 18, 2016 4:15 pm

Re: Itsy M0 i2c scan code inconsistant results

by adafruit_support_carter on Mon Aug 17, 2020 12:16 pm

If you simply ignore the scanning not working as expected, does the OLED work otherwise?

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.