Determining the optimal WiFi library/Example for a LAN

I am hoping forum members with a better understanding of LANs than my own limited knowledge could recommend the best approach for setting up my local area network.

I have 6 buildings on my property all within wifi range of my house router. The Uno WiFi Rev2 has tested successfully over 400 feet at my most distant structure. I am using a combination of Uno WiFi Rev2 and ESP32 boards. I intend to put a microcontroller in each structure.

What is the most practical approach in tying each of these microcontrollers to my local area network. There is a cornucopia of WiFi examples to choose from in the Examples library. Some are "client" and some "server."

I have two goals:

  1. report an alarm condition from any building microcontroller to a web-based push notifications API
  2. monitor each microcontroller through a browser web page

Available methods:

WiFi Client Insecure; WiFi Client PSK; WiFi Client Secure; WiFi Web Client;
Connect With WEP; Connect With WPA; Simple Web Server WiFi;

thanks for your advice,

For the first goal you probably need a client example (maybe WiFi Web Client), for the second goal you need a web server example (maybe Simple Web Server WiFi).

As you didn't provide details you cannot expect detailed information from us.

"As you didn't provide details you cannot expect detailed information from us."

What "details" am I leaving out?

Can I combine "client" code with "server" code in the same controller without creating any conflicts? Or can one WiFi sketch allow me to do notifications and browser access simultaneously?

yes. there maybe be RAM limitation on count of secure connections

So is client or server more appropriate for my application? With a minimal understanding of this terminology I am assuming setting these controllers up as a "client" would be preferable to making each one configured as a "server."

I am not really clear about what you're trying to do. In particular, what monitoring of each controller entails.

I'll guess that each building's device measures a few things, may alarm on some of them and needs to report on what it has.

My inclination would be to make each of them clients that report their findings to something in the house. Web server probably, maybe with an associated database. MQTT might be worth a look.

Details about that push notification API or what kind of alarms you have to protocol.

I cannot guarantee that there won't be conflicts but I wouldn't expect them.

Yes and no. You can do it in one sketch but it wont' be completely simultaneously.

If you want to control or monitor the nodes by a browser the corresponding code functionality is usually called server. The API calls to your push notification service is a functionality subsumed by 'client'.

"I am not really clear about what you're trying to do. In particular, what monitoring of each controller entails."

Perhaps I should never have mentioned a LAN.

Simply stated I want to have the ability to access each microcontroller through a web browser and observe the sensor data. Secondly, give each processor the ability to connect to a website notification API and send me an email message if an alarm condition occurs.

I have made both functions (view data & send out alarm) work independently but when I try to combine them into a single sketch problems arise. This is why I was asking whether I can accomplish this with just a "client" sketch or need a combination of the two.

I do something like this at my house. So do other folks here but my setup isn't as fancy.

I have a controller that measures temperature and humidity and then sends it to a central server which stores the data. It's constructed so that I could have many nodes providing data, although currently there is only one.

The server does pull data from other services though, so I have outside temperature and humidity too. I pull forecasts as well to warn me if it will freeze overnight. It sends email/text messages if the chill will put plants at risk.

Your proposed system could be similar. Mine relies on the server to present all the data, the nodes just provide it. I don't see a reason to need to hit your nodes from a browser from what you have described so far.

"Mine relies on the server to present all the data, the nodes just provide it. I don't see a reason to need to hit your nodes from a browser from what you have described so far."

I want to keep things as simple as possible. I thought just accessing each controller independently would be fairly straightforward but to have them all come to one "server" would be fine as well, probably better to be honest.

So can I have these "nodes" report to my Linux Desktop PC as the server? And they can still independently report alarms to an API? For me the KISS method is a priority....lol.

Could you use your Ubuntu box as the server? Let's see... oh yes, that's what I have :wink:

Since each device will need WiFi to talk to the server, then they'll be able to hit your alarms API too. I would prefer to make the server do that bit too, if only to be able to log the alarm data in one place.

I am liking the scenario you suggested. Code wise could you suggest any "canned" EXAMPLES to accomplish this approach?

Specifically I have a HughesNet router that I have used as my base to communicate with the controllers. I also am tied to that router with my Linux Desktop PC. The router assigns the node addresses as they come online.

What do I need to create to make my Linux PC the server for all these field nodes?

Canned? probably not, but there are lots of examples you can adapt.

My server has been in place for a while and I would likely do it differently if I were to redo it. That said, I have an Apache web server and a MySQL database. There is a really basic CGI web page that the node hits with a GET request specifying Node number, sensor number and reading. Most often, such a page would be PHP, but I've never used it so mine is written in Perl. All it does is push the data to the db. Then there are a few web pages to present the data. Again, I used Perl::DBI to talk to the database but I don't for a moment suggest that you should unless you happen to already know that stuff.

Today, I'd probably use MQTT just to do something practical with it, but I wasn't aware of it when I built this thing.

In the spirit of getting something working, I would suggest that you run MQTT (Mosquitto) on your server and you should quickly be able to get viewable data to the Linux box from your remote controllers using example library code. Then worry about actually using and storing it.

I'd likely use MaiaDb now instead of MySQL, but for this kind of thing, either of them will be more than adequate.

Appreciate the input. It seems I need to just experiment and see what is workable keeping in mind I have a very limited understanding of the server/client environment.
Copy, paste, compile, check functionality......lol.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.