Beaglebone [Embedded Linux]: Wifi Auto-Connect

I'm going to be working on a project that require my Beaglebone to connect to a mobile application.

At first, I plan to use Bluetooth as a medium. However, my android app develop using Flutter cannot find my Beaglebone 😭, This leads me to this blog, where I change to use Wifi and it's a lot Easier 😏. I would like to share the steps I took to do so here in this blog. Let's begin !

PS. In this guideline, I use Beaglebone Green Wireless, but it should work just fine for any embedded Linux board (Eg, Raspberry Pi, Beaglebone Black Wireless and so on)

 1. Check if wifi is working

wlan0 should be listed in interface list;


debian@beaglebone:~$ ifconfig -a

wlan0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 192.168.43.205  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 fe80::8230:dcff:fe30:691f  prefixlen 64  scopeid 0x20<link>
        ether 80:30:dc:30:69:1f  txqueuelen 1000  (Ethernet)
        RX packets 76  bytes 7469 (7.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 177  bytes 29190 (28.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0 collisions 0

2. Try connect to wifi using connmanctl services

get into connmanctrl service

debian@beaglebone:~$ connmanctl
connmanctl>

then do these following command

connmanctl
connmanctl> tether wifi off
connmanctl> enable wifi
connmanctl> scan wifi
connmanctl> services

from command "services" it will list available wifi

*AO SIIT_EV              wifi_8030dc30691f_534949545f4556_managed_psk

connect to the wifi using the wifi_* string

connmanctl> connect wifi_8030dc30691f_534949545f4556_managed_psk

if Beaglebone can connect to the wifi success fully, in you mobile phone where you set up to be your wifi hot spot will show that there are some device connected to it

In your mobile phone, open list of connected device and you will see the ip giving out for beaglebone.

Try putting it in the browser to see if it working, and you should see this;

3. Make it automatically connect to each other

we wouldn't want to repeat all the steps in section 2 every time we turn on beaglebone, do we?
so, let's make a "Wifi Auto-Connect"

3.1 Linux way ( I don't really prefer this)

a simple linux way of doing this is to put you wifi hotspot into a known host to connect to.
For more information you can read this article.

here's how you can accomplish this in beaglebone;
open editor to edit interface file

sudo nano /etc/network/interfaces

at the bottom of that file add this in save and close it


#allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
  address 192.168.1.58
  netmask 255.255.255.0
  gateway 192.168.1.1
  wpa-ssid "SIIT_EV"
  wpa-psk  "siitfomm"

3.2 Python way

TBD

Reference

Deemarc Burakitbumrung

A software develper who graduated from Electronic and Communication Engineer. Have an interest in the field of programming and embedded system.

No comments:

Post a Comment