A "Minimal" Arduino/XBee/Pachube Sensor Network

A couple folks had expressed interest in code from my sensor network, and I was a little hesitant because usually the question was around getting XBees to talk, or how to send data to Pachube, and my code has enough other stuff in it that I didn't want folks to have to wade through to get to a fairly concise answer. Anyway, I finally spent some time and came up with a simple two-node implementation. All the details are in this blog post. (Please don't hoot too much on my blog, it's a work in progress :wink: ... requires more time and effort than I had imagined!)

Nice job Jack. I'm doing something similar and building a weather station.
So far all I have is temperature and sunlight levels, but working on wind speed.

Did you know you can cut out the Boarduino entirely on the end node? All you need to do is power the XBee with 3.3 v. Then program your radio to make pin 0 analog. Then wire the photocell to pin 0 on the XBee instead of the Boarduino.

I hope to eventually get my data into Pachube.

Thanks! Right, an MCU for the sensor isn't strictly necessary if all you have is an analog sensor, but I just chose the photocell because it was simple, I really wanted to demonstrate the more general case. So if the sensor required, for example, an SPI interface, the basics are there, just add whatever code is necessary for the specific sensor.

Appreciate the feedback!

I'd like to hear a little more about the weather station project. I've always been intrigued by these home weather stations, but never got quite serious enough about it. What are you using for sensors, and how are you protecting them from the elements? I like the DS18B20 temperature sensors, I wouldn't mind one outside, but haven't hit on a way to protect it enough from the elements and at the same time not affect the reading.

The link to the sketches on your blog doesn't seem to work.

I actually am interested in the more complicated version with different sensor types, having just designed the PCBs for about 10 different types myself (wired though, not wireless).


Rob

So far all I have is temp & sunlight level and have ordered a humidity sensor.http://www.sparkfun.com/products/9569
I do have an old anemometer (wind )sensor, but am not sure if I can get it working properly.
I may order one with wind direction and rain from Sparkfun http://www.sparkfun.com/products/8942 .

To house my electronics I built a crude Stevenson Shield. Stevenson screen - Wikipedia

I was playing with a setup similar to what Pauly suggests (a temp sensor wired to the xBee's analog pin 1, no Arduino or other uC in the sensor node), using a project out of the Faludi book, but found it to be very unstable - the range of voltages the xBee accepts is only 0-1.2V, so even small fluctuations in power or resistance (I was using typical components - regulator and 5% resistors - not precision parts) seem to significantly affect the result. Ok if you can hand-calibrate each sensor node, but not if you want to be able to add and remove nodes without tweaking the software.

Not sure if there's a solution to this, but that was my (admittedly very limited) experience with it. Since I was just running through the projects to learn the xBee system, I didn't spend a huge amount of time on this issue (since the project I'm working will use digital input into the xBee, not an analog).

Interesting jgalak.
I have also been using the Faludi book and going through the examples. I haven't found my sensors unstable. But, with the photocell I do need to put a 22k resistor on it to get the values down to what the radio can handle. I also have a temperature sensor on the radio and if I don't have a large enough resistor on the photocell, it was affecting the temperature reading.

I built the example from Chapter 5 (Simple Sensor Network), and had horrible results. I built 2 sensor boards, and when they are up, one shows around 40C, the other around -1C, and both fluctuate +- 5*C or so, constantly (the "thermometer" bounces up and down non-stop).

Not sure if the problem is in the power supply, the LM335 sensors, or what, but I think it's at least partially the fact that the 0-1.2V scale is just so darned small.

Not sure if the problem is in the power supply, the LM335 sensors, or what, but I think it's at least partially the fact that the 0-1.2V scale is just so darned small.

analogReference(type)
Description
Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are:

  • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)*
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)*
  • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only)*
  • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only)*
  • EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.*

does this help?

robtillaart:

Not sure if the problem is in the power supply, the LM335 sensors, or what, but I think it's at least partially the fact that the 0-1.2V scale is just so darned small.

analogReference(type)
Description
. . .
does this help?

Nope. Not using an Arduino. Using the analog input on an xBee radio.

