Back to Smartcitizen.me

Battery Mode and Setting the Time

Hello,

I was kindly advised that for the SCK battery, “battery life depends on the operation mode. In NORMAL mode, it should last around 24 hours. In ECO mode, around 60 hours. This is something you change when uploading the firmware via Arduino IDE.”

Can anyone provide me with instructions on how to do this?

Also, when I first connected the SCK the UTC time for the sensor readings displayed with a date of 01-01-2000 and an incorrect time. Now the UTC time is blank. I have not yet configured the SCK to connect to a wireless network, could this be the reason?

Or does the time have to be set manually and if so how?

Many thanks in advance for any responses to my questions!

Hi @louisakgh,

The sensor mode can be changed in the “Constants.h” file. Lines 88-91 look like this:

#define DEFAULT_TIME_UPDATE 60 //Time between update and update
#define DEFAULT_MIN_UPDATES 1 //Minimum number of updates before posting
#define POST_MAX 20 //Max number of postings at a time
#define DEFAULT_MODE_SENSOR NORMAL //Type sensors capture (OFFLINE, NOWIFI, NORMAL, ECONOMIC)

In line 91, change “NORMAL” to “ECONOMIC”

The entire file can be found at: https://github.com/fablabbcn/Smart-Citizen-Kit/blob/a1092fbdcceec30ca319d804ac4058f055a2f2ac/sck_beta_v0_9/Constants.h

As for the time, it will update on it’s own after you’ve connected to the internet.

Keep posting your questions, comments and recommendations. Thanks,

-Matt
SCK 685

Hi Matt,

Many thanks for your response! Apologies and a bit embarrasing but I am a complete newbie. Does the # comment out the line #define DEFAULT_MODE_SENSOR NORMAL and do I therefore need to remove it after I change the NORMAL TO ECONOMIC to make the change active?

Also, how do I upload that to the SCK? Do you have weblink to a howto that I could follow?

Thank you again so much!

Louisa

Hi @louisakgh,

Don’t worry about your level of newbie-ness, we are all still learning.

The comments can stay in the code, it doesn’t change the way it is executed.

As far as the upload, that’s a bit harder to explain all at once.

First, you’ll need the Arduino IDE (integrated development environment), it can be found here: http://arduino.cc/en/Main/Software
Arduino has some great “Getting Started” stuff:
http://arduino.cc/en/Guide/HomePage
But keep in mind that the SCK 1.1 is based on the Arduino Lillypad:
http://arduino.cc/en/Guide/ArduinoLilyPadUSB

Once you have that, you’ll need to get the code from Git Hub:


You’ll need to sign-up for an account before you can download the code. The zip file can be found at:

Let me know when you get to this point, and we’ll go to the next step.

-Matt
SCK 685

Hi Matt,

Sorry it took me some time to respond on this post. I’ve been trying to work with someone to 3D print an enclosure for me and it’s taking longer than expected while we wait for clear filament. Anyway, I’ve decided to go ahead and just get setup anyway.

The SCK (device ID 2070) is online and relaying data, although I think there’s a backend issue at the moment based on another post I saw where it says ‘No data received yet’ when I click on the device but data is showing in the graphs and ‘last update’ time / date changes regularly. So the device is working!

I have installed Arduino IDE (1.0.5-r2), I’ve created my github account and I have downloaded the zip file from the link you provided. So I am ready for the next step, I hope :slight_smile:

Thanks and regards,
Louisa
(SCK 2070)

Hi @louisakgh,

Glad to see you’re moving ahead with your SCK. I checked your data posts, and yes, the updates are being received. It takes a few days for the “no data received yet” to go away.

To get to the point you are at now, I’m guessing you registered and added your SCK via the tools found on smartcitizen.me. You will need to go through part of that again, but in the Arduino IDE.

Open Arduino IDE.
Connect your SCK via USB.
At the top of the IDE screen, got to Tools > Board > select LilyPad Arduino USB. Then Tools > Port > choose the USB port your SCK is connect to. Then File > Open > sck_beta_v0_9.ino (this file will be in the ones you downloaded from GitHub. Smart-Citizen-Kit-Master > sck_beta_v0_9 > sck_beta_v0_9.ino)

OK, when loaded, you should be on the first tab labeled “sck_beta_v0_9”

You will want to navigate to the “Constants.h” tab (should be the third tab).

