66741 发表于 2016-1-22 20:51:16

谁来给我修改一下代码? 帮我把W5100的代码改成可以上传至yeelink的代码可以吗?

本帖最后由 66741 于 2016-1-29 16:18 编辑

我才12岁

Hardware connections:

- (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled:SDASCL
Uno, Redboard, Pro:      A4   A5
Mega2560, Due:             20   21
Leonardo:                   2    3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting
the BMP180 to systems with lower logic levels such as 1.8V

Have fun! -Your friends at SparkFun.

The SFE_BMP180 library uses floating-point equations developed by the
Weather Station Data Logger project: http://wmrx00.sourceforge.net/

Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.

V10 Mike Grusin, SparkFun Electronics 10/24/2013
*/

// Your sketch must #include this library, and the Wire library.
// (Wire is a standard library included with Arduino.):

#include <Ethernet.h>
#include <WiFi.h>
#include <SPI.h>
#include <yl_data_point.h>
#include <yl_device.h>
#include <yl_w5100_client.h>
#include <yl_wifi_client.h>
#include <yl_messenger.h>
#include <yl_sensor.h>
#include <yl_value_data_point.h>
#include <yl_sensor.h>
#include "dht11.h"
#include <SFE_BMP180.h>
#include <Wire.h>

//this example reads data from a lm35dz sensor, convert value to degree Celsius
//and then post it to yeelink.net

//replace 2633 3539 with ur device id and sensor id
yl_device ardu(2633);
yl_sensor therm(3539, &ardu);
//replace first param value with ur u-apikey
yl_w5100_client client;
yl_messenger messenger(&client, "u-apikey", "api.yeelink.net");

const int pin = 5;

dht11 DHT11;   // the Object for sensor DHT11
int temp; // 溫度, 因為 DHT11 只有給整數 !
int humi; // 濕度, 因為 DHT11 只有給整數 !

SFE_BMP180 pressure;

double baseline; // baseline pressure

void setup()
{
Serial.begin(9600); //for output information
Serial.println("REBOOT");
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA};
Ethernet.begin(mac);
Serial.println("Testing the DHT11 and dht11.h Library !");
int chk = DHT11.read(pin);
Serial.print(String("Error code=") + chk);
Serial.println(String("Humidity=") + DHT11.humidity + ", Temperature=" + DHT11.temperature);
if (pressure.begin())
    Serial.println("BMP180 init success");
else
{
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail (disconnected?)\n\n");
    while (1); // Pause forever.
}

// Get the baseline pressure:

baseline = getPressure();

Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
}

