Using a SSD1306 Oled display with the Moteino

Started by Jacco, September 05, 2013, 03:18:53 AM

Jacco

Hi,

I want to use a SSD1306 Oled display from adafruit (http://www.adafruit.com/products/326#Description)

This display works with my UNO board but i can't get it to work with the Moteino. The display only shows text or graphics after power on and then freezes. So it won't show a next line of text or graphic. If i reset the board then it won't show anything at all (have to power cycle it).

Any idea what the problem might be and how to solve?

Kind regards,
Jacco

Felix

Hi Jacco. That display needs 5V power. Looks like they have an onboard regulator which brings that down to 3.3V for the display to operate with.

Other than that it should really work the same. Arduino UNO has the same chip as Moteino R2/R3, except Moteino is all 3.3V including data signals. So that might be a problem if that board divides the data lines from 5V to 3.3V - then if you connect 3.3V data lines those would get divided lower and would be invalid signals.

Here's what the Adafruit description of that OLED includes, confirming what I said before:

The driver chip, SSD1306 can communicate in two ways: I2C or SPI. The OLED itself require a 3.3V power supply and 3.3V logic levels for communication, but we include a 3.3V regulator and all pins are fully level shifted so you can use with 5V devices!

So yeah - Moteino will send 3.3v signals which get divided by a 5/3.3 ratio, so those signals will be too low for the OLED to pick up. Too bad they don't have a 3.3V version without the regulator.
You could probably hack it and remove or bypass the onboard regulator and level shifting, but don't do it unless you know how to do that.

jaime1988

#2
Hi Jacco,

I have the following OLED display based on the SSD1306 which should be equivalent to Adafruit's display:

http://www.ebay.es/itm/161051456501?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

I made the following conections:



MoteinoOled
13RES
12CS
11DC
10SCL/CLK
9SDA/DATA
GND
3V3
3.3VGND

I used the libraries from adafruit and the example ssd1306_128x64_spi and It works perfect. As I said before, the modules should be equivalent.
Are you using the same configuration/libraries?


Moteino R2 + SSD1306 OLED display by FelixRusu, on Flickr


Moteino R2 + SSD1306 OLED display by FelixRusu, on Flickr

Jacco

Hi Guys,

If i read the description on the adafruit site it says "It's easier than ever to connect directly to your 3V or 5V microcontroller without needing any kind of level shifter!". So you should think (at least i do) that it works out of the box with the 3.3V Moteino R3.
I had a Bi-Directional Level shifter lying around so i used that to hook on the Oled at 5V...still no luck.

The OLED on ebay looks indeed the same. I've already tried the example ssd1306_128x64_spi. This works but only after a power cycle. A reset (or upload) and the OLED stays black.

If a take a working sketch and i include the libraries for the OLED and only declare the class (no code to use it), my sketch stops working. Serial.println won't show the welcome message and that is the first instruction. And that is even without wiring the display.

@jaime: did you try anything else than the example.
Also, are we allowed the use pin 10 as that is SS of the radio?

Thanks for your help so far.

Jacco

jaime1988

Hi,

I'm sorry but I don't understand correctly your problem. Can you explain the process? i.e: 1. upload sketch and working, 2. reset and doesn't work....

I haven't done much testing due to time issues, sorry. If you want me to try some scketch it's ok for me, post it and I try.

About pin 10, you are almost right. Both modules (SSD1306 and RFMXX) uses SPI. SPI allows multiple devices using the same bus, the "active" module is the one with they SS low. So if you want to use both modules, you need to modify one library to use a diferent SS pin and do some manual control of the SS pins to assure that when you are using one module, the other's SS pin is in high.

I'm almost sure of this, but correct me if I'm wrong.

Jacco

#5
Hi,

Thanks for your offer to try the sketch.

I put an ATMega328 on a breadbord, hooked up the oled and let the processor and display run at 3.3V.
Loaded the examples of different SSD1306 libraries. They all works fine.
This confirms that the Moteino running at 3.3V should also work.

I loaded the test sketch in the Moteino R3 and the sketch runs fine with oled display showing correct information.
One thing behaves differently though, after loading the sketch in my UNO on a breadboard the sketch starts running with the display working. After a reset it works ok.
On the Motino, the sketch starts running after I load it but the display is dead. After a power cycle the sketch runs and the display is alive. After a reset...display is dead again.
But...I can live with that.

Then when I put in the code to initialize the radio (radio.initialize(FREQUENCY,NODEID,NETWORKID)) things go wrong.
After the init routine of the radio the display freezes.
The same behavior on the UNO on a breadboard (which doesn't have a RFM69 chip).

I attached my test sketch.

Any help is appreciated.

Jacco

Felix

Your data lines look OK to me.
It might be possible that there is crosstalk on the MISO line. A simple check would be to put pulldown resistors on the MISO and MOSI lines, 10K values should be good.
Isn't that OLED also supposed to work on I2C? If so did you try that?

One thing to note is that Moteinos will also use SPI in the bootloader to check for a FLASH image on the FLASH chip, that's even if the FLASH chip is not present. So if the OLED is somehow sensitive to that then that might be an issue. I would start with the pulldown resistors as mentioned above.

I can't image power draw is an issue. Sounds to me like there's a problem with the SPI and the OLED.

Jacco

#7
Indeed it is a SPI conflict of some kind.

When any of the following lines get executed the display freezes (or garbage on screen):
  SPI.begin();
  
  do writeReg(REG_SYNCVALUE1, 0xaa); while (readReg(REG_SYNCVALUE1) != 0xaa);
  do writeReg(REG_SYNCVALUE1, 0x55); while (readReg(REG_SYNCVALUE1) != 0x55);
  
  for (byte i = 0; CONFIG[i][0] != 255; i++)
    writeReg(CONFIG[i][0], CONFIG[i][1]);

  setHighPower(_isRFM69HW); //called regardless if it's a RFM69W or RFM69HW
  setMode(RF69_MODE_STANDBY);
  while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // Wait for ModeReady


Tried the 10K pulldown resistors. Didn't help. B.t.w. I'm testing an a UNO now. That has no RFM chip and no Moteino bootloader.

I avoided a possible power problem by also using an external power source.

Now trying the I2C option...

Thanks,
Jacco

Jacco

...pulling my hair out here.

With I2C is doesn't work either. Display stops when the radio gets initialized. That is not really since I'm using an UNO without radio.

Thanks,
Jacco

Felix

Since it's an Adafruit product and Jaime has his OLED working, maybe someone in Adafruit's forum has had similar issues...?
Perhaps hooking up a logic analyzer would shed some light on what's happening on that SPI bus.

Jacco

#10
I posted this issue also in the Arduino forum...

I'm wondering if Jaime tried it in combination with the RFM69? I think he just tried the Adafruit example. Did you Jaime?
Unfortunately I don't have a logic analyzer so that's no option.
What I find strange is that when I use the I2C option it still doesn't work. SPI couldn't be the problem then? Or can it?

Tried something else...

I had two RFM12B radio's that I didn't use, connected them to two UNO's, one of them with the display (I2C).
Loaded the sketch, change the library form RFM69 to RFM12B...and it works. :D
But, it was quite late last night so I didn't have time to check stability.
The question is then, why does it work with the RFM12B library and not the RFM69? I hope I can figure this out since I have two Moteino R3's and no R2's.

Thanks for your help so far.
Jacco

Jacco

I'm a little bit further...
Build my project (ATMega328, RFM12B and SSD 1306 Oled) on a breadboard and got it working as designed.

When a change the library from RFM12B to RFM69 (and leave the radio or remove it. I have no spare RFM69) the sketch hangs after the radio.Initialize.
The result is the same when I build the project with a Moteino R3.

Is there something you guys can think of what could be the problem.

Thanks,
Jacco

Felix

Did it work at 3.3V on the breadboard?
Does your Moteino R3 have a FLASH chip?

So it works with RFM12B but not with the RFM69W...

A logic analyzer would be perfect, would solve this issue almost 99% of the time.
Without basic tools to investigate the wires it's almost impossible to speculate and guess your way into solving problems like this.

Jacco

Yes I work with 3.3V on the breadboard.
I have two Moteino R3, one with and one without a Flash chip. Results are the same.
Yes it works with the RFM12B and not with the RFM69W.

Hmmm...I don't have an analyzer so that route isn't an option for me.
So I'm stuck for now. :(

The easiest (and probably only) way for me is to order two Moteino R2's ;)
 

Felix

A logic analyzer is a really nice tool to have when doing electronics.
They say it needs 1K of ram on the MCU since it's a buffered display. I'm wondering if that's a problem. The RFM69W might require more RAM than RFM12B.

I looked a little at the datasheets and it looks like it's using quite a bit of power, unusual for such a small OLED display which I believe is more power efficient than non-OLED displays.
It's also not very cheap...

Really not sure what else to suggest. I feel like a mechanic trying to diagnose a car problem over the phone :)