Introduction: ☠WEEDINATOR☠ Part 2: Satellite Navigation

Picture of ☠WEEDINATOR☠ Part 2: Satellite Navigation

The Weedinator navigation system is born!

A roving agricultural robot that can be controlled by a smart phone.

... And rather than just go through the regular process of how it's put together I thought I'd try and explain how it actually works - obviously not EVERYTHING but the most important and interesting bits. Please excuse the pun, but it's how the data flows between the individual modules that I find interesting and broken down into it's lowest denominator we end up with actual "bits" - zeros and ones. If you're ever been confused about bits, bytes, characters and strings then now may be the time to become unconfused? I'm also going to try and unconfuse a slightly abstract concept called 'Error Cancelling'.

The system itself features:

  • GPS/GNSS: Ublox C94 M8M (Rover and Base)
  • 9DOF Razor IMU MO digital compass
  • Fona 800H 2G GPRS cellular
  • 2.2" TFT screen
  • Arduino Due 'Master'
  • Various Arduino 'Slaves'.

Strangely, a lot of Sat Navs don't have a digital compass which means if you are stationary, and lost, you have to walk or drive in any random direction before the device can show you the correct direction from satellites. If you get lost in a thick jungle or underground car park you're stuffed!

Step 1: How It Works

Picture of How It Works

At present, a simple pair of coordinates is uploaded from a smart phone or computer, which are then downloaded by the Weedinator. These are then interpreted into a heading in degrees and a distance to travel in mm.

The GPRS fona is used to access an online database through the 2G cellular network and receive and transmit the coordinates to the Arduino Due via an Arduino Nano. The Due is the Master and controls an array of other Arduinos as Slaves via the I2C and serial buses. The Due can interact with live data from the Ublox and Razor and display a heading calculated by one of it's Arduino slaves.

The Ublox satellite tracker is particularly clever as it uses error cancelling to get very accurate fixes - a final nominal total deviation of about 40mm. The module is composed of an identical pair, one of which, the 'rover', moves with the Weedinator, and the other, the 'base' is fixed onto a pole somewhere out in the open. Error cancellation is achieved by the base being able to achieve a really accurate fix by using a large amount of samples over time. These samples are then averaged to compensate for changing atmospheric conditions. If the device was moving, it obviously would not be able to get any kind of averaging and would be at the complete mercy of a changing environment. However, if a static and moving device work together, as long as they can communicate between one another, they can get the benefit of both. At any given time, the base unit still has an error but it also has a previously calculated super accurate fix so it can calculate the actual error by subtracting one set of coordinates from another. It then sends the calculated error to the rover via a radio link, which then adds the error onto it's own coordinates and hey presto, we have error cancelling! In practical terms, error cancellation makes the difference between 3 metres and 40mm total deviation.

The complete system looks complicated, but is actually fairly easy to build, either loose on a non conductive surface or using the PCB that I designed, which allows all modules to be securely bolted on. Future development is built onto the PCB, allowing a vast array of Arduinos to be incorporated to control motors for steering, forward motion and an on-board CNC machine. Navigation will also be assisted by at least one object recognition system using cameras to sense coloured objects, for example fluorescent golf balls, which are carefully positioned in some kind of grid - Watch this space!

Step 2: Components

Picture of Components
  • Ublox C94 M8M (Rover and Base) x 2 of
  • 9DOF Razor IMU MO digital compass
  • Fona 800H 2G GPRS cellular 1946
  • Arduino Due
  • Arduino Nano x 2 of
  • SparkFun Pro Micro
  • Adafruit 2.2" TFT IL1940C 1480
  • PCB (see attached Gerber files) x 2 of
  • 1206 SMD zero ohm resistors x 12 of
  • 1206 LEDs x 24 of

The PCB file opens with 'Design Spark' software.

Step 3: Wiring Up the Modules

Picture of Wiring Up the Modules

This is the easy part - especially easy with the PCB that I got made - just follow the diagram above. Care is needed to avoid wiring 3v modules to 5v, even on the serial and I2C lines.

Step 4: Code

Picture of Code

Most of the code is concerned with getting data to move around the system in an orderly manner and quite often there is a need to convert data formats from integers to floats to strings and to characters, which can be very confusing! The 'Serial' protocol will only handle characters and whilst the I2C protocol will handle very small integers, I found it better to convert them to characters and then convert back to integers at the other end of the transmission line.

The Weedinator controller is basically a 8 bit system with lots of individual Arduinos, or 'MCU's. When 8 bit is described as actual binary zeros and ones it can look like this: B01100101 which would equal:

(1x2)+(0x2)2+(1x2)3+(0x2)4+(0x2)5+(1x2)6+(1x2)7+(0x2)8 =

Decimal Digit Value
Binary Digit Value

= 101

