Intro: Simple Arduino Wireless Mesh
Build a low cost simple wireless mesh using arduinos and long range APC220 radio modules. Wireless mesh networks can handle individual nodes not working and are tolerant to environments such as forests and hills where data may not be able to go directly from one point to another.
Step 1: How the Mesh Works
This is a wireless mesh with a range of up to 1km between nodes. There are 16 nodes in each mesh, and all nodes use the same frequency. Each node can sample two analog voltages and shares these with the mesh. The mesh is tolerant of faults with individual nodes, and data takes multiple paths to get to the destination. Nodes can also interface to the internet, and to other meshes that that been set up for a different frequency. Individual nodes may only be able to talk to a few nearby nodes.
One problem with building meshes is complexity. This mesh simplifies things by using a synchronised clock, and much of the mesh protocol revolves around getting the clock working. Each node exchanges the time with nearby nodes. If a node receives time data from a nearby node it notes the number of the node, and the number of the last node it received a time from, and takes the lower of the two. If node zero is in the mesh, then all the nodes ultimately synchronise to node zero's time. If node zero is shut down, then node 1 will take over this function.
Nodes flash a led in time with their clock, and within a minute or so, all the nodes will be flashing in synch. Once this is working, each node transmits only during its allocated time slot. This avoids data clashes and minimises errors.
Each node collects its own data and adds a time stamp to this. When a node transmits, it transmits the data for the entire mesh, including the time stamps. Any node that hears this data looks at the list, looks at its own list, and replaces any old data with newer data.
This way, new data propagates through the mesh.
There are 16 nodes and each node has two analog values, making a total of 32 integer values to share through the mesh. The number of nodes and the number of analog values per node is limited by the time needed to cycle through the entire network. Each node has 4096ms to transmit all its data (9600 baud), and so it takes 65 seconds for all the nodes to transmit in turn and for new data to move through the mesh.
Read world data that can be shared are temperatures, tank levels, stock trough levels, rainfall, humidity, dam levels, local battery data if a node is solar powered, and other data that needs to be shared over a large distance and where time is not so critical.
Step 2: Hardware
Hardware is as simple as possible. An arduino, 20x4 LCD display and an APC220 radio module.
Optional extras are a $2 switching module to step voltages down to 7V to power the arduino with minimal heating of the onboard regulators. The optimum input voltage for an arduino board is 7 to 8V. Any higher and the heatsinks get warm and energy is wasted. Any less and the onboard regulators may lose regulation and analog inputs may not be accurate.
The 20x4 display is configures for I2C communications as this only uses two arduino pins. The I2C module can be purchased separately or it is possible to buy 20x4 displays with the module already attached (search 20x4 lcd I2C).
The APC220 module comes with its own antenna that has a range of about 500m through trees. It is possible to replace the coiled antenna with a straight piece of wire 17.3mm long and this extends the range another 20%. It is also possible to add a ground wire of 17.3mm and this creates a dipole of 34.6mm and this extends the range another 20%. The dipole is mounted vertically for an omnidirectional pattern.
For reading analog voltages, the arduino inputs are more stable if a 10uF capacitor is placed across the inputs at the board.
Step 3: Big Mess O Wires
I'll see if I can get Fritzing to work and make this look a bit neater. On the UNO boards I have, there are a group of pins just near the analog inputs that have 4 pins for an I2C connection - 5V, SDA, CLK and 0V. These go to the 20x4 I2C module.
For the APC220, pin 1 is Gnd, pin 2 is 5V, pin 3 is not connected, pin 4 to Arduino D9, pin 5 to Arduino D8, pin 6 and pin 7 are not connected.
The APC modules come with a little USB programmer and this can be used to change the frequency and the baud rate. If you run the utility program, for some reason windows needs you to right click and "run as administrator". The default options though are fine, ie 433Mhz and 9600 baud.
In the photo above is a little RS232 module. I've got this connected to pin
Step 4: Nodes in the Field
Nodes out in the field need to be self contained with power, and robust enough to handle wildlife. (The cow in the background likes chewing wires!)
This shows a node in a weatherproof box. The solar panel is over-sized so it will charge on cloudy as well as sunny days. Inside the box is a charge controller ($15 or so on ebay) and a SLA battery. A switching regulator module ($2) drops the 12V down to 7V for the arduino. A 20k/10k divider means the arduino can measure the volts on the battery and feed this into the mesh. This node is not sampling any other data - just acting as a repeater.
The antenna is built in some 25mm PVC downpipe. It is painted green and is a bit hard to see and is above the post. This is sealed up and has the APC220 module inside, along with the dipole for maximum range.
Step 5: Code
Attached is the arduino code as well as the included drivers for the 20x4 LCD and the serial port to talk to the APC220.
The arduino code has more information on the mesh protocol, and also includes code for a scrolling 20x4 display.
I hope this has been useful!
In step 1 the photo shows a vb.net program uploading the mesh data into xively. This is a vb.net program, though it may be possible to port this into one of the little ESP8266 chips and then the laptop isn't needed.
Next project - building a better battery supply using multiple NiMH batteries connected in parallel to make a high amp hour 1.2V source. Includes charger, discharger and all stepup modules.
Also putting up some 433Mhz yagi antennas on towers for even longer range.
Cheers, James Moxham