Coding errors between the Arduino Uno and SDI-12 interface on Decagon Devices

693 views Asked by At

I have been working on a project recently using a sensor for electrical conductivity in soil (A 5TE sensor from Decagon Devices) with my Arduino Uno. I am ready to code, and found this example code on GitHub (the example code is there when you scroll down the page). When trying to run it on the latest version of Arduino, it gave me these compilation errors:

sketch_dec15a:7: error: expected initializer before 'void'

sketch_dec15a:4: error: 'SDISerial' does not name a type

sketch_dec15a:9: error: expected initializer before 'void'

sketch_dec15a.ino: In function 'void loop()':

sketch_dec15a:22: error: 'connection' was not declared in this scope

NOTE: I believe I installed the library correctly, but am not 100% certain...more like 85%.

What's wrong with the code and how can it be made to work?

1

There are 1 answers

3
Nateowami On

The example code is wrong. Look at the compilation errors. The first thing it says is:

sketch_dec15a:7: error: expected initializer before 'void'

So what it's saying is that it found something that said void and expected to see something else first. void occurs only twice in your code, so we can't be far. Let's take a look at the code immediately surrounding it the first void:

char tmp_buffer[4];
char sensor_info[]
//initialize variables
void setup(){
      connection.begin();
      Serial.begin(9600);//so we can print to standard uart
      //small delay to let the sensor do its startup stuff
      delay(3000);//3 seconds should be more than enough
}

Right before the void setup(){ is //initialize variables. That's just a comment, and not code, so it doesn't relly count. Looking back one more line we see:

char sensor_info[]

Something is wrong with that line. Work on it and see if you can figure it out (check the other lines for "hints"). If you can't figure it out, the answer is right below (put your mouse over it to see it):

It needs a semicolon ";" at the end to complete the statement. Because the semicolon is missing, it thinks "void setup(){" is part of the previous statement.