Photon Wifi selector software

Hi Mr. Rickkas7, What type of plug would i need for connecting the external battery to the Photon 2 with pin headers. Sir
Thanks

There is a battery connector on the Photon 2 module, a JST-PH 2-pin. It's described in detail in the battery guide.

Thanks Sir

Hi Mr. Rickkas7,

Presently I am getting the following error on the softApp page

mas-july-14-2.cpp:59:21: variable 'Header h' has initializer but incomplete type

error

mas-july-14-2.cpp:81:19: invalid use of incomplete type 'struct Writer'

This is happening on all the copies of my Particle apps
Would you give me some advice please

This is on Photon1
Thanks Sir.

Header.h is not a Particle header file, and I don't know what it is. However, if you are missing struct Writer it's probably because you are missing

#include "Particle.h"

at the top of your .cpp file.

Thank you Sir. #include "Particle.h" is already in the code at the top.
What is interesting is that I have had this App for a while with no errors then all of a sudden I am coming up with this starnag error. I have 23 Photon 1 CPUs and I have not been able to sell any of them yet. That makes me nervous

Are you sure you have selected photon or p1 as the build target? That header only exists on Photon 1 and P1, and thus only on Device OS 3.x and earlier.

Also struct Header is defined in the same place.

Thank you Sir You pointed out to my mistake so smartly

Sir I have one parameter on Photon2, TZ, it is the time zone. In case of mains power down I need to store TZ so that after the power is restored my device will work OK. I could use an external battery. Is there any other way I could save TZ parameter without the use of an external battery?
How can I store TZ in the flash ram?

On the Photon 2, use EEPROM or a file on the file system.

If you wanted the parameters to be cloud configurable, per device, use Ledger.

Thank you for your advice Sir. The following example given requires the actual value of the variable to be stored in the EEPROM.

// Write a value (2 bytes in this case) to the EEPROM address
int addr = 10;
uint16_t value = 12345; // in my case it would be -4, or -5 depending on the location of my device.
EEPROM.put(addr, value);
But I have a variable TZ ( Time Zone). this value is inputted by the user through my Web App. Is there any way around this issue?
Thanks

Sir there was another question I need to ask. In the read cycle from EEPROM

// Read a value (2 bytes in this case) from EEPROM address
int addr = 10;
uint16_t value;
EEPROM.get(addr, value);
if(value == 0xFFFF) {
// EEPROM was empty -> initialize value.
value = 25;
}

// What is the initialize for?

I don't entirely understand your question, but when you use the EEPROM for the first time on a new device, every byte is initialized to 0xff (not 0x00), so if you read a uint16_t from it, you'll get back 0xffff as the value.

Sir I need to save TZ in the EEPROM. the example given in docs.particle is as follows

// Write a value (2 bytes in this case) to the EEPROM address
int addr = 10;
uint16_t value = 12345;
EEPROM.put(addr, value);

12345 is the value that is saved.
can I replace it with
uint16_t value = TZ; ?

I hope I have made myself clear
Thanks

I still don't understand the question. Do you mean the Unix TZ variable? That's a string, not a number, and strings are a little tricky to save in EEPROM. However, why are you setting TZ? It's not well supported by the Time class. What are you using that uses TZ?

@kazem, if you are trying to save a "time zone" value to use with the Time.zone() DeviceOS function to set the time zone on startup then you:

  • Need to use a variable name that is not in conflict with TZ such as tzone.
  • You could declare tzone as int16_t (signed) value since it can have both positive and negative values.
  • You can store the tzone value in EEPROM using:
int addr = 10;
uint16_t tzone= -5;
EEPROM.put(addr, tzone);

You can then read the value on startup (in setup()) and set the timezone using:

EEPROM.get(addr, tzone);
Time.zone(tzone);

Of course, you need to set addr and declare tzone before doing this. These could be global variables so they can be accessed from anywhere in your code.

1 Like

Thanks for you kind advice sir
FYI i am using PHOTON-2
I am using GTZ variable for time zone
GTZ is inputted by the user from my webapp which could be any float number

In the main Ioop I have Time.zone(GTZ);// This can be written in set()
Can I make the following changes in your code

storing GTZ in the EEPROM
int addr = 10;
uint16_t tzone= GTZ;
EEPROM.put(addr, tzone);
GTZ = tzone

Reading GTZ in the setup()
EEPROM.get(addr, tzone);
GTZ =tzone;
Time.zone(GTZ);

@kazem, I am not sure what you are trying to do but if GTZ is a type float then store it in EEPROM as a float (4 bytes in EEPROM) instead of a uint16_t.