And the maximum value possible is 255 .... So the maximum integer 'byte' we can transmit over I2C is 255, which is very limiting!

On an Arduino we can transmit up to 32 ASCII characters, or bytes, at a time using I2C, which is much more useful, and the character set includes numbers, letters and control characters in 7 bit format as below:

Fortunately, the Arduino compiler does all the work of conversion from character to binary in the background, but it still expects the correct type of character for data transmission and it won't accept 'Strings'.

Now is when things can get confusing. Characters can be expressed as single characters using the char definition or as a one dimensional array of 20 characters using char[20]. An Arduino String is very similar to a character array and is literally a string of characters often interpreted by the human brain as 'words'.

// Builds the character 'distanceCharacter':
      String initiator = "";
      distanceString =  initiator + distanceString ;
      int n = distanceString.length();
      for (int aa=0;aa<=n;aa++)                    
          distanceCharacter[aa] = distanceString[aa];

The code above can convert a long string of characters into a character array of characters which can then be transmitted over I2C or serial.

At the other end of the transmission line, the data can be converted back to a string using the following code:

 distanceString = distanceString + c;           // string = string + character

A character array can not be converted directly to an integer and has to go into the string format first, but the following code will convert from a string to an integer:

      int result = (distanceString).toInt();
      int distanceMetres = result;

Now we have an integer which we can use to make calculations. Floats (numbers with a decimal point) need to be converted to integers at the transmission stage and then divided by 100 for two decimal places eg:

 float distanceMetres = distanceMm / 1000;

Lastly, a string can be created from a mixture of characters and integers eg:

// This is where the data is compiled into a character:

 dataString = initiator + "BEAR" + zbearing + "DIST" + zdistance;  // Limited to 32 characters

//  String  =  string + characters + intereger + characters + integer.

The rest of the code is standard Arduino stuff that can be found in the various examples in the Arduino libraries. Check out the 'examples >>>> Strings' example and the 'wire' library examples.

Here's the whole process for transmit and receive a float:

Convert Float IntegerStringCharacter[ ] array ..... then TRANSMIT character array from Master ➜➜

➜➜ RECIEVE individual characters on Slave .... then convert CharacterString IntegerFloat

Step 5: Database and Webpage

Picture of Database and Webpage

Above is shown the database structure and the php and html code files are attached. Usernames, database names, table names and passwords are blanked out for security.

Step 6: Navigation Tests

Picture of Navigation Tests

I managed to hook up a datalogger to the Weedinator control board via I2C and get some idea of the Ublox M8M satellite positioning performance:

On 'Cold Start', shown by the green graph, the module started off with lots of error, quite similar to a 'normal' GPS, and gradually the error became reduced until, after about 2 hours, it got a RTK fix between rover and base (shown as the red cross). During that 2 hour period, the base module is continually building up and updating an average value for latitude and longitude and after the pre-programmed time interval decides that it has got a good fix.The next 2 graphs shows behaviour after a 'Hot start' where the base module has already calculated a good average. The top graph is over a 200 minute period and occasionally the fix is lost and the rover sends a NMEA message to the Weedinator that the fix has temporarily become unreliable.

The lower blue graph is a 'zoom in' on the red box in the top graph and shows a good representative snap shot of the Ublox performance, with total deviation of 40 mm, which is more than good enough to guide the Weedinator to it's loacation, but possibly not good enough to cultivate the soil around individual plants?

The third graph shows data gathered with the Rover and Base 100 metres apart - No additional error was detected - the distance of separation made no difference to the accuracy.

Step 7: Final

Picture of Final

I'm very happy with how the Weedinator control system is turning out :) The data seems to flow between the different modules without any particular problem and the foundations for additional modules seems to be pretty solid with plenty of room for motor controllers and object recognition systems.

In the meantime, the Weedinator chassis design has progressed to the stage where it has an on board CNC machine for cultivating the soil. It will soon be time to get back to the workshop to do some more fabrication.

*Special thanks to SlashDevin for the Ublox NMEA Arduino code.


gismo1 (author)2017-12-31

I like this a lot I came across it while doing some research into GPS navigation, my motive to attach a programmable navigation system for a quad copter. I wanted to program the flight path of the drone. I found it very interesting full marks you got my vote.

MarkC7 (author)2017-12-28

This is awesome. I'm following this build closely! When do you think you'll have the next instructable up? When do you plan to have the entire build finished?

Tecwyn Twmffat (author)MarkC72017-12-29

Thanks for your comment, Mark. Next instructable will be about building the chassis, which was finished today. Should get it published in the next week or so. After that it would be the CNC build but there might be a bit of a delay whilst I try and get some sponsorship from my suppliers.

I was not expecting to get the whole machine finished until 2019, but progress has been faster than expected so there will probably be a working prototype in the Spring 2018 for 'Proof of Concept'.

joshuarw (author)2017-12-18

