Cannot get data sensor on Wemos D1 Mini over Rj45 Female Connector?

I have a project for my graduate, i try connect my Wemos D1 Mini to Adafruit Bme280 over Rj45 Female Connector cable.

my define pinout: Wemos -> Rj45 -> Bme280

D4 -> pin 1 White/Orange -> CS D7(MOSI) -> pin 6 Green -> SDI D6(MISO) -> pin 4 Blue -> SDO D5 -> pin 3 White/Green -> SCK GND -> pin 5 White/Blue -> GND 3V3 -> pin 8 Brown -> 3Vo

but, when i uplaod to my Wemos,in my serial monitor say "Unable to connect Bme280!!!", it's just use example sketch on my library. what's my wrong Sir?

I'm sorry about my English

Also posted at: https://arduino.stackexchange.com/q/54960 If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

what’s my wrong Sir?

As you’re using an RJ45 connector I strongly guess you’re using a quite long cable in between the two. The connection uses SPI signals and because of the ESP8266 even in the low voltage (3V3) version. You won’t get these signals further than about 30cm and the RJ45-connector may even loose more.

it’s just use example sketch on my library.

Which we don’t know, so post a link to it and post the code you’re actually using. (Don’t forget the code tags, that’s the </> button in the editor)

@pylon
i need to more 5 meters to connect my Bme280 sir.

this my simple code:

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK D5
#define BME_MISO D6
#define BME_MOSI D7
#define BME_CS D4

#define SEALEVELPRESSURE_HPA (1013.25)

//Adafruit_BME280 bme; // I2C
Adafruit_BME280 bme1(BME1_CS); // hardware SPI
Adafruit_BME280 bme2(BME2_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;
bool status1 = bme1.begin();  
bool status2 = bme2.begin();
    
void setup() {
    Serial.begin(9600);
    Serial.println(F("BME280 test"));
    while (!status1 && !status2) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
    }
    Serial.println("-- Default Test --");
    delayTime = 1000;
    Serial.println();
}

void loop() {
    if (status1){
    Serial.print("Temperature = ");
    Serial.print(bme1.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme1.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme1.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme1.readHumidity());
    Serial.println(" %");

    Serial.println();

   } if (status2){
    Serial.print("Temperature = ");
    Serial.print(bme2.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme2.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme2.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme2.readHumidity());
    Serial.println(" %");

    Serial.println();

   }
    delay(delayTime);
}

i don’t know how to make strongly that signals sir?

i need to more 5 meters to connect my Bme280 sir.

That won't work. Move the MCU closer to the sensor. Or use a second MCU that is closer to the sensor and connect that one to the D1 Mini by a technology that supports connection of this length (RS-485, CAN-Bus, Ethernet, etc.).

pylon: Move the MCU closer to the sensor

berfore i will try it sir, is there any suggestion from you for try connect directly to sensor.

berfore i will try it sir, is there any suggestion from you for try connect directly to sensor.

I would try the setup with short wires to be sure the sensor is working. In your code your instancing 2 sensor objects although you have defined the variables for only one sensor. I doubt that this code compiles.

Do you connect 2 sensors or just one? If two, post a wiring diagram for both sensors.

If you meant suggestions for the 5 meter connection, I have only one: forget it. You won't get that running reliably, it's just a waste of time.

If you tell us more about your project we may have alternative solutions. At the moment we only know that you want to use a Wemos D1 Mini to connect to a BME280 over 5 meters of cable. There are a lot of questions open: why 5 meters of cable? Why must the D1 Mini that far away? What is the whole setup used for? What problems do you see if the D1 Mini is placed directly at the sensor?

Another question that needs asking, is the BME280 module setup for using SPI or I2C. Neither of them will probably work reliably over 5 meters so you might consider using I2C and range extenders like this or this.

An I2C range extender might give you about 3m but not 5m.

pylon: An I2C range extender might give you about 3m but not 5m.

Maybe true as I have never used them but from the Sparkfun link

The differential signaling allows the I2C signals to reach distances of up to 100ft. while still maintaining their signal integrity!

