This can be a good action if friends help

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

This can be a good action if friends help

#1 Post by reza » 18 Nov 2020, 18:54

hi guys
first, sorry for weak in English.
I have a domoticz on raspberry pi and I have some devices with espeasy.
all of devices are connected to a router (raspberry and all of esp).
But I think it is better that the controller and the router are the same(both on the raspberry)
So I searched in google and found a solution for convert raspberry to an access point ( domoticz on same raspberry) this page:
https://thepi.io/how-to-use-your-raspbe ... ess-point/
after this steps , i have domoticz and AP on one raspberry and my esp8266s are connected to raspberry directly and this is very good idea.
but
this solution have a some problems. this is very slow in actions ( connected Mobile to raspberry, speed in opening domoticz , speed in sending and receiving commands to espeasys...)
can resolve this problem ? and convert raspberry to an strong AP for a good network between esps and domoticz?

thanks all managers and engineers.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: This can be a good action if friends help

#2 Post by TD-er » 18 Nov 2020, 19:24

What IP-address ranges have the ESP's and the Raspberry Pi?
Is the Pi configured as a router, or only as an access point?
The manual you have suggests it acts as a router, but then your PC must also know how to route packets so your Pi must then be set as a gateway for those IPs.

So please explain a bit more how the IP-addresses are arranged in your network:
- What IP/subnet is your router? (e.g. 192.168.1.1 / 255.255.255.0)
- What subnet has your Pi? (e.g. 192.168.1.3 / 255.255.255.0)
- What subnet do your ESP's have? (e.g. 192.168.2.3 / 255.255.255.0, note the difference in the 3rd number)
- What gateway is set to the ESPs?
- What gateway is set to the Pi?
- What gateway is set to the other computers in your network?

reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

Re: This can be a good action if friends help

#3 Post by reza » 18 Nov 2020, 20:06

TD-er wrote: 18 Nov 2020, 19:24 What IP-address ranges have the ESP's and the Raspberry Pi?
Is the Pi configured as a router, or only as an access point?
The manual you have suggests it acts as a router, but then your PC must also know how to route packets so your Pi must then be set as a gateway for those IPs.

So please explain a bit more how the IP-addresses are arranged in your network:
- What IP/subnet is your router? (e.g. 192.168.1.1 / 255.255.255.0)
- What subnet has your Pi? (e.g. 192.168.1.3 / 255.255.255.0)
- What subnet do your ESP's have? (e.g. 192.168.2.3 / 255.255.255.0, note the difference in the 3rd number)
- What gateway is set to the ESPs?
- What gateway is set to the Pi?
- What gateway is set to the other computers in your network?
thank you dear for answer.

At first I wanted to use just a AP(raspberry) with esp's. but dont work (i think this is related to "Step 8: Enable internet connection" that i did it and when router-modem is dont connect to raspberry , so raspberry crashed and i can not connect with wifi and domoticz can not work )
but when router is connect to raspberry and i have this settings:

my router : 192.168.1.1 / 255.255.255.0

my pi : 192.168.1.10 / 255.255.255.0

range in pi : 192.168.1.11 - 192.168.1.253

setting in esp's : (set static ip for every one between pi range)for example one esp :
esp ip : 192.168.1.142
esp GW : 192.168.1.10
esp subnet : 255.255.255.0
esp DNS : 192.168.1.10

for pi i didn't set GW . i am beginner and just do step by step "steps in site that search google" on this step dont have option for set GW in pi ! also in my computers and android phone i dont have ant settings for GW. just i choose ssid on pi and enter password and connect to pi for open domoticz and send command to esp's.

sorry dear for i am beginner . have i any problem in settings?
Last edited by reza on 18 Nov 2020, 20:17, edited 2 times in total.

reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

Re: This can be a good action if friends help

#4 Post by reza » 18 Nov 2020, 20:13

all of settings for Pi (AP) is copy this site :
https://thepi.io/how-to-use-your-raspbe ... ess-point/
just i change this lines:

static ip_address=192.168.0.10/24
to
static ip_address=192.168.1.10/24


