-->
Page 1 of 4

ESP-01 capacitive touch sensor

PostPosted: Tue Jun 23, 2015 11:41 am
by Gabi Mihai
Hi,
I've designed a capacitive touch on ESP-01 and I hope that you enjoy it!
Here is the LUA code:
local send_pin = 4 --GPIO2
local float_pin = 3 --GPIO0
gpio.mode(send_pin,gpio.OUTPUT)
gpio.mode(float_pin,gpio.INT)
counter = 0
comanda = 0
function print_comanda()
tmr.alarm(0, 500, 0, function()
print("comanda = ", comanda)
comanda = 0
end)
end
function incr_comanda()
tmr.alarm(1, 50, 0, function()
if counter > 3 then
comanda = comanda + 1
counter = 0
tmr.stop(1)
end
end)
end
function test()
if gpio.read(float_pin) == gpio.HIGH then
counter = counter + 1
incr_comanda()
print_comanda()
end
end
pwm.setup(send_pin, 1000, 512)
pwm.start(send_pin)
gpio.trig(float_pin,"both",test)

I put a 800kohm resistor between send_pin and foiled float_pin and it works.

Re: ESP-01 capacitive touch sensor

PostPosted: Wed Jun 24, 2015 9:33 am
by juanpintom
Hi Gabi! :D :D
Im really interested on this!, I have working a long time with DIY capacitive buttons on arduino using CapSense library.

How I can use this LUA code with Arduino IDE ESP8266?? I don't know how to traslate this :S
All can be adapted well, gpio.trig is attachinterrupt on ESP IDE.
tmr its similar to wdt but not equal, this is my main problem, I don't know how to do this. EDIT: Ticker library should be the solution.

Any help will be appreciated :) I'll work on it until its done :)

EDIT2: This is the work I maded now, tmr to ticker needed (I'll try soon as possible)
http://pastebin.com/u2dk4MSf

Regards

Re: ESP-01 capacitive touch sensor

PostPosted: Thu Jun 25, 2015 9:15 am
by Gabi Mihai
Hi,
This is nodemcu lua ver5.1.4 and I uploaded this code with ESPlorer v0.2.0-rc2 and it works!
I have experience in AVR but not in C or other variant! I work mostly in basic!
So what you must do is to upload and make some fine tuning on 800kohm resistor!
My project is used to make for my own, light switches in my home.
When I touch the face of my sensor, the variable counter is incremented by the frequency of pwm.setup(....
I hope you will find this useful for yourself and use as you wish!
See you!

Re: ESP-01 capacitive touch sensor

PostPosted: Thu Jun 25, 2015 9:18 am
by Gabi Mihai
BTW the scope is to send 1,2,3 consecutive touches, in the time of tmr.alarm(0... and send them to server after tmr.alarm(1...
See you!