/*****************************************************************************/ // Track a Fork Truck // Hardware: Grove - 6-Axis Accelerometer&Gyroscope // Arduino IDE: Arduino-1.8.8 // Author: Me // Date: Dec,2018 // Version: v8.0 /*******************************************************************************/ #include #include #include "arduino_secrets.h" #include "SparkFunLSM6DS3.h" #include "Wire.h" ///////please enter your sensitive data in the Secret tab/arduino_secrets.h char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) int status = WL_IDLE_STATUS; // the Wifi radio's status //Create an instance of class LSM6DS3 LSM6DS3 myIMU( I2C_MODE, 0x6A ); //I2C device address 0x6A void setup() { // put your setup code here, to run once: //BEGIN WIFI SETUP //Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); // don't continue while (true); } String fv = WiFi.firmwareVersion(); if (fv < "1.0.0") { Serial.println("Please upgrade the firmware"); } // attempt to connect to Wifi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to WPA SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network: status = WiFi.begin(ssid, pass); // wait 8 seconds for connection: delay(8000); } // you're connected now, so print out the data: Serial.print("You're connected to the network"); //Print MAC and IP address after connection. printCurrentNet(); } void printWifiData() { // print your board's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); Serial.println(ip); // print your MAC address: byte mac[6]; WiFi.macAddress(mac); Serial.print("MAC address: "); printMacAddress(mac); } //END WIFI SETUP //Start of Accelerometer //Setup connection at 9600 baud //Serial.begin(9600); //Call .begin() to configure the IMUs if( myIMU.begin() != 0 ) { Serial.println("Device error"); } else { Serial.println("Device OK!"); } } void loop(){ // put your main code here, to run repeatedly: //Accelerometer Serial.print("\nAccelerometer:\n"); Serial.print(" X(truck7) = "); Serial.println(myIMU.readFloatAccelX(), 4); Serial.print(" Y(truck7) = "); Serial.println(myIMU.readFloatAccelY(), 4); Serial.print(" Z(truck7) = "); Serial.println(myIMU.readFloatAccelZ(), 4); //Thermometer to be used later in project //Thermometer //Serial.print("\nThermometer:\n"); //Serial.print(" Degrees Fahrenheit = "); //Serial.println(myIMU.readTempF(), 4); delay(1000); void printMacAddress(byte mac[]) { for (int i = 5; i >= 0; i--) { if (mac[i] < 16) { Serial.print("0"); } Serial.print(mac[i], HEX); if (i > 0) { Serial.print(":"); } } Serial.println(); }