8:21 AM
0
BMP180 + DHT11 + ENC28J60 + arduino nano

Beserta ini saya sertakan source code Arduino bagaimana cara mengkonfigurasikan semuanya


hubungkan pin SCL di pin D5 dan pin SDA di pin D4, pin Vin di pin 3v3, gnd di gnd


Jika semua sudah dihubungkan, colokkan usb arduino nano ke laptop, dan upload program seperti di bawah ini :

#include <ETHER_28J60.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24};
static uint8_t ip[4] = {192, 168, 1, 15};
static uint16_t port = 80; 
ETHER_28J60 ethernet;

int err;
float Tc=0;
float Tf=0;
float Pa=0;
float InHg=0;
float Af=0;
float Am=0;
Adafruit_BMP085 bmp;

void setup() {
// Open serial communications and wait for port to open:
  ethernet.setup(mac, ip, port);
  Serial.begin(9600);
  if (!bmp.begin()) 
  {
  Serial.println("Could not find a valid BMP085 sensor, check wiring!");
  while (1) {}
  }
}

void loop() 
{  
    Serial.print("Temperature = ");
    //Serial.print(bmp.readTemperature());
    Tc=bmp.readTemperature();
    Tf=((Tc*9)/5)+32;
    Serial.print(Tf);
    Serial.println(" *F");
   
    Serial.print("Pressure = ");
    //Serial.print(bmp.readPressure());
    Pa=bmp.readPressure();
    InHg=Pa*0.000295333727;
    Serial.print(InHg);
    Serial.println(" In Hg");
   
    Serial.print("Pressure in hPa = ");
    //Serial.print(bmp.readPressure());
    Pa=bmp.readPressure();
    Serial.print(Pa*0.01);
    Serial.println(" hPa");
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    //Serial.print(bmp.readAltitude());
    Am=bmp.readAltitude(101325); //adjusted for local altitude
    Af=Am*3.28084;
    Serial.print(Af);
    Serial.println(" feet");
    
    Serial.print("Altitude in meter = ");
    //Serial.print(bmp.readAltitude());
    Am=bmp.readAltitude(101325); //adjusted for local altitude
    Serial.print(Am);
    Serial.println(" meter");
    
    if (ethernet.serviceRequest())
    {
      char P[9]; 
      itoa(Pa, P, 10);
      ethernet.print("<H1>Aris's ARDUINO</H1>");
      ethernet.print("<p>PressBMP180: ");
      ethernet.print(P);
      ethernet.print("hPa");
      ethernet.respond();
    }
    else
    {
      ethernet.print("Error No :");
      ethernet.print(err);
    }   
    Serial.println();
delay (1000);
}

baik, itu saja yang bisa saya sampaikan. happy coding in arduino !

0 komentar:

Post a Comment