] bonjour
toujours dans la galèrrrrrrrrrrre
j’ai une arduino rev 3 avec une grove base shield v2 dessus. il y a 3 capteur grove dessus un dth11 un barometre un un capteur de luminosité. j’ai relié un rn 171 dessus. le rn s’associe avec mon réseau wifi.
le code sur arduino fonctionne sur le moniteur série j’ai les résultats qui s’affiche.
pin arduino 3.3 v sur 3.3v rn
pin gnd sur gnd rn
pin rx sur tx rn
pin tx sur rx rn
sur le rapsberry, j’ai un serveur lighhtpd qui tourne si j’envoie <? php echo "grrr";?>, cela fonctionne mais dès que j’envoie le code ci dessous rien ne s’affiche et nada dans la base de données. Ma requete get est set com remote GET$/rnpl.php?value1=temperature&value2=pressure&value3=Rsensor&value4=h
voici les différents codes si quelqu’un voit une erreur.
merci
code arduino
/* Barometer demo V1.0
* Based largely on code by Jim Lindblom
* Get pressure, altitude, and temperature from the BMP085.
* Serial.print it out at 9600 baud to serial monitor.
*
* By:http://www.seeedstudio.com
*/
#include "Barometer.h"
#include <Wire.h>
/*
* WiFlyHQ Example httpclient.ino
*
* This sketch implements a simple Web client that connects to a
* web server, sends a GET, and then sends the result to the
* Serial monitor.
*
* This sketch is released to the public domain
*/
#include <WiFlyHQ.h>
//const char site[] = "192.168.0.10";
//#include <SoftwareSerial.h>
//SoftwareSerial wifiSerial(8,9);
WiFly wifly;
/* Grove - Light Sensor demo v1.0
*
* Signal wire to A0.
* By: http://www.seeedstudio.com
*/
#include <math.h>
float temperature;
float pressure;
float atm;
float altitude;
Barometer myBarometer;
#define LIGHT_SENSOR A0//Grove - Light Sensor is connected to A0 of Arduino
float Rsensor; //Resistance of sensor in K
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN A1 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
DHT dht(DHTPIN, DHTTYPE);
void setup(){
Serial.begin(9600);
myBarometer.init();
dht.begin();
wifly.begin(&Serial);
// if (wifly.open(site, 80)) {
// Serial.print("Connected to ");
// Serial.println(site);
//}
}
void loop()
{
temperature = myBarometer.bmp085GetTemperature(myBarometer.bmp085ReadUT()); //Get the temperature, bmp085ReadUT MUST be called first
pressure = myBarometer.bmp085GetPressure(myBarometer.bmp085ReadUP());//Get the temperature
altitude = myBarometer.calcAltitude(pressure); //Uncompensated caculation - in Meters
atm = pressure / 101325;
Serial.print("Temperature: ");
Serial.print(temperature, 2); //display 2 decimal places
Serial.println("deg C");
Serial.print("Pressure: ");
Serial.print(pressure, 0); //whole number only.
Serial.println(" Pa");
Serial.print("Related Atmosphere: ");
Serial.println(atm, 4); //display 4 decimal places
Serial.print("Altitude: ");
Serial.print(altitude, 2); //display 2 decimal places
Serial.println(" m");
Serial.println();
delay(1000); //wait a second and get values again.
int sensorValue = analogRead(LIGHT_SENSOR);
Rsensor = (float)(1023-sensorValue)*10/sensorValue;
Serial.println();
Serial.println("the sensor light is ");
Serial.println(Rsensor,DEC);//show the ligth intensity
Serial.println();
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h))
{
Serial.println("Failed to read from DHT");
}
else
{
Serial.print("Humidity: ");
Serial.print(h);
Serial.println(" %\t");
Serial.println();
}
}
code php
<?php
//sensor
$capteur_LUX ="LUX_EXT";
$capteur_TH="TH_EXT;
$capteur_BAR="BAR_EXT"
//grab the GET data
$valor_t=$_GET['value1'];
$valor_p=$_GET['value2'];
$valor_lux=$_GET['value3'];
$valor_h=$_GET['value4'];
//date_time
$date=date("d-m-Y-H-i");
echo ("h $valor_h; t $valor_t; p $valor_p; lux $valor_lux");
//connect database
mysql_connect("rapsberry","root","poi") or die("lulu");
mysql_select_db("db_rheorthe") or die ("coco");
$Sql_TH_EXT="INSERT INTO tbl_Temp_Ext (Capteur,Humidite,Temperature,Date_temperature) VALUES ('$capteur_TH','".$_GET['value1']."', '".$_GET['value4']."','$date')";
$Sql_Pressure="INSERT INTO tbl_Pression (Capteur,Pression,Date_Pression) VALUES ('$capteur_BAR','".$_GET["value2"]."', '$date')";
$Sql_LUX="INSERT INTO tbl_Lux (Capteur,Lux,DateLux) VALUES ('$capteur_LUX','".$_GET["value3"]."', '$date')";
mysql_query($Sql_TH_EXT);
mysql_query($Sql_Pressure);
mysql_query($Sql_LUX);
mysql_close();
?>