Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 阿杜伊诺+;紫外线传感器&x2B;以太网&x2B;发光二极管&x2B;发送数据_Mysql_Arduino_Ethernet - Fatal编程技术网

Mysql 阿杜伊诺+;紫外线传感器&x2B;以太网&x2B;发光二极管&x2B;发送数据

Mysql 阿杜伊诺+;紫外线传感器&x2B;以太网&x2B;发光二极管&x2B;发送数据,mysql,arduino,ethernet,Mysql,Arduino,Ethernet,我正在做一个由arduino+以太网屏蔽+LED+紫外线传感器组成的项目,我需要将数据(从传感器接收到的数据)发送到mysql数据库 #include <Wire.h> #include "Adafruit_SI1145.h" #include <SPI.h> #include <Ethernet.h> //leds #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/

我正在做一个由arduino+以太网屏蔽+LED+紫外线传感器组成的项目,我需要将数据(从传感器接收到的数据)发送到mysql数据库

#include <Wire.h>
#include "Adafruit_SI1145.h"
#include <SPI.h>
#include <Ethernet.h>

//leds
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

//arduino pin usado + leds nr pins usados
#define PIN            6
#define NUMPIXELS      20


Adafruit_SI1145 uv = Adafruit_SI1145();
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

//delay leds
int delayval = 25; // delay for half a second


byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Enter the IP address for Arduino, as mentioned we will use 192.168.0.16
// Be careful to use , insetead of . when you enter the address here
IPAddress ip(192,168,137,11);



IPAddress server(192,168,137,1); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie. "www.yourwebpage.com")
//char server[] = "localhost";

// Initialize the Ethernet server library
EthernetClient client;

void setup() {

  // Serial.begin starts the serial connection between computer and Arduino
  Serial.begin(9600);
pixels.begin();


  //start UV sensor
  if (! uv.begin()) {
    Serial.println("UV desligado");
  }

  Serial.println ("UV ligado");

  // start the Ethernet connection
  Ethernet.begin(mac, ip);

}

void loop() {
 if (client.connect(server,80) > 0) {

     while(client.connected()) {

   // get data from sensor
   float UVindex = uv.readUV();
   UVindex /= 100.0;
   Serial.print("UV BEFORE LEDS/DB");Serial.println(UVindex);


     if(UVindex==0.02){
   Serial.print("UV: ");  Serial.println(UVindex);

     for(int i=0;i<NUMPIXELS;i++){
      pixels.setPixelColor(i, pixels.Color(150,0,0)); // Moderately bright green color.
      pixels.show(); // This sends the updated pixel color to the hardware.
       delay(delayval); // Delay for a period of time (in milliseconds)
         }

  }
  else if(UVindex == 0.01){
    Serial.print("UV: ");  Serial.println(UVindex);

     for(int i=0;i<NUMPIXELS;i++){
      pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
      pixels.show(); // This sends the updated pixel color to the hardware.
       delay(delayval); // Delay for a period of time (in milliseconds)

         }
  }

   else if(UVindex == 0.03){
    Serial.print("UV: ");  Serial.println(UVindex);

     for(int i=0;i<NUMPIXELS;i++){
      pixels.setPixelColor(i, pixels.Color(0,0,150)); // Moderately bright green color.
      pixels.show(); // This sends the updated pixel color to the hardware.
       delay(delayval); // Delay for a period of time (in milliseconds)

         }
  }

      // Header start
     Serial.println("connected");
     client.print("GET /arduino_client_UV_VALUES/pap/getUV.php?");
     client.print("uv=");
     client.print(UVindex);
     client.println(" HTTP/1.1");
     client.println("Host: 192.168.137.1");
     //client.println("Connection: close");
     client.println();
     // Header finish

     delay(1000);

    }



Serial.println();

  } else {
    Serial.println(server);
    Serial.println("connection failed");
  }


  // Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.
  delay(1000);
}
#包括
#包括“Adafruit_SI1145.h”
#包括
#包括
//发光二极管
#包括
#ifdef__AVR__
#包括
#恩迪夫
//arduino引脚usado+发光二极管N引脚usado
#定义引脚6
#定义像素20
Adafruit_SI1145 uv=Adafruit_SI1145();
Adafruit_NeoPixel像素=Adafruit_NeoPixel(像素,引脚,NEO_GRB+NEO_KHZ800);
//延迟发光二极管
int delayval=25;//耽搁半秒钟
字节mac[]={
0xDE,0xAD,0xBE,0xEF,0xFE,0xED};
//输入Arduino的IP地址,如前所述,我们将使用192.168.0.16
//小心使用,不要插入。当你在这里输入地址时
ip地址ip(192168137,11);
IP地址服务器(192168137,1);//重要提示:如果您使用的是XAMPP,您必须找出您计算机的IP地址,并将其放在此处(在前一篇文章中对此进行了解释)。如果您有网页,请输入其地址(即“www.yourwebpage.com”)
//字符服务器[]=“本地主机”;
//初始化以太网服务器库
以太网络客户端;
无效设置(){
//Serial.begin启动计算机和Arduino之间的串行连接
Serial.begin(9600);
像素。begin();
//启动紫外线传感器
如果(!uv.begin()){
序列号println(“UV-desligado”);
}
Serial.println(“UV ligado”);
//启动以太网连接
以太网开始(mac,ip);
}
void循环(){
如果(客户端连接(服务器,80)>0){
while(client.connected()){
//从传感器获取数据
float UVindex=uv.readUV();
紫外线指数/=100.0;
Serial.print(“LED前的紫外线/DB”);Serial.println(紫外线指数);
如果(UVindex==0.02){
Serial.print(“UV:”);Serial.println(UVindex);

对于(int i=0;i尝试更改以下内容

IPAddress服务器(192168137,1);

char服务器[]=“192.168.137.1”