Serial Monitor in build?

I started using build for simple programs, it’s pretty nice, but is there a serial monitor? I’d like to be able to send numbers and text to my spark, like I did with arduinos. I’ve been looking around, but couldn’t find anything on the topic.

Also, is there any other GUI that I can write code for the spark for, like the arduino IDE? I know that arduino doesn’t work, it would be cool if there was a custom arduino IDE that was made for spark (since isn’t arduino all open-source?) I’m mostly interested in that for the serial monitor. I see you can compile code and do serial monitoring using command line, but I’m positively awful with computers and would rather not :stuck_out_tongue:

There is not any official desktop GUI for building with the Spark Core. There are a few different ways that are available for doing so, but they do require a bit of setup to get going. You can use any IDE that you would like, but building and flashing aren’t quite as one-click as the Arduino IDE. The Spark CLI makes things a lot easier, but it’s still all done on the command line. I can’t say that I blame you about not wanting do go through that hassle. I know how to do it, but I’d also rather not sometimes!

In the meantime, there is an article written in the forums for Installing the USB Driver on Windows & Serial Debugging (assuming you’re using Windows). If not, let us know and we can help steer you towards the easiest options for your operating system.

As soon as you’ve got those drivers installed, you can actually use the serial monitor from the arduino IDE. I guess a lot of people are used to it, but there are other alternatives as well.
Getting familiar with the CLI is something I strongly suggest doing. It’s not as hard as it seems, and for the ‘regular user’, a few simple commands are sufficient. I primarily use it to flash locally, using the .bin file from the web IDE. It’s a lot quicker (approx. 10 seconds). You can also use it for serial monitoring, which isn’t hard either. You simply have to type in “Spark serial monitor”, and that’s it. So in my opinion it’s definitely worthwhile getting to know the CLI.

2 Likes

Would puTTy work?

Yes it does, quite well. Also there is official Spark Dev application, which is something like Arduino environment, but much better.

http://docs.spark.io/dev/

Thanks @lami How can I get Spark Dev? I went to the link you provided but it didn’t exactly tell me how to get Spark Dev.

Thanks,
@Ricky

Have you tried scrolling down a bit ;)? https://github.com/spark/spark-dev/releases/latest

1 Like

Thanks @Moors7

@Moors7 Whenever I flash a firmware to it locally in dfu mode I cont open a serial port monitor. I have no idea how to monitor the port and run the program at the same time.

Try this:

@Jaybuilder98, I have to ask… do you have a Serial.begin() in your app’s setup()? If not, the Core will not enable its serial port and you will not see the device on your PC. :stuck_out_tongue:

2 Likes

Lol no I did not as I did not see that I had to include that

@Jaybuilder98, :stuck_out_tongue_closed_eyes: You should check this out in the documentation:

http://docs.spark.io/firmware/#communication-serial

In order to use Serial.print() to show debug messages in the terminal, you need to have Serial.begin(baud) in setup()! Note, however, that you should not have Serial.print() statements if you don’t have Serial.begin() :stuck_out_tongue_winking_eye:

1 Like

Then I’d highly recommend you try out the docs and the forum search functionalities next time, because it’s definitely in there :wink:
http://docs.spark.io/firmware/#serial-begin

2 Likes

@peekay123 I included that statement but now as soon as I flash the core it goes right into listening mode (Flashing Blue)

Could you share your entire code? That way we can have a look at it and see if/where there might be issues.

@Moors7

//declare variables for the motor pins
int turnD = D3; // turn DOWN
int turnU = D2; // Turn UP
int sensor = D6; // Hall Effect sensor input
bool isUp = false; // If up or not
int upcounter = 0;
int maxSteps = 1980;
bool partWayDownGoUp = false;
bool partWayGoDown = false;
int downTime = 1980;
String alarmTime = "";
String currentTime = "";
bool alarmEnabled = true;
String PassCommand = "";
String semi = ":";
String AM = "AM";
String PM = "PM";

