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() {
void loop() {
 // this delay will slow down this rasppi particle agent process so the pi keeps its cool ;)
 // without this delay, top (the command line util on the pi) shows 100% CPU use (of the firmware.bin process)
 // with this delay, top shows 2% CPU use, much better
 delay(1000);
}
}


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

Two Person Weasley Clock with Particle Photon and IFTTT
Easy
  • 689
  • 8

Full instructions

Taking inspiration from the Harry Potter character's Weasley clock, this one uses Particle and IFTTT to tell you where two people are.

Security+ 2.0 MyQ Garage Door Opener
Easy
  • 770
  • 3

Full instructions

Interface newer garage door openers with more than a relay.

IoT Alcohol Tester
Easy
  • 1,896
  • 16

Full instructions

This project explains how to build a device for estimating blood alcohol content from a breath sample.

Temperature and humidity monitor
Easy
  • 337
  • 3

Full instructions

This is a project that uses SHT30 to get the current temperature and humidity. And then displays it on a no-chip embeded LCD.

Measuring temperature and humidity with Particle Photon
Easy
  • 528
  • 3

Full instructions

Measure temperature and humidity with Particle Photon and Adafruit Si7021 using the Adafruit Si7021 library for I2C based communication.

Study Buddy
Easy
  • 2,391
  • 140

Full instructions

Know when an assignment is coming up!

Study Buddy

Team Alexa and Shannon

Add projectSign up / Login
Respect project