so the OP might be lucky.

@pylon

pylon:
Do you connect 2 sensors or just one? If two, post a wiring diagram for both sensors.

yes Sir Pylon, i used two sensors fo my project, specificly, i should make monitoring temperature and humidity based nodejs using Message Queuing Telemetry Transport Protocol, in my nodejs as javascript html for chart layout have been done, also in my protocol, but that without used RJ45 cable. the D1 Mini is placed directly at the sensor.
now i try to using RJ45 cable for edge of the room on 7 x 5 meters.

on my screenshoot is my simple board between D1 Mini to Rj45 Female Connector, but it’s not work for me Sir.

now i try to using RJ45 cable for edge of the room on 7 x 5 meters.

That won't work reliably as I already stated. Use one D1 mini per sensor (directly connected with short wires).

on my screenshoot is my simple board between D1 Mini to Rj45 Female Connector, but it's not work for me Sir.

The schematics would be much more informative. But as you're just connecting to the RJ-45 connectors it's not that helpful as we need to have the connections to the sensors.

Above code won't work as "BME1_CS" and "BME2_CS" are not defined.

@pylon

pylon: Above code won't work as "BME1_CS" and "BME2_CS" are not defined.

i'm sorry mistakenly written sir, i'm forgot write for

#define BME1_CS D4
#define BME2_CS D3

pylon: The schematics would be much more informative.

The Define pinout of schematics on my question sir, in another forum recommended for to use 1 MCU at RJ45 and 2 MCU at two sensor but i want looking for cheap price sir.

The Define pinout of schematics on my question sir, in another forum recommended for to use 1 MCU at RJ45 and 2 MCU at two sensor but i want looking for cheap price sir.

A cheap prize is not helpful if it doesn't work. You can have two sensors connected to one Wemos D1 mini but you cannot have cables in-between them longer than about 40cm. As you want to have several meters it will fail. So invest the few buck for a second Wemos D1 mini and connect each sensor to a separate MCU.

@pylon so, what your suggestions about RJ45 pinout to my Adafruit BME280? sir i think my RJ45 pinout is mistake.

abuahmed: @pylon so, what your suggestions about RJ45 pinout to my Adafruit BME280? sir i think my RJ45 pinout is mistake.

The Adafruit BME280 board doesn't have an RJ-45 connector so I have no suggestions as the whole RJ-45 part seems to be a proprietary extension of you. You didn't provide schematics of the complete setup as I requested so I'm unable to help you.

@pylon

pylon:
You didn’t provide schematics

This is my schematics sir, what my wrong sir?

This is my schematics sir, what my wrong sir?

This is the schematics of the board you posted the PCB layout before. But it doesn't contain the sensor side. There's no standardized way to connect an SPI bus to a RJ-45 so please provide the necessary information as I asked before.

@pylon

pylon:
There are a lot of questions open:

  1. why 5 meters of cable?
  2. Why must the D1 Mini that far away?
  3. What is the whole setup used for?
  4. What problems do you see if the D1 Mini is placed directly at the sensor?
  1. because on the room 7 x 5 meters far away for maximum result like i want.
  2. because i want get sensor at edge of that room.
  3. the hardware setup too easy for thesis Defence, if use placed directly the sensor, so my lead lecture want add RJ45 to reach the sensor at edge the room.
  4. no problems with placed directly at the sensor, but my lead lecturer want to placed the sensor at edge of the room sir.

what’s my mistakes sir?
That image as schematic Wemos to BME280 sir.

what's my mistakes sir?

You cannot have an SPI bus length of 5m. The cross-talk will be too high and you won't see steep enough signal as the sensor to correctly read the values. If your "lead lecture" (I guess that's a professor) thinks this works with a 5m cable then he's wrong. Get another Wemos D1 mini (they cost a few bucks) and connect each sensor to a separate Wemos.

That image as schematic Wemos to BME280 sir.

The Adafruit BME280 board must be powered by the Vin pin, it won't work if powered by the 3Vo pin (this is just a 3V output).