I need to do the following, and I need to know if it is possible, I do not want to fool around for ages not being able to get it working only to discover that if I has asked someone intelegent in the art first I would not have wasted vast amounts of my time for nothing. Hence the thrust of this is to have some asurance as to the following being possible first.
I want to have an ethernet network comunicating to multiple computers and devices many with static IP addresses and the network range will be 192.168.1.x/24 where 0 defines the network and n can have values from 1 to 254. On this network will be a number of Piâs or appropiate low cost routers which will act as bridges to other WiFi networks. Say one Pi with IP address 192.168.1.54 uses its inbuilt WiFi hardware to bridge to a new network, say, 192.168.26.y/24 where y can take values from 1 to 254. This 192.168.26.y must be able to be statically allocated in the Pi. A number of PicoWâs will use their inbuilt WiFi hardware to communicate with the Pi and each PicoW will have its own statically defined IP address for example, 192.168.26.37 will be one another will be 192.168.26.38 etc., there being able to be 254 possible such PicoWâs. So I need to be able to ping 192.168.26.37 from a device on the fundamental network 192.168.1.x/24. I also need to be able to send UDP packets from such device on base device and be able to receive UDP packets. For instance from device 192.168.1.92, UDP send to [192.168.26.38[port addr][data]], etc., and this send the data from 192.168.1.92 to 192.168.26.38 : port addr. I will also need to have other Piâs on the network say 192.168.1.55 which offer bridge to other WiFi service of Ip address say: 192.168.27.z/24 where z can take values 1 to 254 and these need to be able to be set statically in the appropiate PicoWâs which will communicate with them. I expect that the PicoWâs will be able to be individually programmed to hard code their IP addresses so that they are atatic and unmoveable. I expect that when a PicoW is turmed ON it will come up immediatly with its WiFi connection to itâs network and its communication will be fast and of short latency.
I have tried to be clear on what I want to do, it makes sense to me that this is a sensible possability but that is no guarantee that it is possible with any avaiable equipment.
Please advise, some links of advise on how to do this would be sweet!
Hi Clem
Wow !! With so much RF floating around you will not need a heater during winter.
On a serious note. Do you think you can have all this running around without interference or clashes. I am not up with how all this works but it seems to be a lot of WiFi in one area. With the limited range of WiFi all these devices would have to be in range of each other surely.
Cheers Bob
What you want to do is achievable, it is kind of how the internet works.
But it requires an understanding of the how WiFi networks are created and work, how ethernet packets are sent to addresses, how packets are passed from one network to the other, how static addresses are assigned and the limitations of the RPiâs. Especially the PicoWâs.
Translation of packets from one network to another requires a router with the correct configuration to forward packets. This cannot be done using a RPi, and the Modem Routers used to connect to a telco and provide WiFi internet access are a very cut down version of a router. In most cases you will find they are inadequate.
Suggest you start with a basic setup.
Get a couple of RPiâs talking on one network and others on another network. Then invest in a quality dedicated router (CISCO or similar) and learn how to program it to send packets from one network to another. Its pretty fascinating how it all works, but there are many traps for young players, as they say.
Also I suggest creating a drawing of each device with associated IP and how they will connect together. I think there is software to allow doing this, for me anyway a visual representation often helps me see potential problems before they occur.
Sounds good and exciting what you intend, all the best, if you need more detailed help, happy to do that. But eventually it may go beyond my skill level.
Why would they intefere? Doesnât WiFi work on code division spread spectrum multiplexing? All PicoWâs which communicate with a certain Pi will have to be in range of that Pi - yes, but would not have to be in range of other Pi routers which they are not communicating with. But they could be and that should not be a problem.
Yes I have a specific project in mind. I have a multi lab facility with converted freight containers as labs. All labs are ethernet connected with a switch on the main network with multiple computers in each lab. The lab will have one Pi which bridges to a specific WiFi for that lab. In one lab I might be running multiple ovens which control temperature, gas flows, pressures etc. Each oven might have several PicoWâs dedicated to controlling one parameter and will interface to their lab Pi via WiFi. Any computer on the main networm much be able to ping any PicoW in any lab and a server will monitor and control all PicoWâs in all labs using UDP packet data addressed via IP address[port]. So the PicoWâs must be programmed with a static IP address so that Its address does not change. Diferent things are done in each lab, and while there are unlikly to be 254 PicoWâs in a particular lab, there is likly to be 10âs of them , coul deven be 100. SO thi sis a real project - WiFi range is not large and each lab is an imperfect farady cage. If WiFi controllers are going to be only alright at the best of times I need to know this now and abandon this approach. I need to know up front - can this work reliably or not? What would be a factor which would make them anoying? And is this just unfamiliarity with programming them - or is it fundamental physics / electronics intermitancy issue?
I have used ethernet with embedded controllers and connected computers together before - I have NEVER used WiFi and do not understand its added complexity. But I reason that it must use IP addressing otherwise it would not be possible to communicate with WiFi devices on a network. I can set computers to have static IP addresses and want to do this. I presume that similarly I could program PicoWâs to have static IP address and ports, so that it is set at embedded compile time in the source code.
I do not see why the RPis should have a limitation for this - what are you refering to? The PicoWâs only have to talk to one RPi and each one does not have to know that any other PicoW exists. None of the PicoWâs need to talk to any other device but the dedicated Pi they are communicating with only. Any device on the networn muct be able to communicate with any PicoW but only through the Pi bridge to the PicoW.
I do not understand why a RPi cannot act as a router, it is a linux computer, it has an ethernet port and it has a WiFi hardware, I am sure I have seen links talking about making a RPi into a router - so what exactly is the problem - are you sure that it cannot do this? I donât understand why a routing table cannot be set up easily - and it is like a tree structure, One RPi communicates to the main network and the other side of the bridge communicates to all the Picoâs that are dedicated only to the RPi. That does not sound complicated to me - if any PicoW needed to communicate with any other PicoW that would be a diferent story by order of magnitude dificult increase, but NO, The communication is one way and respnse from main network device to particular PicoW through only one dedicated RPi for that particular PicoW.
I do not want to start with a basic setup if the end result is not achievable - I need to know that before I start so that I will choose diferent hardware if this cannot be done. I strongly suspect that this will work and am seeking the wisdom of you experienced makers for so that I can proceed with confidence.
Why would I get a CISCO router if a RPi can do what I need? I am not interested in expensive routers if I do not need them. If the RPi is capable of doing this routing job then it should be straight forward to make it do the job. Plus I would ideally much prefer RPiâs that CISCO routers - RPis are completly programmable by the user, CISCO routers cannot be used for anything else.
I went to some effort to make it clear with text, but I understand some people are more visual, so I am willing to make diagramms etc if that is helpful to get sound advice.
I donât think thare is a lot of skill level require dfor this, It seems to me that once a system is set up with just a couple of devices which exercises the complete routing path, it is just a matter of adding more devices and programming more PicoWâs with unique IP addresses appropiatly chosen, and adjusting the routing table accordignly.
Am I talking sense or not?
At this stage I do not know how to properly set up a RPi as a router, there seems to be lots of diferent ways out there, and I do not understand how WiFi connects - can I set the PicoW IP address and port and access the data in a loop in the code and send and receive UDP packets?
@Clem73188 Thanks for your reply.
From what you have replied I can now see how you would like it to work and it could be done without expensive network equipment. (like CSICO stuff).
Each container (lab) could have a PRi 4 or 5 configured as a WiFi Hotspot. It controls and communicates with each of the PicoWâs via WiFi and its Ethernet port connects to the network via cabling. That way it acts as a simple router connecting one network to the other.
I have used a RPi Zero in a robot cart as a WiFi Hotspot with a PC or Tablet connected to provided controls for the cart. It worked very well and my grandsons loved playing with it. I tried setting up a PicoW as WiFi Hotspot, another connected to send sensor readings. It sort of worked but not very reliably. The PicoWâs are great little microcontrollers and it is amazing what they have fitted into the space with Micropython. But the WiFi is a cutdown version due the the limitation of memory space.
On the other hand a RPi 4 or 5 is a complete Linux operating system and would work well as a WiFi Hotspot with the Ethernet port connected to a network or internet. That has been done many times successfully by many people.
Yes you are talking sense, now I understand what you are trying to do.
So the first step is to get a RPi 4 or 5 and a couple of PicoWâs. Check for guides on how to setup the RPi as a WiFi Hotspot, some are good some are not. Use DHCP in the RPi to set static IPâs for the PicoWâs. The PicoW can be set to start with a static IP address but I found it more successful to let it request an address, even if it is the same one. The OS of the RPi manages this much better.
I am unsure if the PicoW Micropython has programming to send and receive UDP packets. I was just sending text messages. Once again it would be due to the limitation of memory space in the Pico as to what has been implemented in Micropython. The RPi certainly had this ability or can be setup to do it.
Anyway, get some stuff and experiment, once you have it working on a small scale easy to add more.
Just a comment on this.
Everything is theoretical until tested. I have confidence the RPi could do what you want, provide a bridge between WiFi and Ethernet. A RPi Zero would also work well as it is just a smaller and slower version of a RPi 4 or 5 without all the interface ports.
But the PicoWâs I do not have as much confidence in, they work great as a basic microcontroller sending sensor readings or receiving commands to control something. As a WiFi network device, not so great.
It would probably be useful to look at the RaspAP and OpenWRT projects which both support setting up a raspberry pi as a router. Using something off the shelf like this may make it easier to manage. Good luck. -John
I think I am correct here but please put me right if not.
I believe RPi, Pico etc are primarily experimental and development tools aimed at the hobbyist / enthusiast market. Not really guaranteed for any âmission criticalâ applications. OK for development and any âproof of conceptâ work but for the final long term use I think more robust system bits might be required.
I am not sure what category your system falls into. Experimentor/ hobbyist where the use is short term or as I suspect more a long term critical (I use the word âcriticalâ here as you have mentioned several laboratories) function.
You may find adequate assistance here but do.t be too disappointed if you canât. This Forum is pretty good but at the end of the day you may need the assistance of a specialist systems engineering company who are fully across the type of thing you propose.
Even if such a consultancy can say that what you propose is not economically viable.
I stress here that this is my personal opinion and might not reflect the feelings of this Forum as a whole.
Good luck with a very ambitious project.
Cheers Bob
@Clem73188 Had a brief look at RaspAP mentioned by @John74609, it looks like the best option for what you want to do. It runs on a normal Raspberry Pi OS setup. OpenWRT is its own operating system and dedicated to purely router functions. As well as much more difficult to setup. (this is a learning experience for me)
Because I find this kind of stuff very interesting and an excellent way of keeping my brain active; I am going to haul out my RPi 4, install RaspAP and connect a few PicoWâs to it. See how it goes, will post here the results. This may help you with what you want to do.
A comment on what @Robert93820 said about Raspberry Pi products. They are primarily aimed at the hobbyist market but have been used by manufacturers in their own products as a reliable processing device. All Raspberry Pi products I have bought have been of excellent quality and reliability for what I want to do as a hobbyist. Put them in an industrial environment and they might not perform as well. This would be something to consider if your application is of a commercial nature.
Anyway I will let you know my thoughts on RaspAP and connection to PicoWâs soon.
Very looking forward to your results Jim. Would be interested to know if yu can set the IP address and port of the PicoWâs and communicate with them via UDP packets. Particularly if you have delays in PicoWâs connecting to the WiFi , unreliability in the samd and any speed/ latency issues. I will be programming the PicoWâs in C not python, but interested anyway.
I would expect that the hardware might be problematic in an industrial environment because of hardware - electrical interface issues, not from software issues. The fact that they are WiFi removes some of the hardware electrical interface problems.
Regards
Clem.
@Clem73188 Well I spent some hours getting just the basics to work. But did not do myself any favours by NOT starting with a known good OS on the Pi 4 SD card. And then understanding the terminology and functions of various settings in RaspAP took some reading and experimenting with those settings.
All good now.
I have a PicoW running Micropython connecting via WiFi to the Pi 4.
IP Address 10.3.141.57.
The Pi 4 Ethernet port is connected to my internet modem router through a Dlink Switch.
IP Address 192.168.1.107.
I use a Windows PC to access the Web Page of RaspAP. The same PC is connected to the PicoW to program it with Thonny.
The PicoW shows up as a connected device and the RaspAP logs show it connecting and disconnecting. The PicoW can access the internet to update its date / time from a NTP time server. But I cannot ping the PicoW from my PC, because understandably its on a completely different network. I suspect I would be able to from the Pi 4 (have not tested that yet). So I am pretty much happy it is all working as it should at this time.
I had a look into UDP and now understand the use of sockets in Micropython. (I didnât before) Previously I used HTTP to send messages back and forward between two PicoWâs, probably not the best way to do it.
The next step is to connect two PicoWâs to the Pi 4 and get them to message each other via UDP. I will get this setup and post here again. Happy with how it has gone today.
Lessons learned, install the correct version of the Pi OS as stated in the RaspAP documentation, donât rely on the current OS installed on an SD card and hope it works.
Also donât setup the Pi OS to auto connect to the internet modem router when it should be setup as an access point.
⌠and read the documentation closely before assuming you know what a particular setting is used for âŚ
James:
If the Pi4 is acting as a router and it should make a bridge between 192.168.1.0/24 and 10.3.141.0/24 that including 10.3.141.57. Then you should be able to ping the PicoW from any computer on the 192.168.1.0/24 network.
You say that the PicoW shows up as a connected device - does that mean continually connected? You say the RaspAP logs show it connecting and disconnecting - that alarms me. Does this mean that every time data is to be sent to the PicoW it has to reestablish the communication and will not be able to provide continuous communication? So imagine that I want to send UDP data packets to the PicoW at a repeate rate of 100 packets per second continuously - will that give me dropped packets? Will there be large random latency? If I have 10 PicoWs on the Pi4 and want to send each of them 100 packets per second will each PicoW be served in some kind of sequence or will they all work continuously and in parallel without inteference form the others. If I cannot get continuous connection with low latency them posibly WiFi is not going to deliver a solution.
Thanks for your experiments so far.
Regards
Clem.
Hi James:
I HATE python, I use C. Why, because python is an interpreted language and runs as an interpreter. What that means is that a program is running in the PicoW which is compiling and executing the source code and as such will be thousands of times slower than a compiled machine executed instructions. I will be programming in C which gives much more power and when compiled the processer is running the programe in its own machine language, not continually reading another language, interpreting it and then stepping throught it.
This will not be aparent in many hobbyist applications where execution speed is not an issue.
But such ease of use python programming can be useful in quickly teasting some fundamental concepts.
Regards
Clem.
The routing tables in RaspAP are not setup to do this. The basic âout of the boxâ setup is for WiFi devices to access a Ethernet network. RaspAP translates and handles internet web page requests from the WiFi devices perfectly and provides responses to those devices in a secure fashion. Similar to what a modem router does. Getting RaspAP routing to forward packets from an Ethernet device to a WiFi device is on the to do list.
This was me starting and stopping the PicoW program. I was checking to see how RaspAP handled it and it gave me confidence all was ok. Once connected the device will stay connected, a timeout can be setup for inactivity if that is desired. The configuration flexibility of RaspAP is excellent.
Hmm ⌠if the payload of the packet is 10 bytes lets say, thats 10,000 bytes per second 100usecs per byte. This is not considering the wrapper bytes such as address, and any acknowledgement of a packet, etc. All 10 PicoWâs on the same WiFi channel, data transfer cannot be in parallel.
In my playing with the control of devices via RF I found something like the PiicoDev TX/RX module to work better and easier and more reliably than WiFi. But it is still RF and when it is sending it cannot receive. There is also a small time for the RF energy to dissipate before it can receive. 5Ghz WiFi data rates are pretty high and should cope with the amount of data you want to send, but it is untested at this time.
So far I have been happy with the Pi 4 and RaspAP.
Some notes :-
Advanced features of RaspAP are only available if you become a sponsor, ie you pay a monthly fee.
RaspAP only works with the Lite versions of the Pi OS, no GUI.
PicoWâs can send and receive UDP packets to each other ok.
Totally agree.
When I read you would be using C I had more confidence you would have a good outcome.
I experimented with the Sleep modes of the Pico, Python did not produce a good result but C did.
I will be sticking with Python for now I find the Thonny interface easy to use and run programs. Most of what I do is not processor intensive and is not time constrained.
@Clem73188 Well this has become a little disappointing and frustrating. In all the cases I have looked at, the Raspberry Pi is configured to connect WiFi clients to the internet. RaspAP does this in a seamless and easy manner. But this is not what you want to do.
You want to send UDP packets from a network to WiFi clients, lots of them. If I have it right. I thought using iptables would allow me to do that, but I think my understanding is lacking in this area.
This does not make logical sense to me in my understanding of how networks operate. The networks are completely different and the gateways are different too. There is something missing in my understanding.
Packets are sent with a source and destination address, if the device has no way of knowing how to get to the destination then it is unreachable. Like in the case of my PC and sending a Ping. If my PC was connected through the Raspberry Pi it might work. The way I have it setup at this time is a compromise and if I was to test this further I would need to setup a network similar to what you intend to setup. I might be able to use an old laptop to act as the main network device; I also need a clear space to set it up, its getting a bit crowded on my desk.
Can you provide a clearer picture of what you intend to do ??
Regards
Jim
PS Also getting a better understanding of how the Pi OS and iptables network address translation works would help.
Well 3 days stuffing around with this, multiple reinstalls of the Pi OS (because I stuffed it up, not the OS), reading multiple forum guides and help, realising many are out of date and incorrect, reading the official Debian documents, and finding they are pitched at a level too complex for me and my understanding.
Conclusion:
The Pi 4 is an amazing piece of equipment and very flexible, it can be easily setup to distribute internet access as a WiFi hotspot. The lastest Pi OS has it built in with a graphical interface. (donât need RaspAP)
The PicoWâs WiFi is better than I thought; as long as you accept the limitations of what can be implemented in Micropython with the limited memory space. And remembering it is a microcontroller not a microcomputer.
I now have a much better understanding of using TCP & UDP sockets with the PicoWâs. Probably use it more in projects now.
Last, donât trust all the videos and guide people have made, that probably worked good when they were made with a particular setup, but now need updating to match the latest OS.
All in all I am no closer to achieving what I think @Clem73188 wants to achieve. I really need more detailed information on exactly what they want to do. It might not even be possible or there might be a better way with different equipment. I donât care about what the project is doing, just how the data is to be distributed so I can figure a way to do it.
Anyway I wonât be spending any more time on this, I will be using what I have learnt for my own projects. Its been a great learning experience for me.