Hi! I’ve been working on a project trying to create a local Blynk server on a Raspberry Pi with an Arduino Uno connected directly to the Pi’s ethernet port via the W5100 shield. My goal is to have an offline network that can be used in a field application. Here is a visual below:
____________ ___________
| | eth0 | | wlan0(Access Point)
|Arduino Uno|-----<Eth USB1>RALINK RT5370 <<<<<< PC/Laptop/Smartphone(Blynk App)
|___________| | Raspberry |
| Pi |
|Blynk Local|
|___Server__|
I have successfully set up an Access Point using the following guide: RPI-Wireless-Hotspot
The Blynk Server is running and I am able to connect and create and account with my phone.
Problems
- I am lacking the knowledge on how to configure the Pi so that the Arduino can connect via a direct ethernet connection. My guess is that it involves creating a bridge between eth0 and wlan0. I have tried creating a static ip address for eth0, but this hasn’t worked for me. I’m thinking dhcp needs to be enabled so that the Arduino can be assigned an ip address.
- Side Problem: I’m using the udhcpd service and I’m not entirely sure if it is working correctly. My laptop and phone are not being assigned IP adresses. I ended up having to set static IP addresses for both my laptop and phone to properly connect to the Pi. I figure this might come into play for getting the ethernet working.
Questions
- Is my vision possible? If, so what steps do I need to take to properly set up my Raspberry Pi?
- Does DHCP need to be set up for both wlan0 and eth0?
Pi Settings
/etc/udhcpd.conf
# The start and end of the IP lease block
start 192.168.4.10 #default: 192.168.0.20
end 192.168.4.60 #default: 192.168.0.254
# The maximim number of leases (includes addressesd reserved
# by OFFER's, DECLINE's, and ARP conficts
max_leases 50 #default: 254
# The interface that udhcpd will use
interface wlan0 #default: eth0
#Options
opt dns 8.8.8.8 4.2.2.2
option subnet 255.255.255.0
opt router 192.168.4.1
opt wins 192.168.4.9
#option dns 129.219.13.81 # appened to above DNS servers for a total of 3
option domain local
option lease 864000 # 10 days of seconds
/etc/network/interfaces
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet dhcp
#iface eth0 inet static
# address 192.168.2.1
# netmask 255.255.255.0
iface wlan0 inet static
address 192.168.4.1
netmask 255.255.255.0
up iptables-restore < /etc/iptables.ipv4.nat
/etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=LMT_RPi_AP01
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
/etc/default/hostapd
Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# Additional daemon options to be appended to hostapd command:-
# -d show more debug messages (-dd for even more)
# -K include key data in debug messages
# -t include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
sudo iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
Any help, ideas, or suggestions would be greatly appreciated!