Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
Particle Pi
×1
Software apps and online services:
Particle Cloud
porter app

Code

whatismyip.inoC/C++
copy-paste this code in your Particle IDE of choice
#include "application.h"

String externalip = "";

void setup() {
  
  // declare cloud variables
  // https://docs.particle.io/reference/firmware/photon/#particle-variable-
  // Up to 20 cloud variables may be registered and each variable name is limited to a maximum of 12 characters.
  Particle.variable("externalip", externalip);
  
  // declare cloud functions
  // https://docs.particle.io/reference/firmware/photon/#particle-function-
  // Up to 15 cloud functions may be registered and each function name is limited to a maximum of 12 characters.
  Particle.function("whatismyip", whatismyip);

}

void loop() {
 //nothing gets executed here
}


int whatismyip( String dummyParameter ) {
    
  // source: http://askubuntu.com/questions/95910/command-for-determining-my-public-ip
  Process proc = Process::run("curl ipinfo.io/ip");
  proc.wait();
  
  // The output is the external IP of the rasp PI
  String ipAddress = proc.out().readString();

  // publish it in the console
  Particle.publish("External IP", ipAddress );
  
  //refresh the cloud variable
  externalip = ipAddress;
  
  return 0;
}

Credits

Img 20160904 wa0001
Gustavo Gonnet

If you need professional help with a project, contact me at gusgonnet@gmail.com

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Chromebook Enrollment
Easy
  • 523
  • 9

Work in progress

For work every now and then I have to enroll up to 200 Chromebooks/Chromebits/Chromeboxes, so I wrote a script that does just that.

Particle Photon and Electron shield
Easy
  • 275
  • 3

Work in progress

I was tired of using push-in boards and jumpers for my projects, so I developed a shield for the Particle Electron.

Echo Kill Switch
Easy
  • 4,379
  • 21

Full instructions

Use Amazon Alexa to trigger an IFTTT applet that causes a Particle Photon to remove power from an Echo.

Particle + Raspberry Pi
Easy
  • 3,164
  • 19

Protip

The world's favorite low-cost computer now connects to the world's most popular IoT platform.

How to Command a RS485 Relays
Easy
  • 316
  • 3

Protip

Easy way to command a RS485 Relay boards with our Rotilio board.

Internet-connected Festive Tree
Easy
  • 244
  • 4

Full instructions

Spruce up your desk or home with an Internet-controlled 3D printed Holiday tree!

Add projectSign up / Login
Respect project