Photon IPAddress 0.0.0.0

I have L3D cube up and running on my wifi network which I can interact with via the particle iOS app, the particle-cli node package and have been changing the demos using cubetube.org. I want to run the cube in the streaming mode but I’m having problems as the address reported for the photon is 0.0.0.0?

$ particle get L3D_Cube IPaddress
0.0.0.0

Any ideas?

Hi @cjs

You probably have to wait for the address to become non-zero and then set your Particle variable. The address 0.0.0.0 means that WiFi is not setup yet.

@bko thanks for the reply however I am still confused?

When you say “set your Particle variable” what do you mean? I have to manually set the device IP Address to an address routeble on my network? I can see the device (along with it’s address) from my routers web interface.

I don’t understand how the WiFi cannot be setup when I can see the device in particle app (showing as online) and the LED is breathing cyan suggesting it’s in connected mode?

Hi @cjs

The command you showed above particle get L3D_Cube IPaddress reads a Particle cloud variable named IPaddress from a device named L3D_Cube. There is some code on your Photon that is supplying the value of that particle variable by defining Particle.variable in the setup() function. This is the part that needs to be fixed.

Can you tell or show what code you are using on your Photon?

Thanks @bko that makes things clearer to me now.

Here is the code I’m trying to get running https://github.com/enjrolas/L3D-Software

I can get the demo application working https://github.com/enjrolas/L3D-Software/tree/master/Native/Demo/binary however it’s the streaming one I’d like to get running https://github.com/enjrolas/L3D-Software/blob/master/Streaming/Listener/Listener.ino so I can using the processing library https://github.com/enjrolas/L3D-Library

Hi @cjs

OK this is a bit unusual since normally, as you said, by the time setup() is running in automatic mode the IP address is set. There was a problem with earlier Photon base firmware not updating the IP address, so the first thing to make sure is that your Photon is running 0.4.7.

If that is try you can try modifying this function:

void updateNetworkInfo()
{
    IPAddress myIp = WiFi.localIP();
    sprintf(localIP, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);
    byte macAddr[6];
    WiFi.macAddress(macAddr);
    sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x",macAddr[5],macAddr[4],macAddr[3],macAddr[2],macAddr[1],macAddr[0]);

    //print it out the serial port
    Serial.print("local IP Address: ");
    Serial.println(localIP);
    Serial.print("MAC address:  ");
    Serial.println(macAddress);
}

Try something more like this:

void updateNetworkInfo()
{
    IPAddress myIp = WiFi.localIP();
    while(myIp[0] == 0) {
      myIp = WiFi.localIP();
      Particle.process();  //EDIT As ScruffR notes, you need to call this
    }
    sprintf(localIP, "%d.%d.%d.%d", myIp[0], myIp[1], myIp[2], myIp[3]);
    byte macAddr[6];
    WiFi.macAddress(macAddr);
    sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x",macAddr[5],macAddr[4],macAddr[3],macAddr[2],macAddr[1],macAddr[0]);

    //print it out the serial port
    Serial.print("local IP Address: ");
    Serial.println(localIP);
    Serial.print("MAC address:  ");
    Serial.println(macAddress);
}
    while(myIp[0] == 0) {
      myIp = WiFi.localIP();
    }

In earlier versions this didn’t work (as far as I remember) unless you called Particle.process() inside the loop, since WiFi.localIP() only returns the buffered IP, but the transfer from the WiFi module to the buffer needs to be performed by the cloud maintenance routines (e.g. via explicitly calling Particle.process() in non-multithreaded mode).

1 Like

Great point! Thanks @ScruffR!

1 Like

@bko @ScruffR Thank you both! After making the changes suggested above all is now working as expected.

I did spend some time trying to flash the device from the command line however it kept complaining about not being able to find the neopixel library. I ended up just using build.particle.io to create the binary, would be nice to use the particle command however.

1 Like

Have you got the sources for the library in your project folder and in the correct places for the includes as well?

@ScruffR it tried with neopixel.[h,cpp] in the root directory with Listener.ino and also with the files in a subdirectory neopixel.

To reference the files on the same level as the .INO you’d need to change this #include "neopixel/neopixel.h" to only #include "neopixel.h"

And to use subdirectories, you need to put a text file particle.include into the root folder of your project which lists all the files (with their relative path).
like this

particle.include

neopixel/neopixel.h
neopixel/neopixel.cpp