Go Down

Topic: Barnduino, ArduTablet/Data Terminal (Read 8575 times) previous topic - next topic


I have finally finished my Data Terminal prototype!

Still have to mount a couple of things, Digital Compass, Barometer, GPS and maybe an SD card reader and one of thos AM/FM/SW receivers.
I'm using a SeeedStudio Mega, There is a DS1307 RTC breakout, a regulated XBee Explorer with a series 1, 60mW, U.FL connector XBee module.
On the prototyping board there is a 24LC256 I2C EEPROM.

On top I have the XBee Antenna jack, with a 3dBi Omni.
The switches will be
- Master Power
- LCD Power
- GPS power, if I can find a spot to mount my EM-406 where it can see the sky.

The LCD is a SparkFun HUGE LCD with serial back pack.
It's a great display, but forget buying a civilised case! It's just too big!

At the moment all it does is show the time and the "Up"/"Down" buttons change the LCD brightness.
The buttons are rated IP67, so they will be splash and dust proof, also tougher than the rest of the unit.

I've put together 2 of these Mega/XBee prototyping rigs.
After ripping the U.FL connector off a U.FL to RPSMA lead, I decided to put together something a tad more robust.

The 2 nodes are identical.
- Genuine Mega
- SparkFun XBee shield, I use one of the hardware ports, so I cut the link, switch to "DLINE" and run 2 leads to Serial3 in this case.
- DF Robot protoyping shield, with an SHT15 temperature and humidity sensor

The codes on the nodes look like this

#include <Sensirion.h>

const uint8_t dataPin  =  2;
const uint8_t clockPin =  3;

float temperature;
float humidity;
float dewpoint;

Sensirion tempSensor = Sensirion(dataPin, clockPin);

void setup()
  //XBee UART

void loop()
  tempSensor.measure(&temperature, &humidity, &dewpoint);
  Serial3.print("Barn 1: ");  // This is the only difference, the other
                              // node prints Barn 2:
  Serial3.print("Temperature: ");
  Serial3.print(" C, Humidity: ");
  Serial3.print(" %, Dewpoint: ");
  Serial3.println(" C");

Back here in the house, I have my XBee "Base Station"

