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

CPX accelerometer example won't work with OLED I2C example
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CPX accelerometer example won't work with OLED I2C example

by petespaco on Thu Mar 26, 2020 1:06 pm

I can't get the CP/CPX accelerometer example function to work with the Arduino OLED I2C 128x64 example. FWIW, the OLED uses 0x3c for the I2C address and I have fixed that in the appropriate XXX.h file.
When the program encounters these statements:
X = CircuitPlayground.motionX();
Y = CircuitPlayground.motionY();
Z = CircuitPlayground.motionZ();
it stops dead in its tracks.
If I comment them out, then that function completes, and the whole sketch does exactly what I told it to do.
Funny thing is, those statements DO execute normally in a CPX sketch that contains eight of the examples from the CP/CPX example list.

I have checked and rechecked for any code differences between the sketch that works and the one that does not.
? Is there any history of a conflict in this area?[/code]

I have attached a file that demonstrates the issue.
Sorry about the size of it, but I left most of the OLED example in there so I wouldn't screw anything else up.
Attachments
CPX_Temp_Accel_OLED.ino
(13.86 KiB) Downloaded 2 times

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Thu Mar 26, 2020 1:15 pm

FWIW, the OLED uses 0x3c for the I2C address and I have fixed that in the appropriate XXX.h file.

Which header files did you modify? You can specify the I2C address in the call to begin:
https://github.com/adafruit/Adafruit_SS ... 306.h#L143
so should be done in this line:
Code: Select all | TOGGLE FULL SIZE
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64

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

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Thu Mar 26, 2020 4:07 pm

Adafruit_SSD1306.h

However, the since the OLED stuff does work, I must have gotten the right one,didn't I?

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Thu Mar 26, 2020 4:48 pm

You are using a Circuit Playground Express, correct? Can you link to the specific OLED product you are also using.

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

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Thu Mar 26, 2020 8:21 pm

Here's the source for the OLED display:
https://usa.banggood.com/0_96-Inch-4Pin ... rehouse=CN

In my own defense, I did buy the CPX from you guys!!!

Pete Stanaitis
--------------------

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Fri Mar 27, 2020 12:53 pm

Yah, don't know. Maybe there aren't pull resistors on the I2C lines for that module? Maybe it's not actually an SSD1306 even though they say it is? Or could just be a bad display?

We can help you with the CPX, but we don't know anything about that OLED display.

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

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Fri Mar 27, 2020 1:04 pm

Okay, so I will buy one from you.
Please suggest a product number for me to get.

Pete Stanaitis
--------------------

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Fri Mar 27, 2020 1:07 pm

Sure - do you want something that's essentially equivalent to that one? Maybe describe what you are trying to do - that way we could better suggest a specific product. We have lots of options.

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

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Fri Mar 27, 2020 3:34 pm

I like the 128x64 model.
It has to be I2C because the CPX can't handle SPI if I understand correctly.
Monochrome is okay.
I'd have no trouble using a display larger than the one I mentioned (from a cost standpoint), but my goal is to keep it small and uncluttered-looking.

This whole thing is simply to be a demonstration project where I show off the CPX doing a whole bunch of things "at once" with nothing (but a small display) connected to it.
As it was before I tried to add the OLED, for any output other than the speaker and Neopixel display, the only way an observer could know what was going on was to look at the serial monitor.
By having the tiny OLED display, an observer can see all the action of the accelerometer, sound sensor,
So the eventual goal for this project is to send results from the:
-Light Sensor
-Sound Sensor
-Accelerometer, 3 axes
-Left and Right Buttons
-Temperature Sensor
-----to the display in some format.
I'd use text size 1, even though it's tough to read.

I just wanted to show it at our next little Arduino meeting, but there's no real rush since our meeting place (local library) is closed for the duration.
However, I'd like to get this issue behind me so I can go on to other things.

One last issue: On one of my first attempts to integrate the OLED with the CP/CPX, I tried adding OLED code to the CP/CPX sketch that I had written.
(That's the opposite of what I am doing here, right?)
That one didn't work correctly either.
I almost gave up trying to get it to compile.
Then I started commenting "display" related statement out.
Once I had finally gotten what was left to compile:
The first thing I noticed was that I could NOT get the left button state to react to a button press. It showed up as "DOWN" all the time. Of course, previous versions, without the OLED code, worked just fine.

Pete Stanaitis
--------------------

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Fri Mar 27, 2020 6:05 pm

Additional info relating to this comment in my last post:
"On one of my first attempts to integrate the OLED with the CP/CPX, I tried adding OLED code to the CP/CPX sketch that I had written"
I attach that file.

Pete Stanaitis
--------------------
Attachments
Hello_CPX_Testing_Several_Functions_At-Once_Star_Wars_Rev4_OLED.ino
(11.35 KiB) Downloaded 5 times

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Mon Mar 30, 2020 2:40 pm

For the display, check out this option:
https://www.adafruit.com/product/4367

For the button issue, let's sanity check with a simple test sketch. Do the buttons work OK with this sketch?
https://github.com/adafruit/Adafruit_Ci ... uttons.ino

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

Re: CPX accelerometer example won't work with OLED I2C examp

by petespaco on Tue Mar 31, 2020 9:52 pm

Thank you, adafruit support Carter.

I ordered the product that you suggested.

The buttons worked just fine in the sketch that I am submitting with this post.

Pete Stanaitis
-------------------
Attachments
Hello_CPX_Testing_Several_Functions_At-Once_Star_Wars_Rev3.ino
(7.91 KiB) Downloaded 1 time

petespaco
 
Posts: 96
Joined: Thu Apr 19, 2012 7:53 pm
Location: west central wisconsin

Re: CPX accelerometer example won't work with OLED I2C examp

by adafruit_support_carter on Wed Apr 01, 2020 11:52 am

Cool, glad that info helped. Just FYI - if you ordered directly from Adafruit we are currently unable to ship items right now. Our best option right now is to suggest checking with Digikey or another reseller.

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

Please be positive and constructive with your questions and comments.