Can't get On WIFI#Connected to work
Moderators: grovkillen, Stuntteam, TD-er
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Can't get On WIFI#Connected to work
I'm using mega-20190315 and can't get...
On WIFI#Connected do
in a rule-set to work.
Does anyone know if this command works?
On WIFI#Connected do
in a rule-set to work.
Does anyone know if this command works?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Can't get On WIFI#Connected to work
Please show me the rule you're using.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Can't get On WIFI#Connected to work
Iv'e made it as simple as I can to test it out.
On WIFI#Connected do
publish node80/report,hello
endon
On WIFI#Connected do
publish node80/report,hello
endon
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Can't get On WIFI#Connected to work
What I'm trying to do is detect which WiFi network a Wemos D1 Mini connects to.
Then set a Gateway IP address accordingly.
One of my students has a gateway at his home of 192.168.1.254, while at our IoT Club it's 192.168.1.1
This means each week he has to manually alter the 'settings' in the 'Config' tab (then memember to change it back before he goes home).
I suspose we could detect... on System#Boot do
then trigger a timer for 'x' seconds (which should give the Wemos enough time to connect to a WiFi network) then check the %ssid% name.
Then set a Gateway IP address accordingly.
One of my students has a gateway at his home of 192.168.1.254, while at our IoT Club it's 192.168.1.1
This means each week he has to manually alter the 'settings' in the 'Config' tab (then memember to change it back before he goes home).
I suspose we could detect... on System#Boot do
then trigger a timer for 'x' seconds (which should give the Wemos enough time to connect to a WiFi network) then check the %ssid% name.
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Can't get On WIFI#Connected to work
I've created this rule, but for some reason the first IF test always evaluates to true.
What is the correct syntax for comparing a system variable to a text string ??
on System#Boot do
timerSet,1,5
endon
on Rules#Timer=1 do
If %ssid% = "iotclub" <<<<<<<<<<<<
Gateway,192.168.1.1
Publish node80/report,{"GW=":192.168.1.1}
else
Gateway,192.168.1.254
Publish node80/report,{"GW=":192.168.1.254}
endif
Publish node80/report,{"SSID=":%ssid%}
endon
What is the correct syntax for comparing a system variable to a text string ??
on System#Boot do
timerSet,1,5
endon
on Rules#Timer=1 do
If %ssid% = "iotclub" <<<<<<<<<<<<
Gateway,192.168.1.1
Publish node80/report,{"GW=":192.168.1.1}
else
Gateway,192.168.1.254
Publish node80/report,{"GW=":192.168.1.254}
endif
Publish node80/report,{"SSID=":%ssid%}
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Can't get On WIFI#Connected to work
Haven't read all your posts (on my phone), but wifi connect means just that - the wifi is connected. It doesn't mean your MQTT broker is connected. Use a LED and control it with the GPIO command and you'll see.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Can't get On WIFI#Connected to work
Thanks for you feedback.
When your have a chance - please can you look over the Rule I posted and see why the string comparison doesn't work ??
When your have a chance - please can you look over the Rule I posted and see why the string comparison doesn't work ??
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Can't get On WIFI#Connected to work
You cannot test strings (%) mathematically within the rules engine.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- dynamicdave
- Normal user
- Posts: 257
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Can't get On WIFI#Connected to work
If anyone is interested, I've managed to get a Rule-Set working to detect which WiFi network one of my student's WeMos D1 Mini is connected to.
At home his router has a GW and DNS of 192.168.1.254, while at our IoT Club the GW and DNS is 192.168.1.1
I've flashed one of my Wemos D1s with the version of ESP Easy that includes a 'ping' device.
When the D1 boots-up it sets the GW and DNS for his home (which is the default) and starts pinging that IP address.
If I get a 'good' ping, then the ping counter is incremented otherwise it stays at ZERO.
After 60-seconds the timer times-out and the value of the ping counter is checked.
If it still ZERO then the GW and DNS settings are switched over to the school's network.
Phew - that was fun.
Hope someone finds this useful.
At home his router has a GW and DNS of 192.168.1.254, while at our IoT Club the GW and DNS is 192.168.1.1
I've flashed one of my Wemos D1s with the version of ESP Easy that includes a 'ping' device.
When the D1 boots-up it sets the GW and DNS for his home (which is the default) and starts pinging that IP address.
If I get a 'good' ping, then the ping counter is incremented otherwise it stays at ZERO.
After 60-seconds the timer times-out and the value of the ping counter is checked.
If it still ZERO then the GW and DNS settings are switched over to the school's network.
Phew - that was fun.
Hope someone finds this useful.
Code: Select all
// Routine to check which WiFi network the WeMos D1 Mini is connected to
// Default is a PlusNet network at the student's home
on System#Boot do
Gateway,192.168.1.254 // Set GW for student's home network
DNS,192.168.1.254 // Set DNS for student's home network
Let,1,0 //zero the ping counter
timerSet,1,60
endon
on Rules#Timer=1 do
If [VAR#1]=0 // Check for ZERO pings (looks like the student is connected to the IoT Club's router)
Gateway,192.168.1.1 // Set GW for IoT Club's router
DNS,192.168.1.1 // Set DNS for IoT Club's router
endif
endon
on ping#value do
if [ping#value]>0 //Check if 'good' ping received
if [VAR#1] < 5
Let,1,%v1%+1 //Increment the ping counter
endif
endif
endon
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Can't get On WIFI#Connected to work
Just as a note. The settings will not be written to memory of no save command is made. It'll work just fine in Dave's case since the rules right away set the gateway and DNS.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Who is online
Users browsing this forum: Google [Bot] and 99 guests