0

I have an issue with my application.

Hardware used:

  • ESP8266 Serial Wi-Fi Wireless Transceiver Module for IOT
  • Robodyn Micro USB Compatible for Arduino Nano V3.0 ATmega168 CH340G
  • SENSOR: BMP180

Connections:

  • Arduino Nano to ESP8266
  • CH-PD to Vcc
  • GPIO0 to GND
  • Rx to Rx
  • Tx to Tx
  • 3.3v to 3.3v
  • Reset to GND
  • GND to GND

Arduino Nano to BMP180

  • 3.3v to VIN
  • GND to GND
  • A5 to SCL
  • A4 to SDA

Sketch used (uploaded in Generic ESP8266 Board):

#include <DHT.h> //  DHT.h library
#include <ESP8266WiFi.h> // ESP8266WiFi.h library
#include <SFE_BMP180.h>
#include <Wire.h>

SFE_BMP180 pressure;

const char* ssid     = "GOPI-LAPTOP";
const char* password = "kcejava123";
const char* host = "api.thingspeak.com";
const char* writeAPIKey = "CQSHDFP4EZFCDWKO";

void setup() {
  // Initialize sensor
  Serial.begin(9600);
  delay(1000);
  if (pressure.begin())
    Serial.println("BMP180 init success");
  else {
    Serial.println("BMP180 init fail\n\n");
  }
  //  Connect to WiFi network
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void loop() {
  char status;
  double T, P, p0, a;
  status = pressure.startTemperature();
  if (status != 0) {
    // Wait for the measurement to complete:
    delay(status);
    status = pressure.getTemperature(T);
    if (status != 0) {
      // Print out the measurement:
      Serial.print("temperature: ");
      Serial.print(T,2);
      Serial.print(" deg C, ");
      Serial.print((9.0/5.0)*T+32.0,2);
      Serial.println(" deg F");
    } else
      Serial.println("error retrieving pressure measurement\n");
  }
  status = pressure.startPressure(3);
  if (status != 0) {
    delay(status);
    status = pressure.getPressure(P, T);
    if (status != 0) {
      // Print out the measurement:
      Serial.print("absolute pressure: ");
      Serial.print(P, 2);
      Serial.print(" mb, ");
      Serial.print(P*0.0295333727, 2);
      Serial.println(" inHg");
      p0 = 1013.25; // we're at 1655 meters (Boulder, CO)
      Serial.print("relative (sea-level) pressure: ");
      Serial.print(p0, 2);
      Serial.print(" mb, ");
      Serial.print(p0*0.0295333727, 2);
      Serial.println(" inHg");
      a = pressure.altitude(P, p0);
      Serial.print("computed altitude: ");
      Serial.print(a, 0);
      Serial.print(" meters, ");
      Serial.print(a*3.28084, 0);
      Serial.println(" feet");
    }
  }
  // make TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    return;
  }
  String url = "/update?key=";
  url+=writeAPIKey;
  url+="&field1=";
  url+=String(T);
  url+="&field2=";
  url+=String(P);
  url+="\r\n";
  // Request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
    "Host: " + host + "\r\n" +
    "Connection: close\r\n\r\n");
  Serial.print(String("GET ") + url + " HTTP/1.1\r\n" +
    "Host: " + host + "\r\n" +
    "Connection: close\r\n\r\n");
  delay(30000);
}

Serial Output:

BMP180 init fail

GET /update?key=CQSHDFP4EZFCDWKO&field1=8.04&field2=8.08
 HTTP/1.1
Host: api.thingspeak.com
Connection: close

GET /update?key=CQSHDFP4EZFCDWKO&field1=8.04&field2=8.08
 HTTP/1.1
Host: api.thingspeak.com
Connection: close 

Queries:

• How to enable BMP180 to sense? When I configure BMP180 with Arduino (without ESP8266), I get the output in the serial terminal.

• How to send data to Thingspeak.com from BMP180 using the specified hardware?

  • I get the feeling you are getting a little confused about what is doing what. It looks like you are using the Arduino as a USB to UART converter, and programming the ESP8266 - and then connecting the BMP180 to the Arduino which you aren't programming and isn't even running. – Majenko Oct 4 '17 at 9:04
  • why not just run the BMP from the ESP? – dandavis Oct 5 '17 at 6:31
1

Connections:

[...]

  • Rx to Rx
  • Tx to Tx

That's not gonna fix your problem with initializing the BMP180, but you have to cross the lines, Rx to Tx and Tx to Rx, if you want to get anything on the serial terminal... Besides, your Nano is 5V, your ESP 3.3V. Connecting directly the Nano's Rx/Tx lines at 5V to the ESP's Rx/Tx 3.3V lines might not be very safe.

As for the BMP180, is it rated for 3.3V, or only 5V? If it is 5V only, it might not work on the ESP. Hence the init fail.

1

For I2C to work you must have pull up resistors. Normally 4.7K connected between SCL and VIN and SDA and VIN make thinks work.

You probably should use a logic level convertor to convert 3.3 to 5V (not a resistor divider, not sharp enough edges for digital signals). If I remember correctly the ESP can take 7V on its pins before you kill it (its in the chip spec) but that doesn't mean its a good idea to do it.

As mentioned above you need to cross the serial leads to make the connection. The Nano's Rx lead needs to be connected to the ESP's Tx lead and vice versa.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.