Hello. I am trying to create a prototype for a non-profit that will use a 4 axis tilt sensor (at the moment) to text a smart/mobile phone when it is moved. Currently the tilt sensor is able to create a read out on a display when it is moved. However, I’d like the signal to go through the particle to a smart/mobile phone instead of directly to the lcd display (from Sparkfun). Can anyone out there help with that? Thanks in advance.
Post your current Particle code so we can take a look at what is going on.
Also which tilt sensor are you using?
Code is currently for Arduino:
char gl_senstr1[15];
char gl_senstr2[15];
void setup() {
mySerial.begin(9600); // set up serial for 9600 baud delay (500); // wait for display to boot up
}
void loop() {
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
mySerial.write(" "); // clear display
mySerial.write(" ");
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
sprintf(gl_senstr1, "%d", digitalRead (6));
sprintf(gl_senstr2, "%d", digitalRead(7));
mySerial.write(" movement: ");
mySerial.write(gl_senstr1);
mySerial.write(" movement: ");
mySerial.write(gl_senstr2);
delay(250); // Wait 1/4 second
}
Tilt sensor is from parallax inc. found here: https://www.parallax.com/product/28036
So you just want to have an event reported to the cloud whenever a movement happens?
If so, just do this
const int pinSenseX = D6; // choose your sensor pins
const int pinSenseY = D7;
int senseX;
int senseY;
void setup() {
mySerial.begin(9600); // set up serial for 9600 baud delay (500); // wait for display to boot up
pinMode(pinSenseX, INPUT); // always better to be explicit than just rely on defaults
pinMode(pinSenseY, INPUT);
}
void loop() {
char gl_senstr1[15];
char gl_senstr2[15];
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
mySerial.write(" "); // clear display
mySerial.write(" ");
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);
senseX = digitalRead(pinSenseX);
senseY = digitalRead(pinSenseY);
sprintf(gl_senstr1, "%d", senseX);
sprintf(gl_senstr2, "%d", senseY);
mySerial.write(" movement: ");
mySerial.write(gl_senstr1);
mySerial.write(" movement: ");
mySerial.write(gl_senstr2);
Particle.publish("yourMove", String::format("dX = %d, dY = %d", senseX, senseY), PRIVATE);
delay(1000); // Wait 1 second (rate limit for Particle.publish())
}
1 Like
Been having some trouble claiming the device and have to wait till Friday before I can get this going. Thanks for sharing your knowledge. I look forward to seeing if this will work.