I have it hooked up to one of my ASUS eee's, a 701, running Ubuntu Netbook Remix, a variant of Hardy Heron.
(no, I didn't buy that Porche mouse! My girlfriend did! Makes a great night light!)

As you can see from the code it is just the Sensirion example printing to the XBee.
The arbitration or anti collision is being handled by the XBee's.
The couple of times Barn 2 has not shown up here is due to farm traffic, both nodes are in great big Faraday cages, 100 odd metres away.

I'll write better code, but, as an exercise in saving me extra exercise walking down to the barn's every half hour, it's great!

A friend of mine just said "Why bother?"
He is a grep, awk, sed freak and has written a bash script to log the data.

Hmmm, why didn't I think of that?

Anyway I'm thinking of "packaging" up the data like a GPS sentence.


I'm not sure if I need a checksum, what do you guys think?

Well that's as far as I got today.

The data terminal/ArduTablet was originally going to be my "Tricorder" or "Tracker Jacker"
Originally it was going to be stuffed with as much sensing gear as I could cram in.
There was going to be a companion unit on my dogs walking harness with an Arduino, GPS, compass and XBee.
The idea was I would be able to know where my dog was when we were out walking or hunting and I lost sight of him.

Sadly, I had to have Kanada euthanised a week ago.
He was the last of my 6 dogs that I moved up here with.

It was so unexpected, he was only 8, I thought I'd get at least another 4 - 5 years with him, just going on how long the others lived.
They all lived to 12 - 18! Nanook, White Dog's Gran, was 6 days shy of 18!
He is with his mum, dad, sisters, brothers, uncles, aunts, Grandma and Grandpa now.
This is the first time in 25 years I've not had a dog next to me and the first time in my life I've not had a pet.

I will build a "Tracker Jacker" and remote unit, borrow my friends dog to try it, but not just yet.

Anyway that's my Barnduino and "Great Big Thing"!

I consider this my first "real" Arduino project.
Up to now I've just been messing around with breadboards double sided taped to bits of acrylic or MDF.
It's been fun and a good way to learn the language.

The Barnduinos will eventually be 328's with a Sensirion Temperature and humidity sensor and a serial link back to the barn control room.
Whether that link is an XBee, RS-232 or RS-485, I haven't decided yet.
It's way over kill to use a Mega the way I am now!
Especially a genuine one!

The SeeedStudio Mega Clones are great value for money, less than half the price.
I'll be using one of those to collect data from a few of these nodes in each barn as well as data from flow sensors on the bird water lines.
We also need more flexible control of our lighting.
The ability to shut off the water lines in the event of "abnormal" water flow is being considered as well.

I have broken the whole project into separate modules.
Normally I do my hardware and software development that way.
Especially with software, I think of writing code like I write fiction or other prose.

A new paragraph should be a new idea, or new setting, or change of pace.
So too with coding, a new unit (what do we call them in Arduino?) for a new idea or unit.

I have separate unit for each of my sensors, the LCD, keypad, etc.
I use a separate tab in the IDE for each unit and the main tab is what binds it all together.

Old school Pascal head still writing units!



Congratulations, it looks an impressive project


Terribly sorry to hear of the dog's passing.  My fourteen year old beagle (cute but none too bright) is napping on the couch, and my cat (trying to remember now.. he is either 18 or 19) is right next to her.  Of course it's inevitable, but I must admit it will be a serious blow and some sad days when I do lose them.  Never easy to say goodbye to a loyal friend.

I've watched you work on this over time, I think I remember your original post about it.. I was pretty new here then myself.  Yours was one of the projects that really turned the inspiration on for me, actually- I saw the reactions and the support you were getting in even fielding it as "I want to make a...." - it was the imagination and the community support that convinced me that Arduino was going to be the "right" platform for me.  It doesn't hurt that I was a farm kid myself.. 


Great project, iPad better look out :)

Are you in Aus, the photo of the bush looks very Australian (never mind, I just looked up Jupiter Ck, near Adelaide eh?)

Anyway thanks for the write up, very interesting, and if you decide to go RS-485 look me up I may have my project running by then.

Rob Gray aka the GRAYnomad www.robgray.com


Sep 16, 2011, 06:58 pm Last Edit: Sep 16, 2011, 07:11 pm by draythomp Reason: 1
It appears we think somewhat alike.  I couldn't help but think how some of your devices look like mine.  Tie wrapped to a pipe, stuck in a corner or buried under something.  My neighbors think I'm totally nuts.  Unfortunately, I had to start putting things in some kind of enclosure.  I have pack rats and they love carpeting their floor with chewed up wire and decorating their walls with electronic components.  So almost all my devices are in some kind of enclosure physically screwed to the wall, fence or pole because a tie wrap dries out and breaks in about six months here.

I really like how you put the antenna on something solid and have created sensor boxes that you can put in different places.  I took a slightly different tactic in that I used smaller XBees and hunted down relay points to put a forwarding device so I could get the signal into the house.  I use a GPS to grab the time and broadcast it so every device can get the correct time.  Why get a RTC when you have GPS and XBees?  The GPS is up in the attic so it can get a signal; it also is where my coordinator radio is.  Once you get the coordinator programmed, you really don't have to mess with it so I stuck it up there.

Your display device is way cool; much more ambitious than I'm planning.  My general purpose display will eventually be some kind of tablet computer.  I want the bells and whistles that they have  for displays, buttons and such, plus the resolution and display real estate won't hurt any.

My home protocol is evolving.  I've found that, once the device has the correct time, sending the time with every message helps me to keep track of things going on.  I am also starting to keep track of when the device last reported in.  This is nice because I can check that number and report that some device is off line for some reason (trying to outguess the pack rats).  Makes for a lot of traffic, but it's only electromagnetic waves and electrons.  So, I use something like "NThermo,time,status,status,status....".  My most recent device, an acid pump for the swimming pool, sends "AcidPump,time,On,LOW" every two minutes.  I really don't need it that often, but why not?