I’m super impressed! I’d be interested to pick your brain on some work I’ll bedoing in the Amazon.

Tecwyn Twmffat (author)joshuarw2017-12-19

Yes no problem - pleased to help.

yrralguthrie (author)2017-12-17

"If you get lost in a thick jungle or underground car park you're stuffed!"

With a compass or any sort you still have to know where you are in the jungle or garage in order to make use of said compass. Doesn't do much good to know where north is if you don't know which direction you need to travel!

turpie (author)yrralguthrie2017-12-17

That's probably why there is a GPS and a digital compass in this project.

yrralguthrie (author)turpie2017-12-18

I'm not sure why a digital compass is included. A digital compass still operates off magnetism and can unless very closely calibrated at the site of use could easily be off 10-15 degrees. Even calibrated it has a accuracy level far less than the gps. It won't help.

Even using 3 orbital satellites and 1 in the field the accuracy is about 5 cm. or 2 in. Usually errors in this type of electronics are cumulative. So if the machine is 1 meter wide and the field is 100 by 100 meters, there could be a cumulative error of 100 x 5cm or 500 cm without run time correction. The error whatever it is will not correct itself. It won't be plus one time and negative the next.

A digital compass cannot provide any correction. And real time corrections will have to be made. Also if the field is not prepared and very level and flat, the cultivation dept will vary.

A truly autonomous tractor is many times harder to build than an autonomous car. The big 500 hp. tractors than pull 40-50 foot discs are not completely autonomous. They have an operator in the cab that makes small corrections. All the errors in a car can be corrected by optics and radar.

Another thing to consider is that the GPS systems are either Russian or USA, and in both cases are subject to military priority. Any other country is using a GPS system they have no control over.

Any system that is used in a small area would probably be easier to build and far more accurate using in field radar reflectors. There is actually no reason to use GPS for this device. A radar unit on the small tractor and several reflectors could be made with the accuracy of a fraction of the wavelength of the radar frequency. Very small error.

Thanks for the tips. I'll need to repeat my tests with the base station 100 metres away from the rover and see if there is any extra error. Obviously, if it was 10,000 metres away the environmental conditions such as cloud and humidity would be different so there would then be more error.

Radar sounds like a good idea and I did look into it briefly. I don't think it's so easy to get an 'Out of the Box' solution as with GPS / GNSS. I'm sure that if WW3 breaks out then all the satellites will go offline, but until then I think I'll carry on using them!

If the Weedinator is placed in a field and there is no history in the database it will have no idea which way it is pointing without a compass and would have to travel forwards in an arbitrary direction before it got a heading. Mind you, that distance would probably only have to be about 500 mm or less so it's no big deal.

With the compass you'll know which was is north, but without any history as you said, it is still lost. A compass can't tell where it is located. Without gps or a map (or history) the location is not known no matter how far one moves. The line the machine or you moves along could be anywhere. With a compass one has to know where one is to go where one wants.

I guess the compass could be used to check that the history is still relevant.

focussolar (author)yrralguthrie2017-12-17

If you know you are south of the river, north gets you there!

GaryB166 (author)2017-12-17

I used to be a software engineer for a company that was the first to make GPS guidance systems for crop dusters spraying swaths across fields. We used exactly the method you describe: a fixed base station broadcasting "drift" error corrections to the GPS systems in aircraft in the area. We were able to get accuracies to about 30 cm*, whereas uncorrected GPS is only accurate to 15m or so, depending on the geometry of the visible satellites at the time. The GPS boards we used gave readings 5 or 10 times per second; necessary in an aircraft traveling 120 MPH. Considering the math involved, this always amazes me.

* This was in the 1990s, when the military still had Selective Availibity (spoofing) turned on for the civilian GPS signals to limit their accuracy to 100m. The Government turned SA off in 2000 as civilian applications such as aircraft and marine navigation became more common and demanded better accuracy. Techniques such as differential which corrected the SA and natural "errors" was a factor in the military's decision as well.

Tecwyn Twmffat (author)GaryB1662017-12-18

Very Cool!

AdrienR (author)2017-12-17

I did an automonous boat for a lab in my university and we added an inertial measurement unit and a kalman filter to improve the acuracy

Tecwyn Twmffat (author)AdrienR2017-12-18

I think this is what the RTK (Real Time Kinetics) does in the Ublox MCU.

bricobart (author)2017-12-17

The more this project advances, the more I think you're secretly building a troyan horse mars-rover, in fact. Are you sure this rover is actually weed-related? I think you're also building a rocket to launch this thing to outer space in search of cabbage-big diamonds. I'm right, no?

Tecwyn Twmffat (author)bricobart2017-12-18

Yes .... You are absolutely ..... I'm secretly planning to colonise Mars and build a large 5 star hotel for future travellers. There will be a 'Low Gravity' golf course as well.

