Coder Social home page Coder Social logo

binnes / wifimeshraspberrypi Goto Github PK

View Code? Open in Web Editor NEW
298.0 25.0 84.0 4.79 MB

Workshop to create a sensor application over a WiFi Mesh network

License: Apache License 2.0

mesh raspberrypi iot batman-adv ibm wifi 802-11s mesh-networks raspberry-pi

wifimeshraspberrypi's Introduction

Quick links :


Home - Part 1 - Part 2 - Part 3 - Resources


Create a Mesh Network over WiFi using Raspberry Pi

NOTE - THIS WORKSHOP IS NO LONGER BEING MAINTAINED, IT IS HERE FOR REFERENCE ONLY

Welcome to this workshop, where you will create a mesh network over WiFI using Raspberry Pis. After creating the mesh you will use it to extend an existing network, then use the mesh to connect sensors to the Internet and allow other devices (not participating in the mesh) to connect to the Internet via the mesh network.

mesh image

Expected outcomes

After completing this workshop you should be able to :

  • understand how mesh networks work at a high level
  • create a mesh network using Raspberry Pis
  • connect the mesh to an existing network, understanding the difference between routing and bridging network traffic
  • enable non-mesh devices to use the mesh to connect to the Internet
  • create a sensor application on a mesh node which securely communicates with a cloud application

Prerequisites

