I just got my Spark. I was able to connect to it from my iPad2 using tinker. I turned the LED on and off manually… I then logged into the website and deployed a blinker from the code editor, that worked too… Now, my iPad2 can’t find the core.
What do you mean by can’t find your core?
Did the core run the blinker code you mentioned?
It sounds like you ran your own firmware (blinker) so Tinker has been replaced by your code and is not running now. If you are expecting to turn the LED on and off with the TInker interface on your iPad, then you need to be running the Tinker app on your core. Is that what you meant by can’t find the core? If so, then if you reload Tinker (via factory reset or directly) you can control it from the iOS app again.
Well, @bko beat me to it (again!). For the sake of having said it; documentation of Tinker can be found on the documentation pages, right here. As you’ll notice, it’s just another piece of code. Since this is being overwritten as soon as you flash your own code, the Tinker app won’t work anymore.
Given the responses I’m going to mark this as solved but if you have any more comments @robby feel free to respond.
This post has a surprisingly high density of “elite” responses. Just wanted to point that out. Of course I’m the combo-breaker
I just wanted to reply to ensure we are in fact smothering you with premium support @robby! Have a great day.
- I was initially able to connect to the core through my iPad2 using Tinker.
- I then connected to the core through the web site interface and pushed some basic blinker code to the core.
- I then tried to use my iPad again to connect to the core and now it will not.
This is as clear as I can possibly describe the issue / situation.
@harrisonhjones How can it “be solved” yet if I haven’t applied any of the comments, tested and replied with the results???
Hi bko! Thanks for responding.
I simply followed the “Step by Step” that Spark.io provided. Nothing special done, basic “Hello world” stuff. It seems that connecting to the site and browser code editor locked out the ability for Tinker on my iPad2 to reconnect.
R
Hello BDub!
Thank you for responding. I’m still working on this.
(I just wish “some” people would not jump to conclusions for quickly.) ;>
R
For the tinker app to work, the spark core is running the default firmware code that allows it to expose functions for interaction with the mobile app.
If you flash your own code, tinker will not work anymore unless you deliberately add in the the tinker functions.
You can see how it is written here: https://github.com/spark/firmware/blob/master/applications/tinker/application.cpp
@ kennethlimpp - Thank you! I will try that tonight when I get home and reply back with the results. I appreciate your help :> R
It sounds like you may have pushed some bad code to the Core. Bad meaning perhaps something you coded is resulting in a hard loop that doesn’t allow the background tasks to get called and keep the connection to the Cloud alive and responding. It might not be this, but if it is… one easy way to get back to a clean slate is to Factory Reset your Core. Just hold the MODE button, and tap the RESET button. Continue holding MODE until you see first a flashing YELLOW, and then finally flashing WHITE. Release MODE and let it get all of the way back to blinking BLUE. Now enter your WiFi credentials again via the Spark App on your iPad (or whichever method you prefer). If the cycle keeps happening, post the code that you are flashing to your Core that makes it unresponsive and we’ll have a look and see what we see
Sorry for jumping to conclusions. Given the similar responses to your issue and the issue itself it seemed to me that your issue had been solved sufficiently and only required reading the responses. I still maintain that is the case but I have removed the label and will continue to monitor the thread.
I hope you are able to get your problem figured out! While it isn’t super clear to new comers the tinker app on iOS and Android only works with the stock firmware. If you flash your own firmware and (as @kennethlimcp mentioned) do not include the tinker functions then the Tinker app will NOT work and will NOT be able to “connect.” Tinker is mostly for testing and basic demonstrations.
@BDub Re:Pushing bad code. This was the “Blink an LED” from the list of Examples.
https://www.spark.io/examples/530cf6189d8d19b340000001
After I pushed this (above), I could no longer use Tinker from my iPad2
The fact that Tinker doesn’t work after flashing that code is completely normal. Don’t worry, nothing appears to be wrong with your core, code, or iOS app.
The example you flashed simple blinks the small onboard LED and an external LED (if you wired it in) on D0. Because the code doesn’t have any of the supporting Tinker functions Tinker won’t work.
@harrisonhjones: Thank you! I’m starting to get a clearer picture. If I may I suggest an embedded or link to a video explaining this (holistic overview) to newbs like me… ;>
Explaining what exactly? I’d love to help but I need a better understanding of what you are unclear on. I will try to give a brief overview of how the core works.
The core runs software (firmware) which the user programs onto it. When the core boots up it connects to WiFi and then it connects to the Spark Cloud. The default software allows for the cloud to issue commands (turn on D0, turn off D1, etc). The iOS app is capable of telling the cloud to issue these commands. This is how tinker works! There are other cloud-related functions like pulling variables from the core, pushing events, and subscribing to events. This allows the core to be used in several different ways. You can talk to the core: issue it commands & pull out numbers (like an analog value for example or temperature). You can also have the core talk to you and listen for you: it can issue events like “Hey the water is too hot” or it can listen for events (“Hey, the water is too hot”? Ohk I’ll turn off the water). All of this is possible because of the core-to-cloud connection.
My suggestion would be to go through the example and then pick a project and attempt it. If you run into problems post on the forums and we’ll be happy to help!
BTW just double checking that after you flash that Blink and LED example, your D7 LED is blinking, correct?
You can get back to the Tinker app with Factory Reset, or if you are still able to re-flash your Core, you can create a new App in the Web IDE, and paste the following code into it and call it Tinker. Study this code and browse the Docs to understand how it works
/**
******************************************************************************
* @file application.cpp
* @authors Satish Nair, Zachary Crockett and Mohit Bhoite
* @version V1.0.0
* @date 05-November-2013
* @brief Tinker application
******************************************************************************
Copyright (c) 2013 Spark Labs, Inc. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, see <http://www.gnu.org/licenses/>.
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "application.h"
/* Function prototypes -------------------------------------------------------*/
int tinkerDigitalRead(String pin);
int tinkerDigitalWrite(String command);
int tinkerAnalogRead(String pin);
int tinkerAnalogWrite(String command);
/* This function is called once at start up ----------------------------------*/
void setup()
{
//Setup the Tinker application here
//Register all the Tinker functions
Spark.function("digitalread", tinkerDigitalRead);
Spark.function("digitalwrite", tinkerDigitalWrite);
Spark.function("analogread", tinkerAnalogRead);
Spark.function("analogwrite", tinkerAnalogWrite);
}
/* This function loops forever --------------------------------------------*/
void loop()
{
//This will run in a loop
}
/*******************************************************************************
* Function Name : tinkerDigitalRead
* Description : Reads the digital value of a given pin
* Input : Pin
* Output : None.
* Return : Value of the pin (0 or 1) in INT type
Returns a negative number on failure
*******************************************************************************/
int tinkerDigitalRead(String pin)
{
//convert ascii to integer
int pinNumber = pin.charAt(1) - '0';
//Sanity check to see if the pin numbers are within limits
if (pinNumber< 0 || pinNumber >7) return -1;
if(pin.startsWith("D"))
{
pinMode(pinNumber, INPUT_PULLDOWN);
return digitalRead(pinNumber);
}
else if (pin.startsWith("A"))
{
pinMode(pinNumber+10, INPUT_PULLDOWN);
return digitalRead(pinNumber+10);
}
return -2;
}
/*******************************************************************************
* Function Name : tinkerDigitalWrite
* Description : Sets the specified pin HIGH or LOW
* Input : Pin and value
* Output : None.
* Return : 1 on success and a negative number on failure
*******************************************************************************/
int tinkerDigitalWrite(String command)
{
bool value = 0;
//convert ascii to integer
int pinNumber = command.charAt(1) - '0';
//Sanity check to see if the pin numbers are within limits
if (pinNumber< 0 || pinNumber >7) return -1;
if(command.substring(3,7) == "HIGH") value = 1;
else if(command.substring(3,6) == "LOW") value = 0;
else return -2;
if(command.startsWith("D"))
{
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, value);
return 1;
}
else if(command.startsWith("A"))
{
pinMode(pinNumber+10, OUTPUT);
digitalWrite(pinNumber+10, value);
return 1;
}
else return -3;
}
/*******************************************************************************
* Function Name : tinkerAnalogRead
* Description : Reads the analog value of a pin
* Input : Pin
* Output : None.
* Return : Returns the analog value in INT type (0 to 4095)
Returns a negative number on failure
*******************************************************************************/
int tinkerAnalogRead(String pin)
{
//convert ascii to integer
int pinNumber = pin.charAt(1) - '0';
//Sanity check to see if the pin numbers are within limits
if (pinNumber< 0 || pinNumber >7) return -1;
if(pin.startsWith("D"))
{
pinMode(pinNumber, INPUT);
return analogRead(pinNumber);
}
else if (pin.startsWith("A"))
{
pinMode(pinNumber+10, INPUT);
return analogRead(pinNumber+10);
}
return -2;
}
/*******************************************************************************
* Function Name : tinkerAnalogWrite
* Description : Writes an analog value (PWM) to the specified pin
* Input : Pin and Value (0 to 255)
* Output : None.
* Return : 1 on success and a negative number on failure
*******************************************************************************/
int tinkerAnalogWrite(String command)
{
//convert ascii to integer
int pinNumber = command.charAt(1) - '0';
//Sanity check to see if the pin numbers are within limits
if (pinNumber< 0 || pinNumber >7) return -1;
String value = command.substring(3);
if(command.startsWith("D"))
{
pinMode(pinNumber, OUTPUT);
analogWrite(pinNumber, value.toInt());
return 1;
}
else if(command.startsWith("A"))
{
pinMode(pinNumber+10, OUTPUT);
analogWrite(pinNumber+10, value.toInt());
return 1;
}
else return -2;
}