répondre a des questions sur ESP8266 & Arduino ?? Merci
quel qu'un pour
Jun 19, 2022
Last reply: il y a 4 ans
17 Replies
Am 19.06.22 um 15:25 schrieb zeneca:
Don't believe one will do in French :( ___ Regards JJenssen
Le 20/06/22 à 11:41, JJenssen a écrit :
OK, let's try I would like to find a way allowing several siteId in a configuration. The system (a NodeMcu8266) would try them in sequence. For that I am trying:
struct netw { char *MXWifi;/*ssid*/ char *YYYZY; /*passwd*/ const char *MyIp; /*ip adress*/ struct netw *next; };
struct netw prem = {"AAACCCCCC","xvdfgghs","192,168,1,32"}; struct netw seco = {"Orange-aaa","7XyZzR","192,168,0,32"};
struct netw *current;
In setup()
IPAddress local_IP(MYIpad); IPAddress gateway(MYGatew);
DoConnect();
in void Doconnect() {
while(1) { Serial.println(current->MXWifi); Serial.println(current->YYYZY); Serial.println(current->MyIp);
// IPAddress local_IP(current->MyIp); Serial.println("-------------------");
if (current->next != &prem) { current = current->next; } else { current = &prem; break; }
}Compilation fail on current->MyIP Doesn't' accept 198,162... nor 198.162... Type IPAdress seem to only accept:
#define MYIpad 192,168,0,32
Typically Arduino??
Many thanks in advances André
In article (Dans l'article) <t8pfbu$rp3$ snipped-for-privacy@dont-email.me, JJenssen snipped-for-privacy@arcor.de wrote (écrivait) :
French speaking people can use <news:fr.comp.sys.raspberry-pi>
I have never seen anything using commas in IP addresses instead of periods. It is not an arithmatic number, so those are not decimal points, so I can't imagine anyone, ever, anywhere needing to translate periods to commas or vice versa in IP addresses. If your library does do that, I'd be looking for a different library.
It is actually how they do it:
formatting link
it's a constructor which accepts four arguments, being the four 8 bit chunks of the IPv4 address:
formatting link
Hence you can do: IPAddress alice(127,0,0,1);
which creates an instance of the IPAddress class pre-initialised with the four octets from 127.0.0.1
But, looking at that code, I think you need fromString() to parse the string in a "127.0.0.1" format, ie:
IPAddress local_ip(); local_ip.fromString(prem.MyIp); // sets local_ip to address in MyIp
- which is more time consuming and error prone than the constructor which just accepts (127,0,0,1) as arguments.
Theo
Le 19/06/22 à 15:25, zeneca a écrit :
I misspelled my question:
I would like to find a way allowing several siteId in a configuration. The system (a NodeMcu8266) would try them in sequence. For that I am trying:
struct netw { char *MXWifi;/*ssid*/ char *YYYZY; /*passwd*/ const char *MyIp; /*ip adress*/ struct netw *next; };
struct netw prem = {"AAACCCCCC","xvdfgghs","192,168,1,32"}; struct netw seco = {"Orange-aaa","7XyZzR","192,168,0,32"};
struct netw *current;
In setup()
DoConnect();
in void Doconnect() {
while(1) {
const char* ssid = current->MXWifi; const char* password = current->YYYZY;
IPAddress local_IP(current->MyIp);
Serial.println(current->MXWifi); Serial.println(current->YYYZY); Serial.println(current->MyIp); Serial.println("-------------------");
if (current->next != &prem) { current = current->next; } else { current = &prem; break; }
}Compilation fail on current->MyIP Doesn't' accept 198,162... nor 198.162... Type IPAdress seem to only accept:
#define MYIpad 192,168,0,32
Typically Arduino??
Many thanks in advances André
Oh, ha. Yeah that can be useful and I guess OP misunderstood that it wasn't one string.
Dana Sun, 19 Jun 2022 15:25:52 +0200, zeneca snipped-for-privacy@ailleur.fr napis'o:
As this is for PI which uses Linux, you should look at:
formatting link
look at WiFiMulti.
Le 21/06/22 à 13:52, Nikolaj Lazic a écrit :
Interesting, I will have a try. But the problem I a facing is my local provider doesnt give fixed ip address. So I have to give IPAdresse local_IP(MyIpAd); MyIpAd is #define 192,168,0,111 in another file. Regards
Run a local DNS (named, kea or knot) - I'm running named. Set it up to be authoritative for your local LAN and to pass all other requests to the global root DNS servers.
I think I will start a HOTSPOT on a Raspberry (maybe a Zero ) with dnsmask (dns and DHCP ) it also une local host table, and so be rid of the problem. But I need to use an extra system for this wich is... The Raspberry should have a second ethernet access (cable or a second wlan? looking for a Raspberry zero 2wh )
Am 20.06.2022 um 14:31 schrieb zeneca:
There is the problem -> const char *MyIp; /*ip adress*/
In Arduino IPAddress class is defined (in IPAddress.h) as:
IPAddress(); IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); IPAddress(uint32_t address); IPAddress(const uint8_t *address);
So the line
defines only a place holder 'MYIpad' and this satisfies the second definition above: IPAddress(MYIpad) -> IPAddress(192, 168, 0, 32)
You have to give the class initialiser 4 octets
Or you make a unsigned integer of 32 bits from the 4 octets, to store in your struct...
Hope this helps Philippe
How much bandwidth do you need ? Do you have a managed switch ? If the answers are favourable then you could run two VLANs out of the Pi and use the managed switch to present them to separate ports without the tagging. I did this years ago using an original Pi as a router.
The OP has an ESP8266 running the Arduino platform. That isn't a Raspberry Pi, isn't running Linux, they don't need to run extra servers on a Raspberry Pi to simply set an IPv4 address in their ESP8266, which is something that every machine in the last two decades needs to do.
OP, if you use wifiMulti, it already does DHCP for you. From that link above, see the log:
connected with sensor-net-1, channel 1 dhcp client start... ip:192.168.1.10,mask:255.255.255.0,gw:192.168.1.9
According to the source:
formatting link
IP is printed via:
Serial.println(WiFi.localIP());
So presumably that gives you the local IP, should you need it for further use.
Theo
Le 19/06/2022 zeneca snipped-for-privacy@ailleur.fr écrivait :
raspberry != Arduino
Dana Tue, 21 Jun 2022 14:40:22 +0200, zeneca snipped-for-privacy@ailleur.fr napis'o:
Your home AP handles DHCP requests. Your ESP will get local IP. Than your AP will send all your outgoing requests from its own address. In case you need to access your ESP from the net you will have to do port forwarding from your AP. That way you will be able to access your ESP from the net.
If you need to know your AP's dynamic IP address you can use some kind of external service... I have something like this for sending my IP:
formatting link
for getting my IP I use:
formatting link
You just have to send the first line from your ESP. Use the second line to get IP from yout AP to contact your ESP through port forwarding service on your AP.
You will be given local IP from your home Access point. Then sort out how to manage port forwarding on your AP.
Dana Tue, 21 Jun 2022 16:08:40 +0200, zeneca snipped-for-privacy@ailleur.fr napis'o:
That way you will again get the same functionality as with your AP connected to the internet (probably some kind of NAT... or CGNAT).
Zero has USB connection through four testpoints on the board. You can use those to connect to some USB HUB and connect anything you need. But you have to provide enough power to the USB HUB.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required