Simple Arduino Wireless Mesh





Introduction: 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 program uploading the mesh data into xively. This is a 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

3 People Made This Project!


  • Creative Misuse Contest

    Creative Misuse Contest
  • Oil Contest

    Oil Contest
  • Water Contest

    Water Contest

18 Discussions

Hi DR_Acula thank you for presenting your project.
I have one question?
How can i now include for example a sensor node in Present Network Mesh

Please adwise

Thank You

Hi Dr. I went through this project, but I dint understood the actual purpose of this project. Are we increasing the range of wifi router in this project? Please dont feel offended if you think that my question is silly. Guide me in the proper direction. Thanks in Advance.

2 replies

Good question! Well initially I was building wifi router extenders, but found they have limited range, decent range needs large antennas (1 meter dishes) and use a fair bit of power. So this mesh was a way of sending simple data further distances with less power. But of course, the data is very limited and certainly can't do pictures and video etc.

From what I understand you are taking in simple data temp, levels, etc .. What about using it with a camera system and wanting to pull images from the field.. This setup sounds like what I'm looking for.. but needing image or video footage.


1 year ago

Scois: WHOA THERE on high power modules - at 433 MHz Kiwis & Aussies (you seemingly are in Brisbane?) are allowed just 25 milliWatts transmitter e.i.r.p. ( effective isotropic radiated power)... Stan.


1 year ago

Awesome project. Is it still up and running?

6 replies

Very much so! The wireless data has to go over a hill and through trees so no direct line of sight. Could have used high power radio, but with low power and short range and multiple hops there is no interference to the neighbours. Data used to go to xively but they are subscription, so instead goes to Thingspeak. Data is here Some minor tweaks to the software along the way, now have 32 nodes instead of 16, and also every node has a display - this uses more power, but it makes debugging a lot easier. I like to see each node talking to at least two others, so there are multiple data paths and the system then can handle a few nodes not working.

Oh, I've got so many questions.

\I am trying to achieve what you have already accomplished. I am playing around with building a sensor network for a farm. I want to use rf as gsm is not available. You mention that you could have used high power radio. This will obviously increase the distance between the nodes. Do you have an example of a high power radio you have considered? What was your reasons for picking the APC220 radio modules. I see there range are up to 1000m, but they seem to be a bit pricey ($40+). What do you think about lora?

I am amazed at what you have done with Thingspeak. I am going to have a look at it in more detail. What advantages does Thingspeak have for you?

How do you measure the water level in your tanks? Floaters?

My apologies for all the questions. I have been playing around with arduino for a few months now and are still a noob.



Hi Scios, sorry about the delay replying. Re different radio modules, see Manuka's comment from yesterday. He is a guru when it comes to radio links and always has access to the best modules, as he mentions, LoRa. I'm pretty happy with the APC220 modules, as I like the idea of multiple data paths for a true mesh, so one node can go offline (eg when a koala chews the power wire, and yes, that seriously did happen!). Thingspeak lets you log in once you have a pile of data and change the type of graph, averaging and other parameters. Two catches on an arduino. First, stick a small heatsink on the ethernet chip, and second, it sometimes doesn't reset when the power is cycled so I brought out the reset button to a big button on the front of the box. Transducers - farnell or radiospares, MPX5050 which is 5V = 5metres, and MPX5500 which is 5V = 50 metres. I've been running these transducers for years, much more reliable than float switches (spiders go and build nests in the float switch mechanism).

I though I scared you off with all my questions. How do you used the transducers? How are using them? Outside of the tank or sitting on the bottom?

I though about using an ultrasonic sensor but it there appears to be a few issues with these. I've got a few on order from China (estimated delivery 14 to 3,243 days) will give them a go.

Thanks for telling me about Manuka. I have read his Lora Instructable article a few times and pick up something new every time.

Is it possible to setup a mesh using Lora?

I came across Talk2 Whisper Node, developed by a company here in Brisbane. Appears very promising.

What other sensors are you using?

Sensors are outside the tank. Tank => tap => T piece and put a blank end in the T. I use 4mm black garden hose and barbed connector eg the one at the top of the page and trim the barb off one side with knife, then drill a 4mm hole in the blank that goes into the T and glue it in with araldite. There probably is another way to go from 4mm pipe up to (say) 40 to 50mm that is on a tank. The 4mm garden pipe fits nicely on the MPX5050 sensors. Other sensors - LDRs, LM35 temp sensors for the pool, the pulse output of a 3 phase power meter (to measure solar power). Anything that can convert to 0 to 5V

Thank you very much for all the info. Now I have to go a build something usefull.

Hi Scios, your message from 17/2 appeared on my email feed but it isn't coming up on this comment page - something not working at Instructables. Maybe send me an email

Nice project. I like your code.

Hi. I am building a similar project and ran into the same issue with power consumption. I moved the radio and the temperature sensor to an digital pin. Set up the pin on the temperature sensor to go high every 10 seconds. If something changes the pin the radio is getting its power from goes to high. The radio only transmits if something changes. The rest of the time the arduino sleeps using the narcoleptic library. I don't have screen on transmitter. By making these little changes the arduino nano pulls 8 milli amps most of the time.

The ESP8266 chip uses a heck of a lot of power setting up and looking for other networks servers and clients . Seems about 40% of its memory is this stuff then yours goes in too.Power supply seems to be the failing and even with ESP.deepSleep() it still seems to eat batteries in days. So if you are considering the work involved in switching I would address the battery problem first.

1 reply

Agree with those comments. I initially had the idea of a mesh of wifi routers, each acting as a bridge, but a typical router is 5 to 12 watts, plus the power of the ESP8266 modules. Hence this design that uses APC220 modules to do the long haul data comms, and just have one point in the network where it links to the internet. Also 433Mhz is better than 2.4Ghz for going through trees and over hills. The whole "Internet of Things" tends to gloss over the fact that a router is part of the system and really is not something that can be battery powered. Even arduino's out in the field are borderline for battery power. 100mW still tends to need large panels and large batteries to cover a worst case scenario of clouds for a week.

One thing though with the comment about ESP8266 power supply failing, I agree, and I have had good results putting a beefy capacitor like 4700uF across the ESP8266 supply.