ESP32 MicroPython Capacitive Touch & Sound Tutorial

Поделиться
HTML-код
  • Опубликовано: 28 июн 2024
  • This MicroPython tutorial demonstrates utilizing the ESP32’s built-in capacitive touch sensors. A simple music player is constructed utilizing a JQ6500 MP3 module connected to an ESP32 via serial communication. The touch interface provides feedback by using pulse width modulation to vary LED brightness.
    All the code, schematics, notes and updates are available on my website: www.rototron.info/raspberry-p...
    Previous tutorials in this series:
    Part 1: www.rototron.info/raspberry-p...
    Part 2: www.rototron.info/raspberry-p...
    Part 3: www.rototron.info/raspberry-p...
    Part 4: www.rototron.info/raspberry-p...
    Playlist for all videos: • ESP32 MicroPython Tuto...
    JQ6500 Library: github.com/rdagger/micropytho...
    DIY PCB etching notes: www.rototron.info/pcb-etching...
    T-800 Terminator Endoskull: www.thingiverse.com/thing:438789
  • НаукаНаука

Комментарии • 29

  • @robertlam88
    @robertlam88 6 лет назад +3

    Very very informative. Thank you for spending the time to make this video.

  • @philwilkinson7228
    @philwilkinson7228 6 лет назад +3

    Another fantastic video.
    First of all, thanks for developing a Micropython library for the JQ6500 and sharing it with the community. Many thanks for continuing to program in Micropython, for beginners like me it allows us to really understand the code, adjust and apply it so much easier than Arduino/C.
    This video is the by far the best description of touch capacitance on microcontrollers from a practical implementation point of view. It is really well explained and likely problems in setup are covered.
    I know a lot of people watching will find it difficult to imagine attempting this project (making your own pcb etc), but the video is well broken down so various elements of your project could be attempted in isolation; press a lemon to start a mp3 track, press an orange to stop, etc, etc!
    Up to now, I have kept well clear of the touch sensors on the ESP32 and have never tried any projects with sound. Given this impressive project I feel I have to give it a try! Thanks

    • @rdagger
      @rdagger  6 лет назад

      Thanks for the helpful feedback. Making PCB's yourself is very easy and inexpensive. All you need is a laser printer, some glossy paper, an iron and common chemicals found at the market and hardware store. I posted detailed etching instructions on my website.

  • @MartinBgelund
    @MartinBgelund 6 лет назад +2

    Awesome! Thanks for this tutorial!

  • @jackyli6716
    @jackyli6716 3 года назад +1

    wow!!! Thanks for the video, it really helps me out..

  • @raulrdz9534
    @raulrdz9534 6 лет назад

    Hasta la vista baby 😎

  • @5Leeprunner
    @5Leeprunner 6 лет назад

    you make a fantastic videos .... i want to make tutorial how to control IGBT 220v brushmotor A little more about soft and hard electric... thank you you are good man greetings

  • @MrHbpatel
    @MrHbpatel 6 лет назад +2

    Could please create ESP32 capacity touch home automation display and control panel using MQTT?

  • @0el0baku0
    @0el0baku0 6 лет назад

    do you think this would work with glass instead of acrylic?

    • @0el0baku0
      @0el0baku0 6 лет назад

      oh i watched the video again, it'll work with glass xD

  • @beckiclews887
    @beckiclews887 4 года назад

    Is there any way you can run the code to play the sound for both the orange and the mango over the top of each other if both objects are pressed at the same time?

    • @rdagger
      @rdagger  4 года назад +1

      Unfortunately the JQ6500 is designed to be more like an MP3 player.

    • @beckiclews887
      @beckiclews887 4 года назад

      Thank you, I’ve managed to find some code online now that solved the problem ☺️

    • @Alternativito
      @Alternativito 4 года назад

      @@beckiclews887 Hi, where did you find, could you share?

  • @karansomani8461
    @karansomani8461 4 года назад

    hey!! it was an amazing tutorial. As a beginner i have learned a lot from your tutorials.
    Right now i am trying to read and write a co2 sensor(mh-z19b) datas via esp32 using uart, but it always reads the data bytes as none and i am not able to understand it. Below is the code and can you tell me whats wrong in it?
    Your help will be appreciated.
    Thank you.
    from machine import UART
    uart = UART(2, 9600)
    uart.init(9600, bits=8, parity=None, stop=1)
    uart.read(9)
    data = [0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79] # request data bytes to get co2 concentration
    while True:
    w = uart.write(bytes(data))
    print(w) # output --> 9
    s = uart.read(9)
    print(s) # output --> None
    ppm = s[2] * 256 + s[3]
    print(ppm) # output --> 'NoneTypeObject'

    • @rdagger
      @rdagger  4 года назад +1

      I've never used that sensor. I would try adding a sleep(0.1) between the write and the read. Also search github for existing micropython libraries for your sensor or python libraries that you could port to micropython.

    • @karansomani8461
      @karansomani8461 4 года назад

      @@rdagger Hey!!
      sleep(0.1) between write and read worked out. Now i am getting the co2 readings.
      Once again thank you for your help:)

  • @legoscratch
    @legoscratch 6 лет назад

    Is an mp3 module necessary? I thought an esp32 could play sound by itself

    • @rdagger
      @rdagger  6 лет назад +1

      Yes the ESP32 does have this functionality, but as far as I know it has not yet been ported to MicroPython. Loboris is working on an audio module that will support MP3 and possibly Bluetooth speakers. He posted that it would probably not be ready until April/May.
      github.com/loboris/MicroPython_ESP32_psRAM_LoBo

    • @legoscratch
      @legoscratch 6 лет назад

      rdagger68 Ok, thanks for the info

    • @rdagger
      @rdagger  6 лет назад +1

      btw: theJQ6500 is amplified and can be purchased for under $2 on AliExpress.

  • @Calucig
    @Calucig 6 лет назад

    Hi!
    One question, why micropython instead of C?

    • @rdagger
      @rdagger  6 лет назад

      Like Python, MicroPython is a very easy to use programming language relative to C. Python has an intuitive and readable syntax which generally requires less code and decreases development time and maintenance. It has a very robust standard library. It supports duck typing, iterators, generators and comprehensions. You don’t have to worry about compiling your code, memory management or high-level data types. There are downsides such as performance, debugging and low level access. However, Python is an excellent language for gluing so it works well in conjunction with C.

    • @Calucig
      @Calucig 6 лет назад

      Thank you for your reply. Im a very noob programmer with powershell, html, css and minimum C in Arduino. Which one of the two, Micropython or C, should I start learning first?
      My main objective is to use ESP32 gathering sensor data, activating relays or pumps, and gather that data to send it to a web.
      I've seen so many threads and webs saying micropython is bugged and in a bad state for ESP32, and that one shouldn't waste time learning that and instead learn C or C++.

    • @rdagger
      @rdagger  6 лет назад

      Generally speaking Python would be a better starting point than C. For a Raspberry Pi, Python would be a great solution because the technology is very mature and has a large ecosystem. For a microcontroller the decisions is not as clear cut. The ESP32 is relatively new on all platforms. The Arduino IDE is very popular and has a lot of support. It's also a simplified version of C/C++. Nonetheless, I really like the LoBo build of MicroPython. It is being very actively developed and has fantastic support. I think either would be a good choice for your objectives.

    • @Calucig
      @Calucig 6 лет назад

      Hi again. Sorry to keep bothering you. Im evaluating what would be better to migrate my current arduino project, and I wanted to ask you if micropython has the capacity to do the following:
      millis()
      lm35 or
      LCD i2c library
      loop (stupid question since all languages have loop, but I'm asking if something like void loop() can be done as a standard for all codes
      analogReference(INTERNAL)
      Thank you a lot! And sorry again for so many questions in youtube.. not the ideal situation. If you have a reddit I can contact you there.

    • @rdagger
      @rdagger  6 лет назад +1

      There is a RTC module for keeping time. The utime library has ticks_ms(), ticks_us() and ticks_dif() to track time differences. There is also a timer module that lets you fire interrupt events at specific intervals.
      The ESP32 has analog pins so you can read analog sensors. However, the LM35 is 5V and the ESP32 GPIO pins are 3.3V so you would need to use a level shifter or a different sensor. There is a built-in one wire library for the DS18b20 temperature sensor. I’ve been running a DS18b20 on a Pi for about 5 years in my server room and it has performed flawlessly. There is also a built-in library for the DHT22 temperature/humidity sensor which I’ve been using for outdoor readings on my home automation system. Both of these sensors are digital which are much easier to get accurate measurements than analog.
      I wrote a MicroPython LCD library but not for I²C (it wouldn’t be very difficult to modify). However, there is an existing MicroPython I²C LCD library on GitHub but I haven’t tried it: github.com/dhylands/python_lcd You might also want to take a look at TFT or OLED displays. LoBo has a very efficient and powerful TFT library. I prefer OLED displays because of the low power consumption, high contrast, viewing angle, temperature range and hardware acceleration. I wrote a MicroPython library for the SSD1351 OLED display: github.com/rdagger/micropython-ssd1351
      In MicroPython you can have a main infinite while loop -> while True:
      The LoBo build allows you to set the analog Vref.