Dear Sir ,
i am working on a project trying to send temp/humid data through ether net ,iam using Ethernet Shield installed Over Arduino Uno ,connected to Temp/Humis Sensor DB130-10 ,every thing was OK till i create Ethernet.begin() function in setup() function it causes the data (temperature value and humidity value) to be nonsense the code below
#include<SHT1x.h>
#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin,clockPin);
//////send signal to Relay
int power=7;
int sig=8;
byte mac_addr[] = { 0xDE, 0xAB, 0xBA, 0xEF, 0xFE, 0xED };
IPAddress server_addr(10,154,91,100); // IP of the MySQL *server* here
IPAddress ip(10,154,91,70); // IP of the Arduino
char user[] = "Arduino70"; // MySQL user login username
char password[] = "123"; // MySQL user login password
char query[128];
int counter=0;
EthernetClient client;
int flag;
MySQL_Connection conn((Client *)&client);
int flag;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac_addr,ip);
if(conn.connect(server_addr, 3306, user, password)) {
flag=1;
Serial.println("Connected");
delay(1000);
}
else flag=0;
//Serial.println("Connection failed.");
}
void loop()
{
float tempC;
float humidity;
//read values from sensors
tempC = sht1x.readTemperatureC();
humidity=sht1x.readHumidity();
//Serial.println("Recording data.");
//sensors.requestTemperatures();
// float tempC = sensors.getTempCByIndex(0);
char TEMP[30];
Serial.println(tempC);
Serial.println(humidity);
}