Things used in this project

Hardware components:
Pi 3 02
Raspberry Pi 3 Model B
×1
Software apps and online services:
Particle Cloud
Xidmhfnahh6gnduppwzf
Particle Pi
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

Contact

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

Control Adafruit NeoPixels using Python and JQWidgets
Easy
  • 928
  • 8

Full instructions

In this tutorial, we'll see how to control an Adafruit NeoPixel ring via mobile using Python and JQWidgets.

What's My I2C Address?
Easy
  • 244
  • 4

The story of how to make a clock through using a LCD 1602 or LCD 2004 over I2C.

I Keep My Cucumber Growing Conditions Moist - Part 3
Easy
  • 266
  • 3

Full instructions

This is the next step with an Particle Photon and softAP integration: cucumbers go online.

MyHumidity Controlled by BME280 and Photon
Easy
  • 521
  • 6

Full instructions

Checks if humidity threshold is reached and informs the user by using Blynk/IFTTT-services with softAP integration.

Study Buddy
Easy
  • 2,848
  • 141

Full instructions

Know when an assignment is coming up!

Study Buddy

Team Alexa and Shannon

MyLCD20x4 clock with value-added information
Easy
  • 40
  • 0

Full instructions

Use a Particle Photon, a BME280 sensor and a cheap LCD20x4 to start your own clock-project.

Add projectSign up / Login