User Tools

Site Tools


oak:reference:offline

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
oak:reference:offline [2016/10/27 19:35]
pfeerick created
oak:reference:offline [2016/12/17 19:36]
pfeerick
Line 5: Line 5:
 This page is being put together due to this discussion: This page is being put together due to this discussion:
 https://​digistump.com/​board/​index.php/​topic,​2132.0.html https://​digistump.com/​board/​index.php/​topic,​2132.0.html
- 
  
 In a nutshell, you can use an Oak offline if you serial program it. No wifi or internet is needed for that mode of programming. However, you may not be using an Oak if that was the case. So perhaps your internet or wifi is intermittent,​ or you want to be able to turn the wifi off the save power. Can you do it? YES! In a nutshell, you can use an Oak offline if you serial program it. No wifi or internet is needed for that mode of programming. However, you may not be using an Oak if that was the case. So perhaps your internet or wifi is intermittent,​ or you want to be able to turn the wifi off the save power. Can you do it? YES!
  
 Basically, run the Oak in manual safe mode only mode so it doesn'​t auto-reboot when there is no wifi, and run the oak in SYSTEM_MODE(SEMI_AUTOMATIC) or SYSTEM_MODE(MANUAL)?​ to manage the wifi connection / internet connection yourself in code. You can then have the Oak connect to wifi when it's available, or in response to a button, etc.  Basically, run the Oak in manual safe mode only mode so it doesn'​t auto-reboot when there is no wifi, and run the oak in SYSTEM_MODE(SEMI_AUTOMATIC) or SYSTEM_MODE(MANUAL)?​ to manage the wifi connection / internet connection yourself in code. You can then have the Oak connect to wifi when it's available, or in response to a button, etc. 
 +
 +
 +====== Managing Wifi Manually ======
 +
 +If you want to manage your wifi manually, rather than via the SoftAP / OakConfig page, you can do that too. You have to option of using DHCP IP addresses, or static IP addresses also. If you don't know what a Static or DHCP IP address is, stuck with DHCP. The following two examples don't have a Particle connection until you enable them, nor do they connect to your WiFi until you tell them to. 
 +
 +===== DHCP IP Example =====
 +
 +<​code>​
 +SYSTEM_MODE(MANUAL);​
 +
 +#include <​ESP8266WiFi.h>​
 +
 +//Static IP stuff
 +char SSID[] = "​yournetwork"; ​   // your network SSID
 +char passwd[] = "​yourpassword";​ // your network password
 +
 +void setup()
 +{
 +  pinMode(LED_BUILTIN,​ OUTPUT);
 +  ​
 +  //​don'​t save these details
 +  WiFi.persistent(false);​
 +
 +  //start the WiFi connection process
 +  WiFi.begin_internal(SSID,​ passwd, 0, NULL);
 +
 +  //wait for WiFi to connect
 +  while (WiFi.status() != WL_CONNECTED)
 +  {
 +    digitalWrite(LED_BUILTIN,​ HIGH);
 +    delay(100);
 +    digitalWrite(LED_BUILTIN,​ LOW);
 +    delay(100);
 +  }
 +}
 +
 +void loop() ​
 +{
 +  digitalWrite(LED_BUILTIN,​ HIGH); ​  // turn the LED on (HIGH is the voltage level)
 +  delay(1000); ​                      // wait for a second
 +  digitalWrite(LED_BUILTIN,​ LOW);    // turn the LED off by making the voltage LOW
 +  delay(1000); ​                      // wait for a second  ​
 +}
 +</​code>​
 +
 +===== Static IP Example =====
 +
 +<​code>​
 +SYSTEM_MODE(MANUAL);​
 +
 +#include <​ESP8266WiFi.h>​
 +
 +//Static IP stuff
 +char SSID[] = "​yournetwork"; ​   // your network SSID
 +char passwd[] = "​yourpassword";​ // your network password
 +
 +//WiFi config stuff
 +IPAddress ip(192, 168, 0, 70); //your static IP
 +IPAddress gateway(192,​ 168, 0, 1); //your gateway IP
 +IPAddress subnet(255, 255, 255, 0);  //your subnet mask
 +
 +void setup()
 +{
 +  pinMode(LED_BUILTIN,​ OUTPUT);
 +  ​
 +  //​don'​t save these details
 +  WiFi.persistent(false);​
 +
 +  //configure the WiFi to use the custom settings
 +  WiFi.config(ip,​ gateway, subnet);
 +
 +  //start the WiFi connection process
 +  WiFi.begin_internal(SSID,​ passwd, 0, NULL);
 +
 +  //wait for WiFi to connect
 +  while (WiFi.status() != WL_CONNECTED)
 +  {
 +    digitalWrite(LED_BUILTIN,​ HIGH);
 +    delay(100);
 +    digitalWrite(LED_BUILTIN,​ LOW);
 +    delay(100);
 +  }
 +}
 +
 +void loop() ​
 +{
 +  digitalWrite(LED_BUILTIN,​ HIGH); ​  // turn the LED on (HIGH is the voltage level)
 +  delay(1000); ​                      // wait for a second
 +  digitalWrite(LED_BUILTIN,​ LOW);    // turn the LED off by making the voltage LOW
 +  delay(1000); ​                      // wait for a second  ​
 +}
 +</​code>​
 +
  
 MMTC MMTC
oak/reference/offline.txt · Last modified: 2016/12/17 19:42 by pfeerick