problems with e-ink and nrf24l01 on one controller

Hi guys and girls!

I'm rather new to arduino handicraft. This is my first bigger project and shortly before finish I'm stuck :slightly_frowning_face:

Shortly about my project:
I have two devices: one measures weather conditions with a bme280 and transmits it with a nrf24l01, the second receives the information and displays it on an e-ink display.

The first device already works as planned. But I can't make the second one work.

I attach the wiring diagrams of both devices and the program code of the problem-maker. In the actual state it receives the information and processes it. But it does not show it on the display.
I tried the wiring only with the display, it worked then. As I use two SPI devices with some shared Pins I thought of a problem with Chip select (CS). And in fact I detected a problem there with a multimeter. So I did the CS manually. I also tried different ways of powering the circuit. Sadly there is no info about the current consumption of the e-ink display. The sheet only says "TBD".

Used components:

  • Controller: wemos d1 mini (both devices)
  • Sensor: BME280
  • Transmission: NRF24L01
  • Display: waveshare e-paper 2.7

Has anyone experience with such a circuit or has an advice for me?
I hope I didn't write to much blabla, if any information is still missing please tell me.

Thank everyone in advance for any advice!

Here is the code. I gues most of the lines aren't problem related as they are only message processing and the screen layout.

#include <SPI.h>
#include "RF24.h"
#include "nRF24L01.h"

#define ENABLE_GxEPD2_GFX 0

#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>


//Fuer NTP
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

#define ssid XXX
#define password XXX    

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

#if defined (ESP8266)
GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ 15, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
#endif

// Initialisierung fuer Funk
#define CE 16
#define CS 5
RF24 radio (CE, CS);
const byte address[6] = "00001";

int cs_radio = 5;
int cs_screen = 15;

void setup() {
  Serial.begin(19200);
  delay(100);

  Serial.println("Set CS");
  
  pinMode(cs_screen,OUTPUT);
  pinMode(cs_radio,OUTPUT);
  
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay (500);
  }
  Serial.println("WLAN verbunden");
      
  timeClient.begin();
  Serial.println("NTP initialisiert");

  digitalWrite(cs_radio, LOW);
  digitalWrite(cs_screen, HIGH);
  
  //Radio Initialisierung
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  Serial.println("Funkverbindung initialisiert");

  digitalWrite(cs_radio, HIGH);
  digitalWrite(cs_screen, LOW);

  display.init(19200);
  Serial.println("Display initialisiert");
}

void loop() {
  Serial.println("Loop gestartet");

  digitalWrite(cs_radio, LOW);
  digitalWrite(cs_screen, HIGH);
  
  if (radio.available()) {
    char text[40] = {0};
    char str_temp[8] = {0};
    char str_press[8] = {0};
    char str_hum[8] = {0};
    radio.read(&text, sizeof(text));

    int counter = 0;
    int counter_temp = 0;
    int counter_press = 0;
    int counter_hum = 0;
    
    Serial.println(text); 
    
    for (int i=0; i<=sizeof(text); i++) {
      if (text[i]=='/') {
        counter += 1;
      }
      else if (text[i]=='#') {
        counter = 3;
      }
      else {
        switch (counter) {
          case 0:
            str_temp[counter_temp] = text[i];
            counter_temp += 1;
            break;
          case 1:
            str_press[counter_press] = text[i];
            counter_press += 1;
            break;
          case 2:
            str_hum[counter_hum] = text[i];
            counter_hum += 1;
            break;
          case 3:
            i = sizeof(text);
            break;
        }
      }
        
    }

    Serial.println(str_temp);
    Serial.println(str_press);
    Serial.println(str_hum);

    Serial.println();

    digitalWrite(cs_radio, HIGH);
    digitalWrite(cs_screen, LOW);

    Serial.println("Pins fuer Display gesetzt");

    display.setRotation(1); //0 = hochkant
    display.setFullWindow();
    display.setFont(&FreeMonoBold9pt7b);
    display.setTextColor(GxEPD_WHITE);
    display.fillScreen(GxEPD_BLACK);
    
    // Kopfzeile
    display.drawRect(3,3,258,21, GxEPD_WHITE);
    display.drawRect(2,2,260,172, GxEPD_WHITE);
    char kopfzeile[] = "Dein aktuelles Wetter";
    int16_t tbx, tby; uint16_t tbw, tbh; 
    display.getTextBounds(kopfzeile, 0, 0, &tbx, &tby, &tbw, &tbh);
    uint16_t x = (display.width() - tbw) / 2;
    uint16_t y = 17; //(display.height() + tbh) / 2;
    display.setCursor(x, y);
    display.print(kopfzeile);
    
    display.setCursor(x,y+120);
    char Zeit[] = "Zeit:";
    display.print(Zeit);
  
  
    // Uhrzeit
    while (!timeClient.update()){
      delay ( 500 );
        } 
    Serial.println(timeClient.getFormattedTime());
    int hours = timeClient.getHours();
    hours += 2;
    int minutes = timeClient.getMinutes();
    Serial.println(hours);
    Serial.println(minutes);
    String zeit = String(hours);
    zeit += ":";
    if (minutes < 10)
      {
        zeit += "0";
      }
    zeit += String(minutes);
    display.setCursor(x+150,y+120);
    Serial.println(zeit);
    char ntptime[10];
    zeit.toCharArray(ntptime,zeit.length()+1);
    display.print(ntptime);
      
    display.setCursor(x,y+30);
    char Temp[] = "Temperatur:";
    display.print(Temp);
    
    display.setCursor(x,y+60);
    char Druck[] = "Druck:";
    display.print(Druck);
    
    display.setCursor(x,y+90);
    char LuftF[] = "Luftfeuchte:";
    display.print(LuftF);

    display.setCursor(x+50,y+30);
    display.print(str_temp);

    display.setCursor(x+50,y+60);
    display.print(str_press);

    display.setCursor(x+50,y+90);
    display.print(str_hum);

    Serial.println("Versuche, Display zu aktualisieren");
  
    display.nextPage();

    Serial.println("Display aktualisiert");
  }

  delay(500);
}

