Hello,
I’ve been trying to build out a couple of basic ideas with my BoltIoT. After my async push question I’ve moved on to using the Boltduino shield. I built a very simple script that uses the PIR to count the number of movements that occur. When movement occurs I light the built in LED. During the loop phase I take the current count and send it via serial. I’ve monitored the serial output to see that everything works as I expect it to. However, I’m not getting any values via the cloud app. It says it never has received a value.
Here’s my script that’s running on the arduino:
#include <BoltIot-Arduino-Helper.h>
int ledPin = LED_BUILTIN; // choose the pin for the LED
int inputPin = 4; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
boltiot.Begin(Serial);
Serial.begin(9600);
}
int counter = 0;
void loop() {
// put your main code here, to run repeatedly:
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
Serial.print("Motion detected! Times detected: ");
Serial.println(counter);
// We only want to print on the output change, not state
pirState = HIGH;
counter++;
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended! ");
// We only want to print on the output change, not state
pirState = LOW;
}
}
boltiot.CheckPoll(counter);
}
My cloud app should be very simple as well:
/ *start typing your code here */
setChartLibrary('google-chart');
setChartTitle('Your Graph Title');
setChartType('lineGraph');
setAxisName('X-Axis Name','Y-axis Name');
plotChart('time_stamp','posOne');
The hardware config for the cloud app is for one variable to be read into posOne every 5 min.
Here’s what the serial monitor is output:
Motion detected! Times detected: 130
Motion ended!
Motion detected! Times detected: 131
Motion ended!
132.00,0.00,0.00,0.00,0.00,0.00
132.00,0.00,0.00,0.00,0.00,0.00
132.00,0.00,0.00,0.00,0.00,0.00
The issue is I’m not getting any data. Should I change the 1 value to 6 as it appears to be sending it that when the bolt code fires?
With the bolt on the boltduino it looks as if the tx pin matches up to the tx pin on the board (as it is labeled at the top where I have the bolt plugged in. Is this a misprint or am I actually hooking the bolt up incorrectly?