Cubecell AB02 I2C sensor and display combination

Hi,

I have been using a cubecell AB02 with some I2C sensors on LoRaWan for some time. It was battery driven but now it will be using external power so I decided to turn the display on permanent and display some sensor values. Regretfully I can not get it to work. The sensors are on the second I2C and in the past I used wire.begin(500000,1); and it was working fine. But together with the display I can’t get it to work.

First there was the issue with display being defined twice but I solved that with the “extern SH1107Wire display;”

But after that I still can not get it working. Both can work (depending which I call first) but once 1 has worked, the other one can not work anymore.

I also took a look at the LoRaWan_OLED example but that looks quite different and has specific LoRaWan.display() functions. Also a lot less lib are included.

Could you please help me how to call the Wire.begin and which files need to be included to combine sensor data, a display function and LoRaWan?

Best regards

Could you explain me how to call both I2C’s and which

hi,

please refer these:

Wire.begin();// Initialize and use the first group of IIC

Wire1.begin();// Initialize and use the Second group of IIC

Hi Jason,

Thank you for your fast reply.

I tried that, but with Wire1.begin() it doesn’t see the sensors.
If I put Wire.begin(1000000,1); it does see the sensor.

So I put either:
Wire.begin();
Wire.begin(100000,1);

Or
Wire.begin(100000,0);
Wire.begin(100000,1);

The sensor is working and the display too. But as soon as the display is init the sensor stops working. I placed the display.init() at various locations in the code and result was always the same: sensors are working, display is working, but after display.init() sensors stop (and program to because it needs sensor).

By putting a new Wire.begin(100000,1); in the code after using the display , it seems to work. But I guess this should not be needed and it seems a bit unstable.

I will try some other options

I went back to another project, on an AB01 and experienced same kind off problems with an SGP30 and en SHT3x sensor.
I believe the problem is related to the sleep mode (I saw more people has issues) but I couldn’t find the solution.

I tried wire.begin and wire.end in the prepareTxFrame (although I also have wire.begin() in setup but that doesn’t help.

If I change my script by taking out the loop() for LoRaWan (and thus canceling sleepmode) and rename my prepareTxFrame() function loop() the code us running fine, of course without Lora so can use it, but it is showing it is related to the Lora loop and probably to sleepmode.

As it is USB powered, I’ll try to take out sleepmode. Any tips on that?

OK,

I found the problem and it was unexpected: LORAWAN AT Support was on!! I always use the dropdown menu under tools to put all my lorawan settings and switch off AT support (and I’m doing it every time I change boards or start Arduino. Is there a work around for it?) but I forgot this time.

So apparently if you don’t switch it off it can the serial debugging of Arduino can mess things up!!

1 Like