Scroll down until you get to the section of code titled “WIFLY Firmware Setting” (the first line in this section is “#define networks 0”). You are going to need to change some of these defaults to match what you already entered when you registered and enrolled your SCK on the website.

First change:
#define networks 0
to
#define networks 1
(Here you’re telling the code that you want to connect to 1 network rather than 0 networks.)

Next change:
static char* mySSID[networks] = {
“SSID1” , “SSID2” , “SSID3” };
to
static char* mySSID[networks] = {
“MyWifiSSID” };
(But use your personal wifi SSID, not MyWifiSSID. Here you’re telling the code the name of the network that you want to connect to.)

Next change:
static char* myPassword[networks] = {
“PASS1” , “PASS2” , “PASS3” };
to
static char* myPassword[networks] = {
“MyPassword” };
(But use your personal wifi password, not MyPassword. Here you’re telling the code the password for the network that you want to connect to.)

Next change:
static char* wifiEncript[networks] = {
WPA2 , WPA2 , WPA2 };
to
staticchar* wifiEncript[networks] = {
WPA2 };
(But use your type of wifi encryption, which may or may not be WPA2. Your options are: Open, WEP, WPA1, WPA2, and WEP64. Here you’re telling the code the type of wifi encryption for the network that you want to connect to.)

Last change for the network settings:
static char* antennaExt[networks] = {
INT_ANT , INT_ANT , INT_ANT };
to
static char* antennaExt[networks] = {
INT_ANT }; //EXT_ANT
(But use your type antenna, which may or may not be the internal chip antenna. Your options are: INT_ANT, and EXT_ANT. Unless you’ve connected an external antenna to you SCK, use INT-ANT. Here you’re telling the code the type of antenna you’re SCK is using to use to connect to your network.)

When you’re done modifing the generic code with your specific info, it should look something like this:
#define networks 1
#if (networks > 0)
static char* mySSID[networks] = {
“MyWifiSSID” };
static char* myPassword[networks] = {
“MyPassword” };
static char* wifiEncript[networks] = {
WPA2 };
static char* antennaExt[networks] = {
INT_ANT }; //EXT_ANT
#endif

OK, are you still with me? Not hard, but using the website is much easier. Now we can make the changes you came her for: DEFAULT_MODE_SENSOR.

Scroll down until you get to this line of code: #define DEFAULT_TIME_UPDATE. You will see four lines of code in this section:

#define DEFAULT_TIME_UPDATE 60
(Here you’re telling the code to gather reading from each of the sensors every 60 seconds and compile those readings into an update. If your goal is to conserve battery life, you can change the “60” seconds to a longer time-frame.)

#define DEFAULT_MIN_UPDATES 1
(Here you’re telling the code to post the compiled sensor update every time the readings are taken. Each time you post your updates, the SCK has to “Wake-up” the wifi and confirm a signal connection. If your goal is to conserve battery life, you can change the “1” update to a wait until the SCK has many updates to post. I don’t know how much on-board memory the SCK has to dedicate to the updates, but I would expect to to be a ton.)

#define POST_MAX 20
(Here you’re telling the code the max number of updates sent over wifi during a single post is 20. If you change the DEFAULT_MIN_UPDATE in the previous line to something greater than the value used for POST_MAX, you will always be losing data. The only time I can think this value will be useful is if you lose your wifi connection. Since the SCK will keep gathering sensor readings and compiling updates even without a wifi connection, the SCK will want to post those updates when a connection is re-established.)

#define DEFAULT_MODE_SENSOR NORMAL //Type sensors capture (OFFLINE, NOWIFI, NORMAL, ECONOMIC)
(Here you’re telling the code that the your SCK is in NORMAL operation. If you change it to ECONOMIC, the SCK gas sensor will only take readings once per hour. Note: the gas sensor works by heating a small circuit. This heating draws a ton of energy, and that’s why the ECONOMIC mode results in longer battery life)

OK, so your code should now look something like this:

#define DEFAULT_TIME_UPDATE 60 //Time between update and update
#define DEFAULT_MIN_UPDATES 1 //Minimum number of updates before posting
#define POST_MAX 20 //Max number of postings at a time
#define DEFAULT_MODE_SENSOR ECONOMIC //Type sensors capture (OFFLINE, NOWIFI, NORMAL, ECONOMIC)

You’re now done modifying the code. Go to the top of the IDE screen, File > Save. Then click on the circle with the check-mark (doing this will verify you have valid code and will pu it all together to be uploaded). Now click on the circle with the arrow (right next to the circle with the check-mark), this will upload the code to your SCK.

Congratulations. You’re done.

Let me know if you get stuck along the way. Good luck.

-Matt
SCK 685

Hi @jgysenbergs,

Glad to hear it.

-Matt
SCK 685