Hamblinm (author)2017-12-16

what exactly dose the weedinator do

Tecwyn Twmffat (author)Hamblinm2017-12-16

Weedinator - an autonomous agricultural electric tractor that can be used on small farms to cultivate, till, plant and weed seed beds. It will be able to travel up and down 56 inch wide beds, several times a day if necessary, performing a multitude of quite delicate tasks which a big tractor might struggle with. Some of the key advantages are:

  • Less need for heavy cultivation such as ploughing which destroys soil structure.
  • Preservation of soil health by keeping essential natural micro-organisms and nutrients near the top of the seed bed rather than burying them.
  • No fumes or pollution especially in glasshouses or polytunnels.
  • Will help small farms compete financially with big industrial producers.

Will the Weedinator destroy jobs or will it encourage lots more people to set up small farms and help protect the environment? (Let me know what you think).

Hamblinm (author)Tecwyn Twmffat2017-12-16

Growing up on a farm and have just done 15ha of cotton chipping a weed called fleabane i would have loved one of these to use instead.
Early last year i had a idea that was similar to yours but had a 50hp Diesel engine, I didn’t do anything with the idea because I’m still a high school student and haven’t had any experience in programming it (or the money to buy a moter, wheels, ext). But with you doing this i Have learnt a lot and will continue to learn.

Ps. Would you be ok if i have a crack at trying to build a weedinator.

Thanks again
Regards. Mitch

Tecwyn Twmffat (author)Hamblinm2017-12-17

Hello Hamblinm - You are very welcome to build your own Weedinator - just check out the license here:

A 50 hp diesel engine sounds like a good idea.

Hamblin, I can't see how a license would be needed. First in the US at least a person can build whatever they want, so long as they make no profit from it.

Second this is NOT a new concept. There are large tractors used on corporate farms that do exactly the same thing with the same equipment.

The only thing that might be licensed would be his code. And I doubt his code is completely original to him.

Certainly the concept is not new but some of the build details will probably be original - I've not done any searches so don't know for sure what is original or not at this point in time.

Doesn't make much difference, in the US one can still make a copy, so long as no profit is made. 99% chance the code is not original. It is just robotic control. The code from a large GPS controlled tractor could be used.
Also GPS is not precise enough to drive the device unless a ground gps station in the field is also used. Also the large gps tractors still have an operator in the cabin to make minor corrections from time to time. They are not autonomous. An autonomous cultivator would have to be much more precise than even an autonomous car, which depends on several sensors other than gps. Radar, and optics, being two.

The weedinator will never work depending only on satellite gps.

That is very true. The GPS is only accurate to 40 mm in the system and yes it does have the groundstation, base station whatever you want to call it . There are various object recognition options available and the technology is for this advancing very rapidly at the moment. Four example, check out google AIY .

Well no individual is going to actually make a copy, so that is moot. I'm guessing you're in Asia, and there may be a market for the device there, I would think it is limited because of the expense. In the US a Grassinator (lawn mower) would sell a lot more units. I can't see any but a minimum market for a small remote controlled tractor.

You might make money with the Grassinator, but start up is going to be fierce. Also it's going to be hard if not impossible to keep the companies with deep pockets from copying your device. There are a lot of good ideas out there that will never make their inventors any money since they are too easy to copy. Yours is a complicated device, but still no problem for someone to make one almost like it, legally.

Hamblin, you might want to go smaller than 50 horsepower. A 50 horsepower tractor is a typical farm tractor. A small 15 hp lawnmower will spin its wheels pulling a small disc.

Hamblinm (author)yrralguthrie2017-12-17

I was just thinking a 50 hp engine because there a common size to find here in Aus and if I wanted to put a small implement on the back eg a two row planter. And just compared to a 500hp tractor it’s not big at all

HGC (author)2017-12-17

do you know what the accuracy of this system is. I want to build a motorized lawnmower and am trying to figure out a way to automate it.

Tecwyn Twmffat (author)HGC2017-12-17


grapenut (author)2017-12-17

HOW exactly does the Weedinator rid my yard of weeds?

for example; does it spray an herbicide, does it use a small mechanical arm/grabber?

How does it know weeds from say strawberries or grass?

Tecwyn Twmffat (author)grapenut2017-12-17

Most of the work will be done by a rotating claw that moves around inside the Weedinator chassis as in animation. It wont spray any herbicide and will be able to recognise weeds through object recognition cameras. It will probably also have some kind of pest control system eg an on board water canon for pigeons. - not sure of the details yet.

About This Instructable




Bio: Ugly pirate roaming the seas in search of Treasure.
More by Tecwyn Twmffat:☠WEEDINATOR☠  Part 3: Chassis Build☠WEEDINATOR☠ Part 2: Satellite Navigation☠WEEDINATOR☠  Part 1: Drive Mechanism
Add instructable to: