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?