Images from Original Post so we don't have to download them. See this Simple Image Guide

...R

It's not completely clear from your description so am I correct to assume that you can communicate reliably between the two devices using the nRF24s?

Why not communicate between the devices using WiFi or ESP-NOW?

...R

Thank you for making the pictures easier watchable!

The communication already works fine, I can see over serial communication that the values arrive at the second device.
I use nrf24 for science :slight_smile: I want to use them later for RC modells, so why not learn here...

#define CE 16
#define CS 5

Using the internal numbers instead of D0/D1 is bad style especially if your schematics use the DX naming for the pins. For those who don't like to search for it: D0 has internal number 16 and D1 has 5..

#if defined (ESP8266)
GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/*CS=D8*/ 15, /*DC=D3*/ 0, /*RST=D4*/ 2, /*BUSY=D2*/ 4));
#endif

Why do you have the define around that variable declaration?

Sadly there is no info about the current consumption of the e-ink display. The sheet only says "TBD".

The Waveshare manual for that device says 26.4mW typical, so it's below 10mA, much less than the transceiver consumes. How do you power the devices? Battery? Wall plug power supply?

pylon:

#define CE 16

#define CS 5




Using the internal numbers instead of D0/D1 is bad style especially if your schematics use the DX naming for the pins. For those who don't like to search for it: D0 has internal number 16 and D1 has 5..

Originally I used Dxx. I changed it somewhere on the troubleshoot process just to be sure...
But you're of course right, I will change this again.

pylon:

#if defined (ESP8266)

GxEPD2_BW<GxEPD2_270, GxEPD2_270::HEIGHT> display(GxEPD2_270(/CS=D8/ 15, /DC=D3/ 0, /RST=D4/ 2, /BUSY=D2/ 4));
#endif




Why do you have the define around that variable declaration?

This is from an example code for the display. As it worked in a test, I haven't changed it...

pylon:
The Waveshare manual for that device says 26.4mW typical, so it's below 10mA, much less than the transceiver consumes. How do you power the devices? Battery? Wall plug power supply?

I tried the different things for powering:

  • over the wemos (5V into wemos, 3.3V to SPI devices)
  • over a power supply addon to the Breadboard with wall plug
  • with batteries

Robin2:
It's not completely clear from your description so am I correct to assume that you can communicate reliably between the two devices using the nRF24s?

Why not communicate between the devices using WiFi or ESP-NOW?

...R

After thinking about it a second time I could only use the on board wifi and then I only have to handle the display. Was this your idea?
I have no experience with transmitting variables over wifi, but I guess it isn't that difficult...?

MucFB:
After thinking about it a second time I could only use the on board wifi and then I only have to handle the display. Was this your idea?
I have no experience with transmitting variables over wifi, but I guess it isn't that difficult...?

If you don't actually need WiFi then I suspect that ESP-NOW will be simpler. I wrote this Thread using ESP-NOW on an ESP 8266. I presume it would be much the same on an ESP32.

...R

I will inform me about this possibility!

But do anyone has a clue why my approach does not work?
Is there anything I didn't note using two SPI devices?

MucFB:
But do anyone has a clue why my approach does not work?
Is there anything I didn't note using two SPI devices?

Just so you know I am not ignoring you, I can't help because I have no experience of using SPI with an ESP32, nor do I have an E-Ink module.

In the slight chance that it may help, there is a common problem using some SD Card modules alongside an nRF24 on regular Arduinos because the SD Card modules don't properly set the states of the SPI pins when they are finished. I think there is a workaround.

...R