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

Direct Photon to TP-Link Device Control
Easy
  • 291
  • 7

Full instructions

Add this small file to your project to control TP-Link bulbs and plugs directly with simple subroutine calls.

Poor Man's CAN Bus
Easy
  • 163
  • 4

Protip

Learn how to connect microcontrollers together using the CAN bus by using a simple AND gate

Internet Connected Bubble Machine
Easy
  • 34
  • 2

Full instructions

Make it possible to activate a bubble machine from anywhere using a Particle Photon

MyPIR-Sensor activate analog RGB Stripe controlled by Photon
Easy
  • 92
  • 2

Full instructions

At my age you have to get up at night and get tired on the way to the bathroom. Using a PIR-Sensor to trigger light on!

Weather Box
Easy
  • 2,185
  • 11

Full instructions

Small weather station that uploads to Weather Underground with a NeoPixel ring for visualization.

Washer/Dryer Monitor
Easy
  • 582
  • 5

Full instructions

Monitor your appliance's power indicator with a photocell for easy notifications without high voltage wiring.

Add projectSign up / Login
Respect project