So, similar to you, I can watch the XBee traffic and see what is going on out there without a bunch of hardware to decode it.  

However, I found out that I wanted to be able to concentrate all the data into one location so I could just glance at it and tablets haven't gotten to where I want them to be so I built a box to collect and control stuff.  Like you (again) I used a mega2560 and hooked it to an XBee that watches the traffic.  I flash lights for each of the devices, rotate a display to show me what's happening and have a web server on it that gives me a display of this stuff.  I can turn off my laptop and leave town and it will handle things for me.  See, this way I can set a timer on the control box to turn on the pool lights at 9PM and back off at 10PM and then just leave for a couple of days.  If I get concerned about something, grab someone's computer and hit the box and it will tell me what is going on.  Plus, I get to show off a bit.

Shoot, we both live in relative wilderness areas, but I bet mine is hotter.

Oh, I started experimenting with small versions of the arduino for dedicated tasks.  I'm currently using the ardweeny and putting it on a board with whatever else I need.  I can get a dismantled wall wart, XBee, relay or sensor or two and the ardweeney in a 4x4 (inch) outlet box weather proofed and every thing.  Then I can just run wall power to the box; surprises the pack rats when they chew through that thing.


I thought the display looked really big in the initial picturses, until your thumb showed up!

What will the  buttons do?

The message data repeats often? I wouldn't bother with checksum unless the receiver is going to ask the sender to resend if it saw a bad message come in.

How'd you manage to post all those pictures in one post? I try putting in 2-3 and get m post rejected with a message too big error.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


The cool thing about Series 2 XBees (I don't know if series 1 does this) is that the messages all have checksums.  I have a number of little devices that transmit broadcasts about what they're doing and one that receives all this in API mode (I use mode 1 so I don't have to mess with certain characters).  Receiving in API mode like that, I can easily check the checksum and see if the message was messed up somehow.  It happens, infrequently, but it does happen and I don't use that message.  The devices send their status a little later anyway, so losing one message is no big deal.  When I send a command to do something, I expect a response from the device I'm sending to.  If it doesn't respond, then do it again, etc.

I totally love XBees, 20 bucks US and I have a network device that handles all the crap for me and never hangs up.  These little things just work once you get the hang of it.  Heck, you can reset them and they'll come back online in less than three seconds.

OK, I'm advertising too much.  I'll shut up now.


How'd you manage to post all those pictures in one post? I try putting in 2-3 and get m post rejected with a message too big error.

Offsite image hosting. If you look at the image URL, it's photobucket. You could use Image Shack, Flickr, imgur, etc.

@cyberteque -- you have a Rotel receiver in your barn? :) I've been hanging on to an old Marantz that might see garage duty at some point, that is if I ever have a garage again. And if I doesn't cost an arm & a leg to get it repaired.
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier


Sep 17, 2011, 06:36 am Last Edit: Sep 17, 2011, 07:21 am by cyberteque Reason: 1
@TonyD - Thank you!

@focalist - Thanks man, it is a real shame our critters don't live as long as we do.
Seriously thinking of getting a horse, I've always wanted one.
There would have to be some use for an Arduino powered device on horse!
GPS saddle or something.  :)

@Graynomad - What do you think would be better in the barn?
I'll use a low baud rate, the Arduino UART's will go down to 300 baud, I might be able to get away with RS-232.
At the moment I'm not sure how noisy the electrical environment is.
There are single and 3 phase motors switching on and off at unpredictable times, the energisers for the anti-perch wire, which by the way, really freakin' hurt!
We also have to contend with the power going out, sometimes it's not even long enough to get the backup generator to start.
Which brings us to this beast!
The diesel engine gets serviced, but I would not know what to service on the actual generator.
So who knows what the power quality is like, from what I've seen the genset is probably cleaner that the mains.