To complete this workshop you need some hardware and some prerequisite knowledge. Mode details about the prerequisites is available in the Additional Resources section :

  • A minimum of 2 raspberry Pis (3 or 4 Model B(+)) additional Pis can be added to extend the mesh, which can also include Pi Zero(W). You also need to have an SD card to hold the filesystem and a power supply for each Raspberry Pi and optionally a keyboard, mouse and monitor if not doing headerless setup (details in Additional Resources)
  • A laptop or desktop computer with a modern OS (Linux, MacOS or Windows - windows users will need additional software to communicate with Raspberry Pis if using headerless setup)
  • Ability to flash the SD card for the raspberry Pi (SD card slot in laptop or USB adapter and appropriate software)
  • Ethernet network, cables and connection to connect Laptop to Ethernet (if this isn't available then WiFi is also possible)
  • Internet connectivity is required
  • Optional WiFi USB dongle(s) if want to enable WiFi rather than Ethernet connectivity (Note: some WiFi dongles need more power than a Raspberry Pi USB interface can supply, so a powered USB hub may be needed)
  • DHT11 or DHT22 temperature and humidity sensor and an addressable RGB LED. You also need 6 Female to Female connector cables. Additional details about of these components are available in the Additional Resources section
  • You should be able to setup a Raspberry Pi and get access to a command line on the Pi (help available in the Additional Resources section)
  • You should be familiar with basic linux command line commands and be able to edit a text file on the command line. If you need help there is a section on the raspberry pi site and there are plenty of tutorials available with a quick web search. For new users, nano will be an easier option than vi and remember ^x means hold the control key then press x.
  • An IBM public Cloud account (the free, lite account is OK, if you have resources available in the account to deploy an application)

Outline

This workshop is split into 3 parts:

  • Part 1 will setup the mesh network using at least 2 Raspberry Pi boards. Part 1 assumes that Ethernet connectivity is available to connect the mesh network to your home network (Gateway node connection to Home/Office network in above image) and also allow a non-mesh device to use the mesh network to access the internet (Bridge node connection to Ad-Hoc network in above image), as shown on the image at the top of the page.
  • Part 2 is optional. It converts the Ethernet connection joining the mesh to your home/office network to WiFi. It also provides a WiFi access point to allow other devices to use the mesh to get to your home/office network and onto the Internet. wifi options
  • Part 3 creates an Internet of Things application to sense temperature and humidity and then sends the data to the IBM Cloud. An application running on the IBM Cloud receives and processed the sensor data then sends a command back to the raspberry Pi to set the colour of a multi-coloured LED light. The mesh network is used connect the Raspberry Pi hosting the sensor and LED to the Internet, allowing it to send and receive SSL encrypted data.

Network connectivity

During the workshop you will be switching your laptop to use local networking created by mesh nodes. Until the mesh is fully operational you may have times when you need to work on a Raspberry Pi, but loose internet connectivity on your laptop. You may find it useful to clone this git repository locally, so you can still access the content when offline.

Before starting, you should make sure you have all the prerequisites and setup completed. Once the setup is complete move onto part 1 to get started.


Quick links :


Home - Part 1 - Part 2 - Part 3 - Resources

wifimeshraspberrypi's People

Contributors

binnes avatar johnwalicki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wifimeshraspberrypi's Issues

"interface bat0 is not present" - expected on gateway if no other nodes?

Thanks for putting this together. I thought it was very clean to follow. I thought I had a PI setup as a gateway. Only minor place I diverged is I ended up putting the start script in root's home directory, but I accounted for that in rc.local.

I've got an HDMI monitor hooked up to the PI, and on rebooting I can see the above error come up when it hits rc.local. Actually, the whole message text is: Error - interface bat0 is not present or not a batman-adv interface.

I tried running this as root after boot up and got the same message.

Since I haven't yet configured another node, (cause I got to run out and buy some more microSD cards) is that in play here? Or do I need to back up and figure out this error next?

Regards,

Neal

WIFI GATEWAY USING HOTSPOT DOESNT SHOW WLAN 1

ETHERNET works perfectly however i am trying to implement the one in part 2 using hotspot , everything is working fine until i get to the verification step where i run ifconfig in the gateway node and i dont see the wlan1 interface where iwconfig shows wlan1 essid if/any.
Also when i hover over the wifi connection on my rpi desktop using mouse and keyboard i get the message connection to dhcpcd lost.

problem with part2

Hi binnes,
I've seen your work and completed part 1 with no problems. But moving to part 2, i dont really understand what you meant by saying "replace wlan0 with wlan1 in all the previous configuration completed in part 1 and switch wlan0 and wlan1 in the following configuration."
For example:
sudo nano /etc/network/interfaces.d/wlan0
Do i have to create another file "wlan1" and set the content with wlan1 or i just need to replace wlan0 with wlan1 in "wlan0" file?
And do i have to replace wlan0 with wlan1 for just the gateway rapberrypi or all of the raspberrypis ?
Thank you!

How to send/recieve data through the network

I have two drones, 1 gateway and the other is bridge, i have a pozyx device attached to the rpi where it returns to me the xyz coordinates in a 3d plane. How do i send commands or recieve info from the drones on my laptop whether its data or photos.

I am currently implementing the wifi bridge part so its not over yet however I want to know what to expect

"sudo batctl if" command on gateway node results in "wlan0: <error reading status>"

Hello Brian,

Creating my request as a new issue. Apologies, earlier I was posting on a closed thread.
My hardware and software details are as following
Gateway
Raspberry Pi 2 Model B Rev 1.1
5.10.11-v7+ #1399 SMP Thu Jan 28 12:06:05 GMT 2021 armv7l GNU/Linux
USB WiFi (Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter)

Bridge
Raspberry Pi 4 Model B Rev 1.2
5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux
On-board WiFi

Issue details

Sometimes back I followed your instructions and successfully created the mesh network
But I tried today again and it shows me error "wlan0: error reading status".

I have closely tried all the instructions twice with a fresh image from Raspberry site.
I am configuring one Pi for Gateway and another for Bridge.
Followed the instructions very closely in Part1.
But it shows same error like this

pi@rpi-brg-4gb:~ $ sudo batctl if
wlan0: error reading status

my gateway looks like this

pi@rpi-gtw-1gb:~ $ ifconfig
bat0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1468
inet 192.168.199.1 netmask 255.255.255.0 broadcast 192.168.199.255
inet6 fe80::36c5:e5f6:4e13:9df8 prefixlen 64 scopeid 0x20
ether 1e:1a:0c:49:4c:81 txqueuelen 1000 (Ethernet)
RX packets 21 bytes 1460 (1.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 304 (304.0 B)
TX errors 0 dropped 45 overruns 0 carrier 0 collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.34 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d6aa:4ac5:b976:548a prefixlen 64 scopeid 0x20
ether b8:27:eb:9f:ee:3b txqueuelen 1000 (Ethernet)
RX packets 1187 bytes 59140 (57.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 117 bytes 14893 (14.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 95 bytes 7546 (7.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 95 bytes 7546 (7.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::7edd:90ff:fe47:4507 prefixlen 64 scopeid 0x20
ether 7c:dd:90:47:45:07 txqueuelen 1000 (Ethernet)
RX packets 117 bytes 9729 (9.5 KiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 133 bytes 13669 (13.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

pi@rpi-gtw-1gb:~ $ iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

wlan0 IEEE 802.11 ESSID:"call-code-mesh"
Mode:Ad-Hoc Frequency:2.412 GHz Cell: EE:99:7A:6C:F5:07
Tx-Power=20 dBm
Retry short limit:7 RTS thr=2347 B Fragment thr:off
Power Management:on

bat0 no wireless extensions.

pi@rpi-gtw-1gb:~ $ sudo batctl if
wlan0:

pi@rpi-gtw-1gb:~ $ sudo batctl n
Error - interface bat0 is not present or not a batman-adv interface

my bridge looks like this

pi@rpi-brg-4gb:~ $ ifconfig
bat0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1468
inet6 fe80::8a6:7ff:feb8:a14a prefixlen 64 scopeid 0x20
ether 0a:a6:07:b8:a1:4a txqueuelen 1000 (Ethernet)
RX packets 33 bytes 1386 (1.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3557 bytes 213767 (208.7 KiB)
TX errors 0 dropped 225 overruns 0 carrier 0 collisions 0

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1468
inet 192.168.1.4 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::8a6:7ff:feb8:a14a prefixlen 64 scopeid 0x20
ether 0a:a6:07:b8:a1:4a txqueuelen 1000 (Ethernet)
RX packets 3995 bytes 197842 (193.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 286 bytes 31309 (30.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::dea6:32ff:feb7:dd6b prefixlen 64 scopeid 0x20
ether dc:a6:32:b7:dd:6b txqueuelen 1000 (Ethernet)
RX packets 4031 bytes 257826 (251.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 331 bytes 33904 (33.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 8 bytes 480 (480.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 480 (480.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::dea6:32ff:feb7:dd6c prefixlen 64 scopeid 0x20
ether dc:a6:32:b7:dd:6c txqueuelen 1000 (Ethernet)
RX packets 94 bytes 6715 (6.5 KiB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 359 bytes 37300 (36.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

pi@rpi-brg-4gb:~ $ sudo brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0aa607b8a14a no bat0
eth0

pi@rpi-brg-4gb:~ $ sudo batctl if
wlan0: error reading status

pi@rpi-brg-4gb:~ $ sudo batctl n
Error - interface bat0 is not present or not a batman-adv interface.

Please suggest me what could be the possible reason for this.
your guide is excellent material on mesh networking.
Thanks for educating the community on mesh networking.

Regards
Leo

KERNEL 5.10: Error - interface bat0 is not present or not a batman-adv interface

Hello there,

Thanks for your amazing guide!
I ran into some trouble with batctl.

Running sudo ~/start-batman-adv.sh results in an error:
Error - interface bat0 is not present or not a batman-adv interface
Unfortunately I couldn't find any solution on the web, so I turn to you :)

I followed your guide step by step and double-checked the files. Already after the first setup (Part 1 - Mesh Networks), this error appears when running sudo batctl gw_mode client.

It happens on a Raspberry Pi 4B as well as on the 3B+. Latest Raspberry OS Lite (Buster).

Greets,
Tom

Remove "sudo batctl gw_mode client" for bridged mesh with no gateway server as it stops DHCP requests working.

Thanks for making this tutorial available I found it very useful.

I set up a bridged mesh network to extend my home lan to a number of IOT sensor devices (Pi Zero W) that are in range of each other but not all can see my router AP.

I follower your guide which worked, but encountered the issue mentioned here: #6
ie errors when trying to get neighbours/origins/stats etc.

So I built batctl to match the batman-adv version as suggested and my mesh stopped working, or rather the mesh came up fine, but no nodes were able to get an IP address so became unreachable.

A diff of batctl 2019.0 vs 2020.4 showed the gw_mode client/server options were only added after 2019.0 so I removed the line "sudo batctl gw_mode client" and everything started working again.
I guess 'gw_mode client' instructs the mesh to look specifically for a gateway server and supresses instead of passing on DHCP requests?

Wifi AP on gateway

Hi, thanks for sharing this, it's been of great help !

Everything works fine, but I've been since some days trying to set up the gateway node also as an AP. I think it can be done but i'm facing some issues, if you had some documents to share or anything it would be of great help !

So far i've been able to either set up a functionnal mesh without an AP on the gateway or an AP on the gateway node but the bride nodes couldn't connect anymore and the client (smartphone) could connect to the AP BUT with an address given by the ethernet connection, while I need the client to get an address from the gateway.

Thanks for any help you could provide !

wifi bridge no wireless interface found

the gateway has been setup successfully (part2) however when i try to implement the wifi bridge model, i seem to have all the wlan connections disappear.
Do i have to plug in a usb dongle aswell to the rpi just like the gateway?
Is this normal ?
how to actually connect the bridge to the gateway and start communicating?

mtu value of 1532 on host adapter instead of MTU 1468 on bat0 interface

Thanks for the tutorial, it was very helpful.
Setting up the mesh and a gateway was a breeze. But I ran in to a problem.
I had issues pinging and reaching the nodes in the mesh although I successfully set up the mesh network according to your instructions.

I would like to mention that changing the MTU value of the host adapter (wlan0) to 1532 and not setting a MTU value on the bat0 adapter solved my problem with communicating across the mesh.

I hope this can be of help to someone experiencing the same issues I did. In my case only batctl ping worked, normal ping did not. That is until I changed the mtu values as described above.

WIFI BRIDGE USING USB DONGLE AS IN PART 2 (URGENT)

Hello I have the gatewawy working perfectly using usb dongle not ethernet, same goes for the bridge access point using usb dongle with the exception that once i reboot my bridge node I get the NO WLAN INTERFACE FOUND and I cant seem to be able to access the rpi through putty anymore and so I have to use a monitor setup.

I tried all sorts of commands I could find from playing around with dhcpcd or even editing the WPA_supplicant but nothing seems to work.

My question is this supposed to happen, should a bridge node not be able to access the internet? aka my wifi mobile hotspot?

Also when I try running the sudo batctl n on either the gateway or the bridge I dont seem to find neighbours as mentioned.

URGENT

it was really helpful i manage to build a network i am using 3 pi one is gateway and another one is bridge they both are connected to each other but the third pi is connecting and moreover i want to access internet from all three pi for the third pi I follow all the commands in the file name PMESH. But i am unable to see third pi and cant access internet from my pi.

2021-07-12 12_29_48-New Issue · binnes_WiFiMeshRaspberryPi

Issue with Bridge Node

I successfully created the gateway and second nodes. However after turning the second node into a Bridge it doesn't get a 192.168.199.x address and is unable to ping the gateway (192.168.199.1). Anything connected to eth0 on the Bridge cannot reach the internet either.

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.