Go Down

Topic: oled malfunction (Read 368 times) previous topic - next topic


Jan 18, 2019, 07:34 am Last Edit: Jan 18, 2019, 08:43 am by kintoun75
Hello i need help
When i add Adafruit_SSD1306.h and run display
BC95Udp.h can't work
Thank you.


Mycode :

Code: [Select]

#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Wire.h>

#include <Arduino.h>
#include <ArduinoJson.h>
#include <AltSoftSerial.h>
#include "BC95Udp.h"
#include "EmonLib.h"
#include <Dns.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

AltSoftSerial bc95serial;

BC95UDP udpclient;
uint8_t buff[64];
DNSClient dns;
IPAddress remoteip;

int x;
void setup() {

    while (!BC95.attachNetwork()) {

    dns.getHostByName("ddns name", remoteip);
    Serial.print(F("NB-IOT module IP address : "));
    udpclient.beginPacket(remoteip, 55555);

    display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize I2C addr 0x3c
    display.clearDisplay(); // clears the screen and buffer
void loop() {

  char text[100];
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["S0"] = "50";
  root["S1"] = "69";
  root["S2"] = "99";
  root["S3"] = "78";
  root["S4"] = "25";
        Serial.println("\n\nSending UDP payload : ");


         size_t len = udpclient.read(buff,64);
         Serial.println(F("\n\nReceive UDP payload : "));
         printHEX(buff, len);
String str_char(char val[]){
  String str_a;
  for(int i=0;i<strlen(val);i++){
    str_a += val[i];
  return str_a;
void printHEX(uint8_t *buff, size_t len) {
    char myStr[len];
    String aaa;
    for (int i=0; i<len; i++) {
        if (buff[i]<16) Serial.print(" 0");
        else Serial.print(" | ");


Jan 18, 2019, 08:22 am Last Edit: Jan 18, 2019, 08:24 am by groundFungus
Read the how to use the forum-please read sticky to see how to properly post code.

What do you mean by "It doesn't work with the BC95 NB-IOT library".  Are there compile errors?


When i add Adafruit_SSD1306.h and run display
BC95Udp.h can't work


And if you try the IOT shield by itself does it work?


Jan 18, 2019, 08:49 am Last Edit: Jan 18, 2019, 08:52 am by kintoun75
It works normally well.
When running the display command, BC95 will be restarted repeatedly.


1024 Bytes of display buffer, 200 Bytes of JSON buffer, and then some more dynamic memory usage by the BC95 library. I wouldn't call it a surprise ...


I would like advice  :(  :(


My guess is that you're running out of RAM. The display uses more than 50% of the RAM on an Arduino UNO.
The BC95 library seems to be using dynamic memory allocation, that'll fail when there's not enough memory.

 What board are you using?


Arduino UNO
what should I adjust?


what should I adjust?
Nothing. If you need such a large amount of memory, you need a microcontroller that has more memory.

You could try to use smaller buffers where you can, also make the JSON buffer static or global, so the compiler can tell you how much memory you're using.

There are some libraries for the SSD1306 without a RAM buffer, but they don't have as many features.


I just want to show the character Do you have an example of an SSD1306 library that doesn't have RAM?


It works. Thank you.

Go Up