void loop()
{
delay(2000);   // Wait 2seconds between measurements.
int chk = DHT11.read(pin);
if (chk != 0 ) {// 讀取 DHT11 有問題
    Serial.println("DHT11 reading Error !");
} else {    // 把這行注釋掉就可以有錯也照印 !
    temp = DHT11.temperature;
    humi = DHT11.humidity;
    Serial.print("Humidity: ");
    Serial.print(humi);
    Serial.print(" %\t");
    Serial.println(String("Temperature: ") + temp + " oC");
    double a, P;

    // Get a new pressure reading:

    P = getPressure();

    // Show the relative altitude difference between
    // the new reading and the baseline reading:

    a = pressure.altitude(P, baseline);

    Serial.print("relative altitude: ");
    if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
    Serial.print(a, 1);
    Serial.print(" meters, ");
    if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
    Serial.print(a * 3.28084, 0);
    Serial.println(" feet");

    delay(500);
}


double getPressure()
{
    char status;
    double T, P, p0, a;

    // You must first get a temperature measurement to perform a pressure reading.

    // Start a temperature measurement:
    // If request is successful, the number of ms to wait is returned.
    // If request is unsuccessful, 0 is returned.

    status = pressure.startTemperature();
    if (status != 0)
    {
      // Wait for the measurement to complete:

      delay(status);

      // Retrieve the completed temperature measurement:
      // Note that the measurement is stored in the variable T.
      // Use '&T' to provide the address of T to the function.
      // Function returns 1 if successful, 0 if failure.

      status = pressure.getTemperature(T);
      if (status != 0)
      {
      // Start a pressure measurement:
      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
      // If request is successful, the number of ms to wait is returned.
      // If request is unsuccessful, 0 is returned.

      status = pressure.startPressure(3);
      if (status != 0)
      {
          // Wait for the measurement to complete:
          delay(status);

          // Retrieve the completed pressure measurement:
          // Note that the measurement is stored in the variable P.
          // Use '&P' to provide the address of P.
          // Note also that the function requires the previous temperature measurement (T).
          // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
          // Function returns 1 if successful, 0 if failure.

          status = pressure.getPressure(P, T);
          if (status != 0)
          {
            return (P);
          }
          else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
      }
      else Serial.println("error retrieving temperature measurement\n");
    }
    else Serial.println("error starting temperature measurement\n");
}// if..else..
} // loop(
Hardware connections:

- (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled:SDASCL
Uno, Redboard, Pro:      A4   A5
Mega2560, Due:             20   21
Leonardo:                   2    3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting
the BMP180 to systems with lower logic levels such as 1.8V

Have fun! -Your friends at SparkFun.

The SFE_BMP180 library uses floating-point equations developed by the
Weather Station Data Logger project: http://wmrx00.sourceforge.net/

Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.

V10 Mike Grusin, SparkFun Electronics 10/24/2013
*/

// Your sketch must #include this library, and the Wire library.
// (Wire is a standard library included with Arduino.):

#include <Ethernet.h>
#include <WiFi.h>
#include <SPI.h>
#include <yl_data_point.h>
#include <yl_device.h>
#include <yl_w5100_client.h>
#include <yl_wifi_client.h>
#include <yl_messenger.h>
#include <yl_sensor.h>
#include <yl_value_data_point.h>
#include <yl_sensor.h>
#include "dht11.h"
#include <SFE_BMP180.h>
#include <Wire.h>

//this example reads data from a lm35dz sensor, convert value to degree Celsius
//and then post it to yeelink.net

//replace 2633 3539 with ur device id and sensor id
yl_device ardu(2633);
yl_sensor therm(3539, &ardu);
//replace first param value with ur u-apikey
yl_w5100_client client;
yl_messenger messenger(&client, "u-apikey", "api.yeelink.net");

const int pin = 5;

dht11 DHT11;   // the Object for sensor DHT11
int temp; // 溫度, 因為 DHT11 只有給整數 !
int humi; // 濕度, 因為 DHT11 只有給整數 !

SFE_BMP180 pressure;

double baseline; // baseline pressure

void setup()
{
Serial.begin(9600); //for output information
Serial.println("REBOOT");
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA};
Ethernet.begin(mac);
Serial.println("Testing the DHT11 and dht11.h Library !");
int chk = DHT11.read(pin);
Serial.print(String("Error code=") + chk);
Serial.println(String("Humidity=") + DHT11.humidity + ", Temperature=" + DHT11.temperature);
if (pressure.begin())
    Serial.println("BMP180 init success");
else
{
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail (disconnected?)\n\n");
    while (1); // Pause forever.
}

// Get the baseline pressure:

baseline = getPressure();

Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
}

void loop()
{
delay(2000);   // Wait 2seconds between measurements.
int chk = DHT11.read(pin);
if (chk != 0 ) {// 讀取 DHT11 有問題
    Serial.println("DHT11 reading Error !");
} else {    // 把這行注釋掉就可以有錯也照印 !
    temp = DHT11.temperature;
    humi = DHT11.humidity;
    Serial.print("Humidity: ");
    Serial.print(humi);
    Serial.print(" %\t");
    Serial.println(String("Temperature: ") + temp + " oC");
    double a, P;

    // Get a new pressure reading:

    P = getPressure();

    // Show the relative altitude difference between
    // the new reading and the baseline reading:

    a = pressure.altitude(P, baseline);

    Serial.print("relative altitude: ");
    if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
    Serial.print(a, 1);
    Serial.print(" meters, ");
    if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
    Serial.print(a * 3.28084, 0);
    Serial.println(" feet");

    delay(500);
}


double getPressure()
{
    char status;
    double T, P, p0, a;

    // You must first get a temperature measurement to perform a pressure reading.

    // Start a temperature measurement:
    // If request is successful, the number of ms to wait is returned.
    // If request is unsuccessful, 0 is returned.

    status = pressure.startTemperature();
    if (status != 0)
    {
      // Wait for the measurement to complete:

      delay(status);

      // Retrieve the completed temperature measurement:
      // Note that the measurement is stored in the variable T.
      // Use '&T' to provide the address of T to the function.
      // Function returns 1 if successful, 0 if failure.

      status = pressure.getTemperature(T);
      if (status != 0)
      {
      // Start a pressure measurement:
      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
      // If request is successful, the number of ms to wait is returned.
      // If request is unsuccessful, 0 is returned.

      status = pressure.startPressure(3);
      if (status != 0)
      {
          // Wait for the measurement to complete:
          delay(status);

          // Retrieve the completed pressure measurement:
          // Note that the measurement is stored in the variable P.
          // Use '&P' to provide the address of P.
          // Note also that the function requires the previous temperature measurement (T).
          // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
          // Function returns 1 if successful, 0 if failure.

          status = pressure.getPressure(P, T);
          if (status != 0)
          {
            return (P);
          }
          else Serial.println("error retrieving pressure measurement\n");
      }
      else Serial.println("error starting pressure measurement\n");
      }
      else Serial.println("error retrieving temperature measurement\n");
    }
    else Serial.println("error starting temperature measurement\n");
}// if..else..
} // loop(
帮我把W5100的代码改成可以上传至yeelink的代码可以吗?

66741 发表于 2016-1-29 16:21:09

怎么多人看就帮我修改一下吗?

66741 发表于 2016-1-29 17:29:38

有人吗?谁来帮帮我啊。
页: [1]
查看完整版本: 谁来给我修改一下代码? 帮我把W5100的代码改成可以上传至yeelink的代码可以吗?