Just got this little board and I’m having trouble with the “sending data to the cloud” portion.
What does work
The tinker reads pins
The build IDE sends to the board
The scripts run on the board
I can serial output the data I want
Particle.publish seems to compile with everything else and the rgb flashes accordingly
What doesn’t
The console never receives an event
The “last connection” info only updates if I reflash the board
Any suggestions on how to troubleshoot this?
Thanks in advance T
Thanks Moors
I’ve been playing with delays. No result
Here is a 3-4th iteration lol
// Define the Pin the Temperature sensor is on
int tempPin = A0;
int led = D7; // The on-board LED
// Create a variable that will store the temperature value
double temperature = 0.0;
double temperatureF = 0.0;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
digitalWrite(led, HIGH);
// Keep reading the sensor value so when we make an API
// call to read its value, we have the latest one
int reading = analogRead(tempPin);
// The returned value from the device is going to be in the range from 0 to 4095
// Calculate the voltage from the sensor reading
double voltage = (reading * 3.3) / 4095.0;
// Calculate the temperature and update our static variable
temperature = (voltage - 0.5) * 100;
// Now convert to Farenheight
temperatureF = ((temperature * 9.0) / 5.0) + 32.0;
Serial.print(temperature); Serial.println(" degrees C");
delay(10000);
Particle.publish("temperature",temperature);
Particle.variable("temperatureF",temperatureF);
delay(60000);
digitalWrite(led, LOW); // Turn OFF the LED
delay(54000);
}
I get the cyan breath flash constantly only get the cyan blink when I flash to the board. I did get some intermittent “null” data with my first few scripts.
T
Your delays won't need to be that long. As long you don't publish more than once every 1010 milliseconds (I know it's supposed to be 1000, but in older versions there was a bug).
That variable line is just thrown in to see if it will send as opposed to a publish line.
The delay times have just been sent out to 1min as there is no need for anything quicker.
I have just been using a an arduino serial monitor to get the serial data and the console to check for uploads( ardiuno works ok).
Ta
T 24h on photon lol
But for testing it’s usually good to have shorter delays to allow for shorter test cycles
And about Particle.variable(), still move it to setup(), how it’s supposed to be used.
thanks for the help everyone. Need to do some cooking. heres one of my other attemts that gave the same
//TMP36 Pin Variables
int sensorPin = A0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
int TempSensor; //to view the result open the serial monitor
}
void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
Particle.publish("temperature", sensorPin);
delay(1000);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 3.3;
voltage /= 4095.0;
// print out the voltage
Serial.print(voltage); Serial.println(" volts");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
Serial.print(temperatureC); Serial.println(" degrees C");
Particle.publish("temperatureC ",temperatureC);
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
delay(60000); //waiting a second
}
if anyone has a few minutes can they see the common problem?
And @TonyMc, when you provide a new version of your code, it would be nice to see that you’ve at least incorporated the hints you got so far.
There is also no overload of Particle.publish() that would publish an int (which is the type of sensorPin) or float (which is the type of temperatureC).
Try @chrisb2’s suggestion!