dhcp-range=192.168.0.11,192.168.0.30,255.255.255.0,24h
to
dhcp-range=192.168.1.11,192.168.1.253,255.255.255.0,24h

interface=wlan0
bridge=br0
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=NETWORK
wpa_passphrase=PASSWORD

to

interface=wlan0
bridge=br0
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=RAYAN
wpa_passphrase=@RAYAN

reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

Re: This can be a good action if friends help

#5 Post by reza » 18 Nov 2020, 20:22

TD-er wrote: 18 Nov 2020, 19:24
- What subnet do your ESP's have? (e.g. 192.168.2.3 / 255.255.255.0, note the difference in the 3rd number)
what is means? how select 192.168.2.3 for esp's when my pi and my router are 192._.1._ !
all my devices are connected to my network and my AP(PI) just very slow or freeze more sometime

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: This can be a good action if friends help

#6 Post by TD-er » 18 Nov 2020, 21:22

It looks like the ESP's connected to the Pi are in the same subnet as the rest of the PCs (and the Pi)
So I am surprised you even get something to work.

Just a very short introduction on IP routing.

2 devices are in the same subnet if they have a number of bits of their IP address overlapping.
For example:
- 192.168.1.1 (subnet 255.255.255.0)
- 192.168.1.123 (subnet 255.255.255.0)

"255.255.255.0" means the first 3 values (separated by a ".") must be the same to define the IPs to be in the same subnet.

The subnet can be read as 24x "1" and 8x "0" in binary. So you can also write it as /24 which is shorter and I will also write it as that.
So every time you see "/24" in my post, you must think to yourself it is "255.255.255.0"


Back to the example:
- 192.168.1.1/24
- 192.168.1.123/24

These all have the same first 3 numbers (192.168.1.) and given their subnetmask of /24 you know they are part of the same subnet.

For devices in the same network (as in connected to each other) and in the same subnet, you don't need any routing as the devices can reach each other directly.

As soon as you need to communicate between different subnets, you need to have a gateway which can forward your packets to the other subnet.
Such a gateway is also known as a router.

For example:
- 192.168.1.11/24
- 192.168.2.22/24

Those 2 are in a different subnet, so even if they are plugged in te same switch they cannot talk directly to each other.
They need to have a gateway to forward the packets between subnets.
Usually a home network doesn't have different subnets (except for maybe a guest network which some routers offer) and thus the only gateway you have set up in your network is the address of your internet router, to connect to the internet.
The addresses on the internet are also in another subnet, so you need to route them.
For example 8.8.8.8 is not part of your local subnet and thus your router will need to know what to do with it.

If you look at your PC's network settings, you will see a gateway address, which is very likely the IP of your internet router/modem.

Now the Raspberry pi which is NOT your internet router, but is acting as an access point on your network.
If the nodes connected to the WiFi access point of your Pi have the same subnet as your own network, then the Pi must not act as a router, but as a bridge.
A bridge can best be seen as a normal network switch, only it is not connecting wired network to wired network, but WiFi to wired (or wifi to wifi)
So it is not routing IP traffic, but only routing a lower level traffic (called layer 2, MAC addressed packets).

This means the network (your switches etc.) need to know how to reach your WiFi connected ESP nodes.
So your Pi must try to forward the packets (and not route them) and also must reply to low level questions like "who has IP 192.168.1.123" (so called ARP packets)

If your Pi does not forward all these packets in due time, I guess it will be terribly slow, if working at all.

Another approach can be to setup your pi as a gateway/router, so it will connect two different subnets. (e.g. 192.168.1.x/24 and 192.168.2.x/24)
But if the pi isn't also your internet router, I am afraid your network configuration will soon become quite messy and hard to maintain.

For this to work you either need a very well written tutorial to get it to work with ESP's (as they probably need some other specific WiFi settings also) or you need extensive knowledge of network architecture.
Right now I advice you not to connect the ESP's like this to your network as it is likely to cause a number of issues.

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: This can be a good action if friends help

#7 Post by Ath » 18 Nov 2020, 22:08