Graynomad:
The link to the sketches on your blog doesn't seem to work.

I put them up on github (wasn't a real fan of Google Docs, for this purpose, anyway). Try this link and if that doesn't do it, I'll be glad to email them to you.

I actually am interested in the more complicated version with different sensor types, having just designed the PCBs for about 10 different types myself (wired though, not wireless).

Well, I probably haven't done 10 types myself, but let me know what you're interested in and I'll help if I can. Basically my project has a bunch of other stuff in it like a clock display (either LCD or LED) on each unit, button inputs in some cases, NTP sync on the base unit, then I have my own time sync happening between the base and remotes, a scheme to stagger the transmission times (not sure how critical that is, I should take it out and see), etc. etc.

jgalak:
I was playing with a setup similar to what Pauly suggests (a temp sensor wired to the xBee's analog pin 1, no Arduino or other uC in the sensor node), using a project out of the Faludi book, but found it to be very unstable -

I played just a tiny bit with a TMP36 connected to an Arduino and noticed quite a bit of bobble as well. I like the DS18B20 much better in that regard, plus I think its absolute accuracy is better.

Pauly:
So far all I have is temp & sunlight level and have ordered a humidity sensor.http://www.sparkfun.com/products/9569
I do have an old anemometer (wind )sensor, but am not sure if I can get it working properly.
I may order one with wind direction and rain from Sparkfun Weather Meter Kit - SEN-15901 - SparkFun Electronics .

How are you measuring sunlight? Is there any standard in that area?

Hadn't noticed that weather meter on SparkFun. Might have to give that a little thought, hmmm...

To house my electronics I built a crude Stevenson Shield. Stevenson screen - Wikipedia

Familiar with the concept, but didn't know it had an official name! Thanks!

I've already done the node design and PCBs with nodes to do the following

VOLTS - Three analogue inputs that can read up to 30v with 10-bit resolution.
AMPS - This Node uses a two hall affect sensors to measure two separate currents up to ±20A. The contacts are isolated.
TEMP - Measures internal and external temperature in the range -55 to +150°C.
TCOUPLE - Thermocouple interface, 0 to 1000°C.
RELAY/DIGIN - A voltage-free contact pair for controlling lights, small pumps etc. Can switch voltages up to 100v AC or DC, and currents up to 1A with a 33-watt limit. The contacts are isolated. This Node uses a latching relay, therefore the output state persists if the power is cut. A single ESD-protected digital input is also included so this Node can work as an independent Node with local control.
DIGITAL IN - Four digital inputs that can withstand ±25v continuous and up to 15kv ESD.
SHUNT - This Node is designed to read the voltage across a current shunt.
RTC - A real time clock using the DS3234 chip with an onboard TCXO and battery backup.
COUNT - A high-speed counter to measure period, frequency or events. Features adjustable threshold and hysterisis.
PROTO - A prototyping Node with a large pad array for DIP ICs, several breakout areas for SOIC and SOT devices, and a BUSnet interface.

These are basically "proof of concept" designs to cover a few of the most common needs (as perceived by me anyway).

I have my own time sync happening between the base and remotes,

I'm doing something similar. What resolution does your timing have?

a scheme to stagger the transmission times (not sure how critical that is, I should take it out and see)

How will you handle clashes?


Rob

Graynomad:
I've already done the node design and PCBs with nodes to do the following...

Interesting stuff! I'm trying to learn Eagle in all my spare time. Not very intuitive, at least for me.

I'm doing something similar. What resolution does your timing have?

Just one second. Using DS1307s and have one DS3231. Would like something finer but practically I don't really need it. Took several runs at getting NTP right though, it's a challenge with only one second resolution. I played some games with millis() to provide better resolution in the NTP packet. Still, I'm not doing it "properly" -- only querying the NTP server once, but again, I only really need so much precision, and anything more is not really practical with the hardware I have. But it seems to work reasonably well; just using my well-calibrated eyeball (or tuning in WWV), it's usually within a second.

How will you handle clashes?

Unknown. Haven't even read up on it. Not even sure if I'd have to do anything, perhaps the XBees already have sufficient collision detection.