Bought me a shiny new SeeedStudio DSO Quad oscilloscope, so I'll be able to have a better idea of electrical noise.
I've run RS-232 in some pretty horrible environments and have had reliable comms.
MAX-232's rock!

@draythomp - LOL
I had no choice with the nodes, they will be in enclosures, I just had to get this working fast.
That's why the code is so simple.
We now have a cron job executing a bash script every 10 minutes and writing the data to a file.
I'll have to use the compressor to blow the dust out off my breadboard and Arduino sockets.

The aluminium extrusion I used is the stuff they make window and door surrounds out of. I picked up a heap of different cross sections from a shop fitters off cut bin.
I went for the XBee 60mW with external antenna because I thought I would need all the signal strength I could get.
Those U.FL connectors are really fragile and messing around trying to hold up a rubber duck antenna with tape or whatever is tedious at best.

It turns out I can receive data pretty much anywhere in the valley from Barn 1, but in only a few distinct places around the farm from Barn 2.
I'm thinking it's the proximity to the corrugated iron control room wall.
The 20mm squared mesh on the barn sides seem to be pretty transparent to 2.4GHz.

I like your idea of using a GPS as a clock source, the Time library can use a GPS sync provider.
That was how I set the time on all my DS1307 RTC's.
I've been experimenting with my uM FPU, which is a really groovy chip!
One of the Micromega examples calculates sunrise and sunset times based on GPS position.
We are trying out giving the birds a constant day length.
Summer is not that much of a problem, but winter days here can be really dark and short.
Seriously, who wants to get out of bed at 5am, just turn on 2 switches when it's around 0C, raining and windy?

It can get pretty hot here! We had a few days last summer over over 40C, down in Adelaide, on the plain, it was hell!
We had city friends asking if they could camp out in the field!

@CrossRoads - The buttons on the right will be navigation for menus, list selection, stuff like that.
The other 4 will be modal, depending on which screen or menu you are in.
This was the original keypad I was going to use.

One of the data "screens"

The early days!
My first Mega, with GPS shield on top of a DF Robot Mega Prototyping shield.

The 2 shed nodes are just "free running", not synced in any way.
The data gets sent every 2 seconds.

I used photobucket to put the photo's in.
I love that we get to see them in full res!
My Cannon IXUS 75 is a great camera!

@justjed LOL
The Rotel is in my room, hooked up to my computers.
When I hit something with a rocket or grenade in Quake, I want it to feel like a rocket or grenade just exploded!
In storage I have a Marantz DC 500 that I would never part with!
At least I can work on it!
My Kenwood surround amp has a power supply problem, somewhere in that big black box, there must be a power supply.
But I haven't gotten it apart that far! It has like 12 pc boards!
No way I'm going to buy the service manual for $250!!!
I just have to take it and get it fixed!


What do you think would be better in the barn?

Well my preference has always been for 485 over 232, it's intrinsically more robust by design and you can multi-drop. It ain't used in industry for nothing.

They both need a drive chip so no advantage ether way there.

485 does need an extra wire but normally if you're running a wire it may was well be a 3-way as a 2-way. Truth is 8-way CAT5 or 4-6 way telephone cable is probably cheaper than anything around anyway.

Rob Gray aka the GRAYnomad www.robgray.com


Is there an RS-485 driver chip?
Like a MAX-232? I still have half a rail of those.
I saw the SP3485, but was confused by the half duplex thing, do you need 2 of them?


Is there an RS-485 driver chip?

Only about 10,000 varieties :)

Like a MAX-232?

Better because you don't need caps.

You can go full-duplex (4-wires normally 14-pin chip) or half-duplex (2-wires normally 8-pin chip)

Have a look at the SP490, 8 pins, full-duplex, no control inputs. I'm using them on my little "Arduino network dongle" gadget I'm working on.

Rob Gray aka the GRAYnomad www.robgray.com

Go Up