Introduction: Particle Photon - Semi Automatic and Manual Mode

Picture of Particle Photon - Semi Automatic and Manual Mode

The Particle Photon is a tiny IoT device and being of a small form factor it is ideal to use it for wearable. But beside the form factor, we need to need to calculate the current consumption so we can run it off a battery. Keeping the photon connected to the internet all the time will drag more juice off your battery, so a solution to that would be to connect to the WiFi only when needed and keep it switched off when not in use.

Fortunately, this is really simple to do with the Photon with just a few lines of code. So in this instructable I will be showing you how to use the particle photon in semi automatic mode and in manual mode and the current drawn in each case.

Step 1: Tools and Components

Picture of Tools and Components

For this Project you will need

  • Particle Photon
  • Breadboard
  • 5V power supply (I used a bench top power supply)
  • Multi-meter

Note- The particle photon come with the breadboard and microUSB cable in the box.

Step 2: Connect to the Particle Cloud

Picture of Connect to the Particle Cloud

If you just ordered a brand new photon the first step is getting it connected to the internet and the Particle Cloud. All you need for this step is to download the particle app for android or your apple device. Create a user account in the app and login into it.

Once you login you should see the option to add a new device, follow the on screen instructions to add the photon to your account and also get it connected to your WiFi network. Once connected to the internet, you should see the on board LED blink cyan, and after a successful connection to the particle cloud you should see it breathing cyan.

Step 3: Semi Automatic Mode

Picture of Semi Automatic Mode

By default the photon is in automatic mode in this mode the photon remains connected to the WiFi network the photon can be put into semi automatic mode by specifying the below line of code in the start of the program.

SYSTEM_MODE(SEMI_AUTOMATIC);

In semi automatic mode the photon doesn't connect automatically to the WiFi network as in the Automatic mode it waits for Particle.connect() to be called and then connects to the internet. This can be done by checking the state of a digital pin and then calling Particle.connect() once the state has been changed. This example has been shown in the code below.

In semi automatic mode when the WiFi is turn off the photon drags 31mA of current while when the WiFi is on it drags 78mA of current.

SYSTEM_MODE(SEMI_AUTOMATIC);

boolean connectToCloud = false;

void setup() { pinMode(D7, OUTPUT); attachInterrupt(D1, connect, FALLING); }

void loop() { digitalWrite(D7, HIGH); delay(500); digitalWrite(D7, LOW); delay(500);

if(connectToCloud && Particle.connected() == false) { Particle.connect(); connectToCloud = false; } }

void connect() { connectToCloud = true; }

Step 4: Manual Mode

Picture of Manual Mode

A photon in manual mode gives you full control of the photon, it not only allows you to call Particle.connect(), but also allows you to process the information revived from the photon at a specific time. So you can call Particle.process(), whenever you want the WiFi data to be processed. This keeps the RAM free for other tasks or lets you process only relevant data to you.

The Sample code below shows you how to keep the photon running in manual mode.

SYSTEM_MODE(MANUAL);

boolean connectToCloud = false;

void setup() { pinMode(D7, OUTPUT); attachInterrupt(D1, connect, FALLING); }

void loop() { digitalWrite(D7, HIGH); Particle.process(); delay(500); digitalWrite(D7, LOW); Particle.process(); delay(500);

if(connectToCloud && Particle.connected() == false) { Particle.connect(); connectToCloud = false; } }

void connect() { connectToCloud = true; }

Step 5: Going Further

Picture of Going Further

As you may have seen there is a significant difference in current consumption when the photon is connected and not connected to WiFi, so now keeping the WiFi, off when not needed will help you design better ware able devices.

Comments

About This Instructable

502views

7favorites

License:

Bio: I post IoT projects relating to the Particle Photon and Particle Core
More by particleguy:Puli Saadham (Tamarind Rice)Spicy Potato FryParticle Photon - Wearable Pulse and Temperature Sensor
Add instructable to: