Go Down

Topic: Real Time Data Logging (Senior Design Project) (Read 3510 times) previous topic - next topic

TGH904

Hello, this is my first post, but I have been using Arduino's a lot for most of my studies in school. Right now I have 4 Atlas Scientific Instruments (Sensor Probes, compatible with Arduino). I have sucessfully, managed to setup each probe and run them out of the box, as well as implement an SD shield to store the data on an SD card.

Recently I have found a Arduino WIFI Shield, and saw you are capable of sending data wirelessly to a website such as freeboard, or thingspeak. I decided to give this a go after running the example light and temperature demo for transmitting data to thingspeak using the shield. Next I tried setting up the code for my atlas instrument, but I am getting an error in compiling.


I have also replaced the SSID network/password and API Key with *'s for privacy purposes.

Also here is my error message below:

Quote
"C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp/core\core.a" "-LC:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp" -lm
C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_3'

C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_5'

C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_4'

C:\Users\THEHA_~1\AppData\Local\Temp\build0ab38658654d97e0abf5f85ce1118355.tmp\libraries\WiFi101\bsp\source\nm_bsp_arduino_avr.c.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

Using library WiFi101 at version 0.12.1 in folder: C:\Users\theha_000\Documents\Arduino\libraries\WiFi101
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board Arduino/Genuino Uno.
A hasty reply would be nice thank you.

TGH904

Quote
#include <WiFi101.h>

#include <SPI.h>


#include <SoftwareSerial.h>                           //we have to include the SoftwareSerial library, or else we can't use it
#define rx 2                                          //define what pin rx is going to be
#define tx 3                                          //define what pin tx is going to be


// WLAN parameters
char ssid[] = "******";     //  your network SSID (name)
char pass[] = "*******";  // your network password
int status = WL_IDLE_STATUS;     // the WiFi radio's status

WiFiServer server(80);

char thingSpeakAddress[] = "api.thingspeak.com";
String APIKey = "***********";              //enter your channel's Write API Key
const int updateThingSpeakInterval = 20 * 1000;  // 20 second interval at which to update ThingSpeak


// Variable Setup
long lastConnectionTime = 0;
boolean lastConnected = false;

// Initialize Arduino Ethernet Client
WiFiClient client;

SoftwareSerial myserial(rx, tx);                      //define how the soft serial port is going to work


String inputstring = "";                              //a string to hold incoming data from the PC
String sensorstring = "";                             //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false;                //have we received all the data from the PC
boolean sensor_string_complete = false;               //have we received all the data from the Atlas Scientific product
float ORP;                                             //used to hold a floating point number that is the ORP



void setup()
{
  // Start Serial for debugging on the Serial Monitor
  myserial.begin(9600);                               //set baud rate for the software serial port to 9600
  inputstring.reserve(10);                            //set aside some bytes for receiving data from the PC
  sensorstring.reserve(30);                           //set aside some bytes for receiving data from Atlas Scientific product
  Serial.begin(9600);
  while (!Serial)
  {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD)
  {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED)
  {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  
  
  
  
  //set up the hardware
  myserial.begin(9600);                               //set baud rate for the software serial port to 9600
  inputstring.reserve(10);                            //set aside some bytes for receiving data from the PC
  sensorstring.reserve(30);                           //set aside some bytes for receiving data from Atlas Scientific product

    // you're connected now, so print out the status:
  printWifiStatus();
}


void serialEvent()
{                                  //if the hardware serial port_0 receives a char
  inputstring = Serial.readStringUntil(13);           //read the string until we see a <CR>
  input_string_complete = true;                       //set the flag used to tell if we have received a completed string from the PC
}


void loop()
{
  
  
  
  
  
  
  
  
  
  //here we go...


 

  if (input_string_complete == true) {                //if a string from the PC has been received in its entirety
    myserial.print(inputstring);                      //send that string to the Atlas Scientific product
    myserial.print('\r');                             //add a <CR> to the end of the string
    inputstring = "";                                 //clear the string
    input_string_complete = false;                    //reset the flag used to tell if we have received a completed string from the PC
  }

  if (myserial.available() > 0) {                     //if we see that the Atlas Scientific product has sent a character
    char inchar = (char)myserial.read();              //get the char we just received
    sensorstring += inchar;                           //add the char to the var called sensorstring
    if (inchar == '\r') {                             //if the incoming character is a <CR>
      sensor_string_complete = true;                  //set the flag
    }
  }

 {


  if (sensor_string_complete == true)
  {               //if a string from the Atlas Scientific product has been received in its entirety


    Serial.println(sensorstring);                     //send that string to the PC's serial monitor
    Serial.print(" , ");

    
    if (isdigit(sensorstring[0]))
    {                   //if the first character in the string is a digit
      ORP = sensorstring.toFloat();                   //convert the string to a floating point number so it can be evaluated by the Arduino
      if (ORP >= 500.0)
      {                             //if the ORP is greater than or equal to 500
        Serial.println("high");                       //print "high" this is demonstrating that the Arduino is evaluating the ORP as a number and not as a string
      }
      if (ORP <= 499.9)
      {                             //if the ORP is less than or equal to 499.9
        Serial.println("low");                        //print "low" this is demonstrating that the Arduino is evaluating the ORP as a number and not as a string
      }
    }
    sensorstring = "";                                //clear the string
    sensor_string_complete = false;                   //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
  }
 
}
  // Print Update Response to Serial Monitor
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }
  // Disconnect from ThingSpeak
  if (!client.connected() && lastConnected)
  {
    Serial.println("...disconnected");
    Serial.println();
    client.stop();
  }
  // Update ThingSpeak
  if (!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
  {
    updateThingSpeak("field1=" + sensorstring);
    Serial.println(sensorstring);
  

  }
  lastConnected = client.connected();
}

void updateThingSpeak(String tsData) {
  if (client.connect(thingSpeakAddress, 80)) {
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + APIKey + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(tsData.length());
    client.print("\n\n");
    client.print(tsData);
    lastConnectionTime = millis();

    if (client.connected()) {
      Serial.println("Connecting to ThingSpeak...");
      Serial.println();
    }
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Go Up