A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By Gabi Mihai
#21392 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.
User avatar
By juanpintom
#21510 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
User avatar
By Gabi Mihai
#21614 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!