-->
Page 1 of 1

Recieve a pulse from vibration sensor

PostPosted: Tue Nov 24, 2015 7:10 pm
by WalfasProject8
Hello everyone. I'm searching for a LUA script that makes the ESP recieve a value from a SW-420 vibration sensor (it's digital, so there's no problem) and send the value to a sever or client. I did something similar on an Arduino UNO, and here's my Arduino code so you can have a reference:

Code: Select all#include <SoftwareSerial.h>

int ledPin = 13;   
int EP = 9;         

void setup() {
  pinMode(ledPin, OUTPUT);   
  pinMode(EP, INPUT);         
  Serial.begin(9600);         
}

void loop() {
  long medida = TP_init();   
  delay(50);                       

  if(medida > 1000)           
  {
    Serial.println(medida);
    digitalWrite(ledPin, HIGH);     
  }
  else                       
  {
    digitalWrite(ledPin, LOW);     
  }
}

long TP_init()               
{
  delay(10);                         
  long medida = pulseIn(EP, HIGH);   
  return medida;                     
}

Re: Recieve a pulse from vibration sensor

PostPosted: Wed Nov 25, 2015 4:34 am
by eduperez
Have you considered using the Arduino platform to program your ESP, instead of LUA?