Have a code I used awhile ago with the first core. Just received my new cores planed back the same program but doesn’t work and blinks SOS 1. What the heck!?
MartyMart, did you compile it again on the web IDE just recently? If so, there are known RAM issues with the latest (2.2) web IDE that the Team is working on to fix.
I did recompile the same code but it said error compiling then I remove some // comment and it said great work but SOS… I miss my arduino now…
MartyMart, I had the same frustration with a demo I had to bring to the Maker Faire in San Mateo! I’ve had the same problem with Arduinos, especially with dynamic allocation. Hang in there, it WILL be fixed.
Thanks for the cheer up, I will go on and build my hardware, what happens if I reflash my old spark core?
MartyMart, everytime you flash your code over to any core from the web IDE, it also includes the core firmware which at this point is V0.2.2. Since this code has the RAM consumption issue, it will affect any code that is RAM “sensitive”, that is, near the maximum available for users. If you were using a local compile toolchain, you could “revert” back to the more stable V0.2.1. This issue will be the hot topic between the Elites and the Spark Team in the coming days so it will get resolved. @zachary and @Dave perhaps you can chime in here?
With new IDE revisions, the cloud verification/compilation has been tweaked slightly, so old code may refuse to compile. One interesting bug I found is that compilation can fail if there is something on the very first line in the IDE. If you start your code on line 2, you should be clear of that bug.
@Dave here! Please let me know if you have some code that isn’t compiling that should compile, I’d be happy to look into it and see if there is something I can improve.
Thanks!
David
bummer, doesnt work… tried it and same problem…
// Boite de statuts automatisés par SMS
// Tous droits réservés Martin Proulx
// Reproduction ou modification interdite
// Version 4 boutons avec BEEP de statut
// Version de code 2 pour Spark core
// Numéro de série 0002
// Service incendie L'Ange-Gardien - 272
char modele[] = "statuts via RAJA2-urgence";
//-----------------------------------------------------------------------------------------
// Paramètres des données du véhicule et des messages
char server[] = "smtp server here";
char smtpuser[] = "dmx2cWFtb2c=";
char smtppass[] = "Mjg0ZmVsaXg";
char emailexpediteur[] = "mail from: sender email here";
char emaildestinadmin[] = "rcpt to: admin email here";
char emaildestingroupe[] = "rcpt to: group email here";
char nomservice[] = "(SPI-PR L'Ange-Gardien)";
char vehicule[] = "VEHICULE 272";
char messagecle[] = "EN MARCHE";
char message1[] = "EN ROUTE POUR L'APPEL 10-16";
char message2[] = "DISPONIBLE EN CASERNE";
char message3[] = "HORS SERVICE";
char message4[] = "DISPONIBLE SUR ROUTE";
// Assignation des contantes
int beep1 = 0;
int ledpower = 2;
int ledready = 7;
int bouton1 = 3;
int bouton2 = 4;
int bouton3 = 5;
int bouton4 = 6;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 100; // interval at which to blink (milliseconds)
int i=1;
int j=0;
TCPClient client;
void setup()
{
// Assignation des fonctions des entrées et sorties
pinMode(beep1, OUTPUT);
pinMode(ledready, OUTPUT);
pinMode(ledpower, OUTPUT);
pinMode(bouton1, INPUT);
pinMode(bouton2, INPUT);
pinMode(bouton3, INPUT);
pinMode(bouton4, INPUT);
// Beep de rappel wifi
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(50);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(200);
}
void loop()
{
// Nomination de la fonction de prise d'état des boutons
buttonState1 = digitalRead(bouton1);
buttonState2 = digitalRead(bouton2);
buttonState3 = digitalRead(bouton3);
buttonState4 = digitalRead(bouton4);
// VÉRIFICATION DE L'ÉTAT DES BOUTONS
// Message clé
if (j=0){
client.connect(server, 25);
delay(1000);
client.flush();
client.println("ehlo");
client.flush();
client.println("auth login");
client.flush();
client.println(smtpuser);
client.flush();
client.println(smtppass);
client.flush();
client.println(emailexpediteur);
client.println(emaildestinadmin);
client.println("data");
client.println(vehicule);
client.println(messagecle);
client.println(nomservice);
client.println(modele);
client.println(".");
client.flush();
client.stop();
j=1;
}
// Bouton 1
if (buttonState1 == HIGH) {
digitalWrite(ledready, LOW);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
i=57;
client.connect(server, 25);
delay(1000);
client.flush();
client.println("ehlo");
client.flush();
client.println("auth login");
client.flush();
client.println(smtpuser);
client.flush();
client.println(smtppass);
client.flush();
client.println(emailexpediteur);
client.println(emaildestingroupe);
client.println("data");
client.println(vehicule);
client.println(message1);
client.println(nomservice);
client.println(modele);
client.println(".");
client.flush();
delay(10000);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(50);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
client.stop();
}
// Bouton 2
if (buttonState2 == HIGH) {
digitalWrite(ledready, LOW);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
i=57;
client.connect(server, 25);
delay(1000);
client.flush();
client.println("ehlo");
client.flush();
client.println("auth login");
client.flush();
client.println(smtpuser);
client.flush();
client.println(smtppass);
client.flush();
client.println(emailexpediteur);
client.println(emaildestingroupe);
client.println("data");
client.println(vehicule);
client.println(message2);
client.println(nomservice);
client.println(modele);
client.println(".");
client.flush();
delay(10000);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(50);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
client.stop();
}
// Bouton 3
if (buttonState3 == HIGH) {
digitalWrite(ledready, LOW);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
i=57;
client.connect(server, 25);
delay(1000);
client.flush();
client.println("ehlo");
client.flush();
client.println("auth login");
client.flush();
client.println(smtpuser);
client.flush();
client.println(smtppass);
client.flush();
client.println(emailexpediteur);
client.println(emaildestingroupe);
client.println("data");
client.println(vehicule);
client.println(message3);
client.println(nomservice);
client.println(modele);
client.println(".");
client.flush();
delay(10000);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(50);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
client.stop();
}
// Bouton 4
if (buttonState4 == HIGH) {
digitalWrite(ledready, LOW);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
i=57;
client.connect(server, 25);
delay(1000);
client.flush();
client.println("ehlo");
client.flush();
client.println("auth login");
client.flush();
client.println(smtpuser);
client.flush();
client.println(smtppass);
client.flush();
client.println(emailexpediteur);
client.println(emaildestingroupe);
client.println("data");
client.println(vehicule);
client.println(message4);
client.println(nomservice);
client.println(modele);
client.println(".");
client.flush();
delay(10000);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
delay(50);
digitalWrite(beep1, HIGH);
delay(200);
digitalWrite(beep1, LOW);
client.stop();
}
if (!client.connected())
{
client.stop();
}
if (Spark.connected()) {
digitalWrite(ledpower, HIGH);
digitalWrite(ledready, HIGH);
delay(75);
digitalWrite(ledready, LOW);
delay(75);
}
else
{
digitalWrite(ledready, LOW);
}
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
if (i<57){
digitalWrite(beep1, ledState);
i=i+1;
}
}
}```
MartyMart, if you want to share your code with one of us Elites like myself or @wgbartley , we can take a look to see what can be done.
It is a statuts box for fire trucks… when crew start the truck it sends an email to the officers stating truck started, the beeps for 15 seconds or so unless a button is pressed. 4 buttons in route, back to hall, maintenance etc… if you press a button it send a email to all firefighter stating the status button pressed. It actually work with core bought on september. Then ordered 4 more core then same program doesnt work anymore…
First core work flawlessly… had to fumble a bit the tcp client for it to work as it was jamming… This project was first built with an arduino that is still running also at this day…
I edited your post to wrap it in ``` … ```
to make it a little easier to read. I hope you don’t mind!
That looks like French in the comments. I think that automatically relegates it to @peekay123’s realm.
@MartyMart, I looked at the code and made some minor changes to store all your strings in flash instead of RAM. The other thing I noticed is that you don’t have any debouncing on your buttons and no error checking on your client.connect() calls. Nonetheless, I was able to compile the your .ino file using the Spark CLI and the web IDE and send it to one of my cores. It promptly connected and I have a nice breathing cyan. I don’t have any buttons connected but I don’t believe you even getting the code to run at all if I am correct. Here is the part of the code I changed:
static const char modele[] = "statuts via RAJA2-urgence";
//-----------------------------------------------------------------------------------------
// Paramètres des données du véhicule et des messages
static const char server[] = "smtp server here";
static const char smtpuser[] = "dmx2cWFtb2c=";
static const char smtppass[] = "Mjg0ZmVsaXg";
static const char emailexpediteur[] = "mail from: sender email here";
static const char emaildestinadmin[] = "rcpt to: admin email here";
static const char emaildestingroupe[] = "rcpt to: group email here";
static const char nomservice[] = "(SPI-PR L'Ange-Gardien)";
static const char vehicule[] = "VEHICULE 272";
static const char messagecle[] = "EN MARCHE";
static const char message1[] = "EN ROUTE POUR L'APPEL 10-16";
static const char message2[] = "DISPONIBLE EN CASERNE";
static const char message3[] = "HORS SERVICE";
static const char message4[] = "DISPONIBLE SUR ROUTE";
Give that a shot to see what happens.
perfect… thanks so much! What is the difference static char and char? As for debouncing I did not implement due to lock down of 10 seconds after button pressed to restrict from sending multiple different statuts to quickly… I will try it tonight. Can I use the same code in my old core?
I believe static char
stores the variables in flash whereas plain old char
stores in RAM.
@MartyMart and @wgbartley, the “static” part tells the compiler to only consider the variable in context of the file it is defined in (compilation unit). The important part the “const” which causes the compiler to put the var in flash instead of RAM. In Arduino land this is like PROGMEM.
finally had time to work again on this thing but still red… Please, is there any way to work with the old library has I dont have time anymore to fiddle with this thing. My old code was working and now I’m stuck with couple of those boards and what WAS working and still working on my first board is NOT on theses ones…
@MartyMart, this is an issue with the latest web IDE compiler causing programs to take more RAM than before. If you compile locally, you can use the previous stable core firmware version (2.1) and avoid the problem.
not use to compile locally, any reference sheet explaining where to find 2.1 version and how to do it?