error: 'Client' does not name a type

Greetings! Please help me correct this error in my sketch :slight_smile:

Here is the compile error I get when I verify the sketch:

sketch_mar19a.ino:12:1: error: 'Client' does not name a type
sketch_mar19a.ino: In function 'void loop()':
sketch_mar19a.ino:36:5: error: 'client' was not declared in this scope
Error compiling.

Here is my entire sketch code (a lot is commented out because I'm just trying to make basic sketch that sends data from 2 analog sensors to a SQL database, I borrowed the code from here: http://www.instructables.com/id/Save-data-of-temperature-and-humidity-on-MySQL-wit/?ALLSTEPS ):

int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorValue0 = 0;
int sensorValue1 = 0;

// int DS18S20_Pin = 3;
// OneWire ds(DS18S20_Pin);

Client client( "192.168.1.110", 80 );

int looped = 1;

void setup()
{
Serial.begin( 9600 );
// WiFly.begin();

// if( !WiFly.join( ssid, passphrase ) )
// {
// Serial.println( "Association failed." );

// while( 1 )
// {
// Hang on failure.
// }
// }

}

void loop()
{

if( client.connect() )
{
sensorValue0 = analogRead(sensorPin0);
sensorValue1 = analogRead(sensorPin1);
// float temp = getTemp();
Serial.println(sensorValue0);
Serial.println(sensorValue1);

client.print( "GET /add.php?");
client.print("temp1=");
client.print( sensorValue1 );
client.print("&&");
client.print("moi1=");
client.print( sensorValue0 );
client.println( " HTTP/1.1");
client.println( "Host: grow.gov" );
client.println( "Content-Type: application/x-www-form-urlencoded" );
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
}
delay( 5000 );
// }

// float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

// byte data[12];
// byte addr[8];

// if ( !ds.search(addr)) {
//no more sensors on chain, reset search
// ds.reset_search();
// return -1000;
// }

// if ( OneWire::crc8( addr, 7) != addr[7]) {
// Serial.println("CRC is not valid!");
// return -1000;
// }

// if ( addr[0] != 0x10 && addr[0] != 0x28) {
// Serial.print("Device is not recognized");
// return -1000;
// }

// ds.reset();
// ds.select(addr);
// ds.write(0x44,1); // start conversion, with parasite power on at the end

// byte present = ds.reset();
// ds.select(addr); 
// ds.write(0xBE); // Read Scratchpad


// for (int i = 0; i < 9; i++) { // we need 9 bytes
// data[i] = ds.read();
// }

// ds.reset_search();

// byte MSB = data[1];
// byte LSB = data[0];

// float tempRead = ((MSB << 8) | LSB); //using two's compliment
// float TemperatureSum = tempRead / 16;

// return TemperatureSum;

}

Client client( "192.168.1.110", 80 );This looks like you are trying to create an instance of an object named client using a library named Client but that libary is not #included in the program. What libraries were #included in the original code ?

UKHeliBob,

my mod includes 0 libraries but the original included the following:

#include
#include "WiFly.h"

it looks like the engineer made a typo on the first line so I commented it out. I also commented out the wifly library because when I include it I get a mess of compile errors... perhaps client is defined in wifly.h and this is why I get the current error. Please give me your thoughts!

Put the WiFly.h include back and post the compile errors. I assume that you actually have the.h file and that it is in right place.

UKHeliBob,

the original engineer didn't provide a wifly library so I'm using one provided by a friend of mine, he says it worked with the hardware before. After including wifly.h I get these compile errors:

Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:62:10: error: conflicting return type specified for 'virtual void SpiUartDevice::write(byte)'

     void write(byte value);

          ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:8:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/Client.h:21:8: error: conflicting return type specified for 'virtual void Client::write(byte)'

   void write(byte value);

        ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:8:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/Client.h:23:8: error: conflicting return type specified for 'virtual void Client::write(const uint8_t*, size_t)'

   void write(const uint8_t *buffer, size_t size);

        ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:53:20: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

UKHeliBob,

please ignore my previous post because I have now read the readme.txt included with the WiFly library and have updated my mod code. You will find my new code below and compile errors.

Arduino: 1.6.1 (Windows 7), Board: "Arduino Uno"

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:62:10: error: conflicting return type specified for 'virtual void SpiUartDevice::write(byte)'

     void write(byte value);

          ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:8:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/Client.h:21:8: error: conflicting return type specified for 'virtual void Client::write(byte)'

   void write(byte value);

        ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:48:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

In file included from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:8:0,

                 from sketch_mar19a.ino:2:

C:\Users\Urkle\Documents\Arduino\libraries\WiFly/Client.h:23:8: error: conflicting return type specified for 'virtual void Client::write(const uint8_t*, size_t)'

   void write(const uint8_t *buffer, size_t size);

        ^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/_Spi.h:9,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/SpiUart.h:7,

                 from C:\Users\Urkle\Documents\Arduino\libraries\WiFly/WiFly.h:4,

                 from sketch_mar19a.ino:2:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:53:20: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'

     virtual size_t write(const uint8_t *buffer, size_t size);

                    ^

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
#include "WiFly.h"


int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorValue0 = 0;
int sensorValue1 = 0;

// int DS18S20_Pin = 3;
// OneWire ds(DS18S20_Pin);

Client client( "192.168.1.110", 80 );

int looped = 1;

void setup()
{
Serial.begin( 9600 );
  WiFly.begin();
  
  if (!WiFly.join("ssid", "passphrase")) {
     // Handle the failure
  }
  
  // Rejoice in your connection
// WiFly.begin();

// if( !WiFly.join( ssid, passphrase ) )
// {
// Serial.println( "Association failed." );

// while( 1 )
// {
// Hang on failure.
// }
// }

}

void loop()
{

if( client.connect() )
{
sensorValue0 = analogRead(sensorPin0);
sensorValue1 = analogRead(sensorPin1);
// float temp = getTemp();
Serial.println(sensorValue0);
Serial.println(sensorValue1);

client.print( "GET /add.php?");
client.print("temp1=");
client.print( sensorValue1 );
client.print("&&");
client.print("moi1=");
client.print( sensorValue0 );
client.println( " HTTP/1.1");
client.println( "Host: grow.gov" );
client.println( "Content-Type: application/x-www-form-urlencoded" );
client.println( "Connection: close" );
client.println();
client.println();
client.stop();
}
delay( 5000 );
// }

// float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

// byte data[12];
// byte addr[8];

// if ( !ds.search(addr)) {
//no more sensors on chain, reset search
// ds.reset_search();
// return -1000;
// }

// if ( OneWire::crc8( addr, 7) != addr[7]) {
// Serial.println("CRC is not valid!");
// return -1000;
// }

// if ( addr[0] != 0x10 && addr[0] != 0x28) {
// Serial.print("Device is not recognized");
// return -1000;
// }

// ds.reset();
// ds.select(addr);
// ds.write(0x44,1); // start conversion, with parasite power on at the end

// byte present = ds.reset();
// ds.select(addr); 
// ds.write(0xBE); // Read Scratchpad


// for (int i = 0; i < 9; i++) { // we need 9 bytes
// data[i] = ds.read();
// }

// ds.reset_search();

// byte MSB = data[1];
// byte LSB = data[0];

// float tempRead = ((MSB << 8) | LSB); //using two's compliment
// float TemperatureSum = tempRead / 16;

// return TemperatureSum;

}

We don't know where you got your WiFly library, but the error message is telling you that it's write() method is incorrectly defined as returning void. The class that it derives from says that write is supposed to return a size_t. Fix your library or find a current version.

Using this library resolved the issue

Thanks so much for your help all!