reza wrote: 18 Nov 2020, 18:54 But I think it is better that the controller and the router are the same(both on the raspberry)
...
but
this solution have a some problems. this is very slow in actions
I'm trying to understand why it would be an advantage to use a relatively slow, general purpose computer, the RPi, as both a Domoticz server and a router?

The first paragraph of the page you linked to, describing only the router function, (and you are also hosting Domoticz there, not the lightest load for a RPi), already states the fact that "it won't be fast, but it works".
Isn't that exactly what you are experiencing now?

It sounds like a nice project/experiment for a rainy Saturday or Sunday, but not something I'd want to put into production.
Only exception I can think of is the RPi and ESP's are in a remote location, where only wired ethernet is available, and there is no cheap router available to be placed at the same site.

My advice: use a proper router, and connect all wifi stuff to it.
If you want to have a separate wifi, only for the IoT stuff, read the quick networking course that TD-er wrote above ;) , create the separate wifi in your existing router, or configure an extra router, and make the RPi accessible from the regular wifi/network so it's manageble from your standard devices (pc, tablet, mobile).
/Ton (PayPal.me)

reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

Re: This can be a good action if friends help

#8 Post by reza » 18 Nov 2020, 23:45

TD-er wrote: 18 Nov 2020, 21:22 It looks like the ESP's connected to the Pi are in the same subnet as the rest of the PCs (and the Pi)
So I am surprised you even get something to work.
very thank you my dear friend for complete explain. but i want do it for my home (Ath for home using , i think not needed a strong router ! one network with a raspberry and max 20 esp and 5 mobile phone and computer) is this not ok AP PI for this network ? this is good way for remove router between PI and esp and connect directly . if work better and dont freeze.
so dear TD-er can you help me for change setting until devices work better ?
this very hard for me (weak english) for a small home i must learn all of this issue about network. i want just setup this in my home.this is all of my devices :
1. a ADSL modem-router that connect to internet and have a lan port and wireless . 192.168.1.1/24
2. a raspberry pi 3 that have domoticz and setup for AP .raspberry connect to modem with lan. 192.168.1.10/24
3. 20 esp modules with static ip inside client.
{
esp ip : 192.168.1.142
esp GW : 192.168.1.10
esp subnet : 255.255.255.0
esp DNS : 192.168.1.10
}
i want all of esp connect to PI access point.
4. 5 mobile phone and computer (these are connect to PI too) ( dhcp give ip to this devices)
so i want have a local network with pi with good speed and without freeze (no very very good) and modem just connect to PI for remote access and internet.
can you guide me how change my settings?
thank you

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: This can be a good action if friends help

#9 Post by TD-er » 19 Nov 2020, 09:36

I strongly advice you to reconsider this idea.
Let me explain my concerns:

Configuring a Pi to become a router (which is what you would like to do) does require quite some network knowledge to keep it safe.
Otherwise you risk someone entering your Pi from the internet and start messing around in your network or abuse your system for other purposes like sending spam, trying to hack other sites (from your account), install software on your PC's in your network (ransom ware for example) or do all kinds of other nasty things.

A Pi is not quite fast, so you are probably limited to the speed of the Pi for your internet speed.

To act as a router, your Pi must have at least 2 network devices. One to connect to your modem and one to provide connection to your internal network.
This can theoretically be done via the WiFi on the Pi, but that's not a very fast one and extensive WiFi traffic from other devices also hurts the performance of the connected ESP's (and vice verse)


My advice is to buy some (cheap) WiFi access point for your ESP hardware. Those can be had for less than 25 euro. (not a repeater, an access point)
This will make life a lot easier and also more secure.

reza
Normal user
Posts: 88
Joined: 13 Jun 2017, 21:14

Re: This can be a good action if friends help

#10 Post by reza » 19 Nov 2020, 11:06

TD-er wrote: 19 Nov 2020, 09:36 My advice is to buy some (cheap) WiFi access point for your ESP hardware. Those can be had for less than 25 euro. (not a repeater, an access point)
This will make life a lot easier and also more secure.
thank you dear <3

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests