Blank LCD after #include "rpcWiFi.h"

Hello! I have a problem with getting WiFi functionality in a project for my Wio Terminal. I started with making the Seeed BME680 sensor work on it, this was possible by changing the code from Lesson 12 of the Wio Terminal wiki.

This is the code I use:

#include “seeed_bme680.h”
#include “TFT_eSPI.h” //TFT LCD library

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define IIC_ADDR uint8_t(0x76)

TFT_eSPI tft; //Initializing TFT LCD
TFT_eSprite spr = TFT_eSprite(&tft); //Initializing buffer

/** NOTE!!! Select the communication protocol correctly **/

Seeed_BME680 bme680(IIC_ADDR); /* IIC PROTOCOL /
//Seeed_BME680 bme680; /
SPI PROTOCOL */
//Seeed_BME680 bme680(BME_CS, BME_MOSI, BME_MISO, BME_SCK);/SPI PROTOCOL/

void setup() {
delay(100);
while (!bme680.init()) {
Serial.println(“bme680 init failed ! can’t find device!”);
delay(10000);
}
tft.begin(); //Start TFT LCD
tft.setRotation(3); //Set TFT LCD rotation
spr.createSprite(TFT_HEIGHT,TFT_WIDTH); //Create buffer
}

void loop() {

//Setting the title header 

spr.fillSprite(TFT_WHITE); //Fill background with white color
spr.fillRect(0,0,320,50,TFT_DARKGREEN); //Rectangle fill with dark green
spr.setTextColor(TFT_WHITE); //Setting text color
spr.setTextSize(3); //Setting text size
spr.drawString(“BME680”,50,15); //Drawing a text string

spr.drawFastVLine(150,50,190,TFT_DARKGREEN); //Drawing verticle line
spr.drawFastHLine(0,140,320,TFT_DARKGREEN); //Drawing horizontal line

//Setting temperature

spr.setTextColor(TFT_BLACK);
spr.setTextSize(2);
spr.drawString(“Temperature”,10,65);
spr.setTextSize(2);
spr.drawNumber(bme680.sensor_result_value.temperature,10,95); //Display temperature values
spr.drawString(“C”,80,95);

//Setting humidity

spr.setTextSize(2);
spr.drawString(“Humidity”,10,160);
spr.setTextSize(2);
spr.drawNumber(bme680.sensor_result_value.humidity,10,190); //Display humidity values
spr.drawString("%RH",80,190);

//Setting pressure
spr.setTextSize(2);
spr.drawString(“Pressure”,160,65);
spr.setTextSize(2);
spr.drawNumber(bme680.sensor_result_value.pressure / 100,160,95); //Display sensor values as percentage
spr.drawString(“hPa”,230,95);

//Setting gas
spr.setTextSize(2);
spr.drawString(“Gas”,160,160);
spr.setTextSize(2);
spr.drawNumber(bme680.sensor_result_value.gas / 1000,160,190); //Display sensor values as percentage
spr.drawString(“KohmS”,230,190);

spr.pushSprite(0,0); //Push to LCD
delay(50);

if (bme680.read_sensor_data()) {
    Serial.println("Failed to perform reading :(");
    return;
}
Serial.print("temperature ===>> ");
Serial.print(bme680.sensor_result_value.temperature);
Serial.println(" C");

Serial.print("pressure ===>> ");
Serial.print(bme680.sensor_result_value.pressure / 1000.0);
Serial.println(" KPa");

Serial.print("humidity ===>> ");
Serial.print(bme680.sensor_result_value.humidity);
Serial.println(" %");

Serial.print("gas ===>> ");
Serial.print(bme680.sensor_result_value.gas / 1000.0);
Serial.println(" Kohms");

Serial.println();
Serial.println();

delay(2000);

}

Now I want the Wio Terminal to connect to my MQTT server to send the BME680 values, however, after the first step, which is for me to add the line #include "rpcWiFi.h" to my code, I have the problem that the LCD screen stays blank after uploading the code, which doesn’t work for me as I also want to use the LCD screen as before.

Does anybody have an idea how to solve this problem?

Im also facing this issue,once i update with latest wifi firmware, that tft lcd library not working, but other lovyan gft are working…

Thank you for the tip with the lovyan gfx, sadly it’s not a good option for me since I would have to change the code a lot, and I don’t have enough experience for that. I just emailed support and hope they get back to me, last time they did but it takes some time. I will keep you updated!

Support answered me and recommended to upgrade or downgrade the board manager of Seeed SAMD to 1.8.1. So I downgraded it from 1.8.2 to 1.8.1 but the problem still remains in my setup (so I contacted support again), maybe it works for you?

Hello, Placebo83!
We tested the Wio Terminal with LovyanGFX with rpcWiFi, it can work. So I recommend you to downgrade the board support file in Board Management to 1.8.1 and use LovyanGFX.
Our Seeed_Arduino_LCD library is the same as TFT_eSPI, so it is easy to copy the source code to LovyanGFX.
Here is the document of how to use LovyanGFX. https://lang-ship.com/blog/work/lovyangfx-1/ Although it is Japanese.

Best wishes.

Thanks for your suggestion, once i tried, will inform

So TFT_eSPI not gone a work…am i right

TFT_eSPI is not going to function in combination with rpcWIFI I guess, which sucks but nothing to do.

I was really pissed off first, as I have spent the last two days with pixel-level placing a complex interface with TFT_eSPI, and it disappeared when rpcWifi.h was included.

Dig a bit deeper into this, and it looks like the underlying cause is that rpcWifi.h fragments the RAM so much that a contiguous buffer cannot be allocated anymore for a full screen sprite. 320x240x2 bytes eat up almost the entire RAM of the board.

The solution was to not use sprites at all, just use the functions of the TFT_eSPI instance that write into the video RAM directly. You may see a bit more blinking here and there, but it is not a big deal.

1 Like

Thx for this information, might help me in the future

I’ve the same problem above, spent hours optimizing graphics using sprites and now…all gone when I included rpcwifi.h !!!

Is there any news ? Seeed , can you help us ?

I really wouldn’t like to rewrite everything using LovyanGFX or disabling sprite (graphics too slow…)

I’ve read @lakshanthad advice to avoid using sprites or deleting them soon after use when using rpcwifi but, instead, I’d like NOT to use rpcwifi / rpcunified at all so my question here is: does anyone know other libraries to use wifi (RTL8720DN) on wio terminal ? perharps not based on freeRTOS (ram waster…) ?

Thanks

Well, changed TFT_eSPI to LovyanGFX but…surprise !!! It isn’t working when using sprites…

Simply including <rpcWiFi.h> get your screen blank, the only solution is to avoid sprites usage (that in my case provokes too much flickering)

Going on investigating how to swap rpcwifi/unified with something else but i’d like to have some hint from seeed