//////////////////////////////////////////////////////////////////////////////
void setup() {
    // setup function to act on Spark API calls
    Spark.function("Blind", BlindControl);
    Spark.function("SetTime", setTimer);
    Spark.function("isTimerEnabled", checkTimerState);
    //declare the motor pins as outputs
    Time.zone(-5);
    Spark.syncTime();
    pinMode(sensor, INPUT);
    pinMode(turnU, OUTPUT);
    pinMode(turnD, OUTPUT);
    digitalWrite(turnU, HIGH);
    digitalWrite(turnD, HIGH);
    setBlindsUp();
	Serial.begin(9600);
	while(!Serial.available()) SPARK_WLAN_Loop();
}

//////////////////////////////////////////////////////////////////////////////

void loop(){
    getCurrentTime();
    Serial.println(alarmTime + "  Current:");
    Serial.print(currentTime);
    if(alarmTime.equals(currentTime) && alarmEnabled == true){
        PassCommand = "Open";
        BlindControl(PassCommand);  
    }
    delay(100);
}

//////////////////////////////////////////////////////////////////////////////

int BlindControl(String command){
   if (command=="Open") {
       while(isUp == false){
            goUp();
            delay(100);
       }
       digitalWrite(turnU, HIGH);
   }
   if (command=="Close" && isUp == true) {
       goDown();
   }
   return 1;
}

///////////////////////////////////////////////////////////////////////////////

int setTimer(String alarmSetTime){
    alarmTime = "";
    alarmTime = alarmSetTime;
    return 1;
}

///////////////////////////////////////////////////////////////////////////////

int checkTimerState(String state){
    if(state == "On"){
        alarmEnabled = true;
    }
    else if(state == "Off"){
        alarmEnabled = false;
    }
    return 1;
}

//////////////////////////////////////////////////////////////////////////////

void goUp(){
    digitalWrite(turnU, LOW);
    isUp = checkPosition();
    delay(100);
    upcounter += 100;
}

//////////////////////////////////////////////////////////////////////////////

void goDown(){//find out why this is fireing twice
    digitalWrite(turnD, LOW);
    if(partWayGoDown = true){
        downTime = 198000 - upcounter;
    }
    for (int i = 0; i < 4; i++){
        delay(downTime/4);
    }
    digitalWrite(turnD, HIGH);
    isUp = false;
    downTime = 198000;
    partWayGoDown = false;
}

//////////////////////////////////////////////////////////////////////////////

bool checkPosition(){
    bool isUpOrNot = false;
    if(digitalRead(sensor) == LOW){
        isUpOrNot = true;
    }
    else if(digitalRead(sensor) == HIGH){
        isUpOrNot = false;
    }
    return isUpOrNot;
}

//////////////////////////////////////////////////////////////////////////////

void setBlindsUp(){
    while(digitalRead(sensor) == HIGH){
        digitalWrite(turnU, LOW);
    }
    digitalWrite(turnU, HIGH);
    isUp = true;
}

//////////////////////////////////////////////////////////////////////////////

void getCurrentTime(){
    currentTime = "";
    int unixTime = Time.now(); //Returns Unix Time (Seconds)
    int hour = Time.hourFormat12(unixTime);
    String hourSTR = String(hour);
    int min = Time.minute(unixTime);
    String minSTR = String(min);
    int sec = Time.second(unixTime);
    String secSTR = String(sec);
    bool isAm = Time.isAM();
    
    if(isAm == true){
        currentTime.concat(hourSTR);
        currentTime.concat(semi);
        currentTime.concat(minSTR);
        currentTime.concat(semi);
        currentTime.concat(secSTR);
        currentTime.concat(AM);
    }
    else{
        currentTime.concat(hourSTR);
        currentTime.concat(semi);
        currentTime.concat(minSTR);
        currentTime.concat(semi);
        currentTime.concat(secSTR);
        currentTime.concat(PM);
    }
}

Ok I figured it out… turns out my core disconnected from the Wifi and forgot the credentials :smile: My Bad lol

1 Like