So what i have so far in my code is to make my arduino able to send accelerometer and gyroscope data using Ethernet but I cant figure out how to make it wireless.
here is what i have so far:
`
#include #include #include
Byte mac[] = { 0x00, 0Xaa, 0xbb, 0xcc, 0xde 0x01 }; // Reserved Mac Address
EthernetClient client;
#define DHTPIN 2 // SENSOR PIN
#define DHTTYPE DHT11 // SENSOR TYPE
DHT dht(DHTPIN, DHTTYPE);
long previousMillis = 0;
unsigned long currentMillis= 0;
long interval = 250000; //READING INTERVAL
int t = 0; // TEMPERATURE VAR
int h = 0; // HUMIDITY VAR
String data;
Void setup() {
Serial.begin(115200);
If (Ethernet.begin(mac) == 0) {
Serial.println(“Failed to configure Ethernet using DHCP”);
}
dht.begin();
delay(10000); // GIVE THE SENSOR SOME TIME TO START
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
data = “”;
}
void loop(){
currentMillis = millis();
if(currentMillis – previousMillis > interval) { //READ ONLY ONCE PER INTERVAL
previousMillis = currentMillis;
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
}
data = “templ=” + t + “&hum1=” + h; //THIS IS FOR PRINTING DATA TO WEBPAGE
if (client.connect(www.*****.*************.com,80)) { //REPLACE WITH SERVER ADDRESS
client.println(“POST /add.php HTTP/1.1”);
client.println(“Host: *****.*************.com,80”); //SERVER ADDRESS HERE TOO
client.println(“Content-Type: application/x-www-form-urlencoded”);
client.print(“Content-Length: “);
client.println(data.length());
client.println();
client.print(data);
}
If (client.connected()) {
client.stop(); //Disconnect from the server
}
delay(300000); //Wait five minutes before sending again
}
`
thank you
You'll need a WiFi module like ESP8266.
You can also use it alone (without arduino) since it is a complete soc with io pins.
For small range you can use Xbee module or Bluetooth shield. For range, GSM shield is recommmended.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.