Help with wording sketch

Hi all.

I’m trying to use the Arduino to upload all the sensor information to Xively. I’m trying to upload one wire temperatures, and ultrasonic distance sensor (converted to Litres).

I’ve gotten all the temperatures uploading fine, but I’m having issues compiling the sketch to include the ultrasonic sensor (which I had working perfectly in another sketch).

The error code I’m getting is:

Aquaponic_Sensors.ino: In function 'void loop()':
Aquaponic_Sensors:95: error: 'WaterLevel' was not declared in this scope
Aquaponic_Sensors:95: error: 'ultrasonicValue' was not declared in this scope
Aquaponic_Sensors.ino: At global scope:
Aquaponic_Sensors:124: error: function definition does not declare parameters

This is the part of the code that was working with the temperatures.

//sensorValue function
 float sensorValue (byte deviceAddress[])
 {
 float tempC = sensors.getTempC (deviceAddress);
 return tempC;
 }
}

So I tried to copy it and make it work with the ultrasonic sensor. But it’s bouncing back with errors. It’s saying that waterlevel/ultrasonicSensor aren’t declared in this scope, but the working sensorValue isn’t anywhere else in the sketch, but that’s working.

float ultrasonicValue
 {
 unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
 float level = (650 - ((uS / US_ROUNDTRIP_CM) * (10)));
 return level;
 }

I’ve attached both sketches (I believe the larger is too big to put in this post).

I’ve been at this for the last 5 hours, and my head hurts :frowning:

Any help would be greatly appreciated.

NewPingExample.ino (1.09 KB)

Aquaponic_Sensors.ino (3.68 KB)

float ultrasonicValue

{
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
float level = (650 - ((uS / US_ROUNDTRIP_CM) * (10)));
return level;
}

Have you forgotten something in the function, like perhhaps a pair of parentheses?

I just got it to compile!

Woo!

I really was quite close. Thanks for the help!

Now to see if it uploads the data properly!

Dude! I could kiss you! :slight_smile:

https://xively.com/feeds/352242277

All working!

Columnmn:
https://xively.com/feeds/352242277
All working!

Great! I see your Temperature in the shade is 25.5 C.
I just glanced at my weather station, and see that the outside temperature is -25.9 C.
What great symmetry!

lar3ry:

Columnmn:
https://xively.com/feeds/352242277
All working!

Great! I see your Temperature in the shade is 25.5 C.
I just glanced at my weather station, and see that the outside temperature is -25.9 C.
What great symmetry!

That sounds like snow, that's be awesome to see. Don't get much of it here!

It's currently sitting on top of my fridge, I'm waiting for one of those cheap wifi repeaters to arrive from china.

Thanks again!

Columnmn:

lar3ry:
Great! I see your Temperature in the shade is 25.5 C.
I just glanced at my weather station, and see that the outside temperature is -25.9 C.

That sounds like snow, that's be awesome to see. Don't get much of it here!

This was last year. That pile was from my driveway. The pile was about 85 ft. long, 20 ft. wide, and 12 ft. high.
You probably would not have enjoyed it quite as much as you think. :slight_smile:

http://dl.dropboxusercontent.com/u/41759425/Snowy_Winter.jpg

It’s 32C at the moment in Adelaide, I’m drooling at that snow at the moment :slight_smile:

Grass is always greener.

Although I’m sure the novelty of snow would wear off soon enough. I’m only seen it a handful of times before.