{"id":8242,"date":"2022-02-11T11:20:08","date_gmt":"2022-02-11T11:20:08","guid":{"rendered":"https:\/\/www.fambach.net\/?p=8242"},"modified":"2023-06-12T20:11:20","modified_gmt":"2023-06-12T20:11:20","slug":"esp32-c3-das-spiel-mit-der-mouse","status":"publish","type":"post","link":"https:\/\/www.fambach.net\/en\/esp32-c3-das-spiel-mit-der-mouse\/","title":{"rendered":"ESP32-S2 playing with the mouse"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Verwendet_Versionen\" title=\"Verwendet Versionen\">Verwendet Versionen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Fakten\" title=\"Facts\">Facts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Anwendungsbereiche\" title=\"Areas of application\">Areas of application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Ansichten\" title=\"Views\">Views<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Analyse\" title=\"Analyse\">Analyse<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Board_Annotation\" title=\"Board Annotation\">Board Annotation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Genauer_betrachtet\" title=\"Genauer betrachtet\">Genauer betrachtet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Mal_Angeschlossen\" title=\"Mal Angeschlossen\">Mal Angeschlossen<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Programmierung\" title=\"Programming\">Programming<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Bibliotheken\" title=\"Libraries\">Libraries<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Testprojekt_erstellen\" title=\"Testprojekt erstellen\">Testprojekt erstellen<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Mit_IDF_und_Konsole\" title=\"Mit IDF und Konsole\">Mit IDF und Konsole<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Vorbereitung\" title=\"Preparation\">Preparation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Zieplattform_festlegen\" title=\"Zieplattform festlegen\">Zieplattform festlegen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Konfigurieren\" title=\"Konfigurieren\">Konfigurieren<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Bauen\" title=\"Bauen\">Bauen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Flashen\" title=\"Flashen\">Flashen<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Monitoren\" title=\"Monitoren\">Monitoren<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Mit_VS-Code\" title=\"Mit VS-Code\">Mit VS-Code<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Probleme\" title=\"Problems\">Problems<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Fazit\" title=\"Conclusion\">Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Verwandte_Beitrage\" title=\"Related Posts\">Related Posts<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/#Quellen\" title=\"Sources\">Sources<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>A friend was complaining to me the other day. He's now working from home and fears his employer is tracking his computer data. Since the computer switches to standby mode after a few minutes, he came up with the idea of repeatedly moving the mouse to prevent this. His wireless mouse even reaches the toilet, he told me, and he expressed his gratitude to manufacturers of such mice. <\/p>\n\n\n\n<p>Now the acquaintance is not only a good one, but also a civil servant, and as is well known, they need their midday nap. Tying the mouse to the cat (does anyone see the irony) or letting it run along on a record player isn't quite perfect. <\/p>\n\n\n\n<p>As I was putting the children to bed in the evening, my thoughts wandered in this direction. It occurred to me <a href=\"https:\/\/www.fambach.net\/en\/esp32-s2\/\" data-type=\"post\" data-id=\"6288\">ESP32-S2<\/a> to memory, which has the capability to emulate a HID (Human Interface Device), i.e. a mouse or keyboard. <\/p>\n\n\n\n<p>Thus, a new project was born \u2013 to emulate a mouse that would then intervene when you were inactive. Of course, software emulation on the computer would also be conceivable, but most company computers are secured against the installation of external software. <\/p>\n\n\n\n<p>Facts<\/p>\n\n\n\n<ul>\n<li>Simply plug the FAKE mouse into the USB port.<\/li>\n\n\n\n<li><s>Mouse activates after 3 minutes of inactivity.<\/s> It wasn't possible, no feedback from the computer<\/li>\n\n\n\n<li><s>The mouse stops as soon as the user does something again.<\/s> Same reason as above<\/li>\n\n\n\n<li>The mouse movements should be random in pace and time intervals.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Selected Hardware<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/\" target=\"_blank\" rel=\"noreferrer noopener\">LILYGO EP32 S2 V1.1<\/a><\/p>\n\n\n\n<p>Alternatives<\/p>\n\n\n\n<p>LILYGO<a href=\"http:\/\/lilygo-t8-esp32-s2-display-v1-1\" data-type=\"URL\" data-id=\"lilygo-t8-esp32-s2-display-v1-1\"> T8 ESP32-S2 Display V1.1<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Anwendungsbereiche\"><\/span>Areas of application<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul>\n<li>Funny mouse movements on the screen<\/li>\n\n\n\n<li>Liberation from the yoke of employers.<\/li>\n\n\n\n<li>The lives of civil servants (An apology to civil servants who have to work hard for their money)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Ansichten\"><\/span>Views<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Photos are available at <a rel=\"noreferrer noopener\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/\" target=\"_blank\">LILYGO EP32 S2 V1.1<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Programmierung\"><\/span>Programming<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Bibliotheken\"><\/span>Libraries<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The two required libraries, USB.h and USBHIDMouse.h, are included in the ESP32 library from version 2.0 onwards.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test programme<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"348\" src=\"https:\/\/www.fambach.net\/wp-content\/uploads\/2022-02-07-22_15_42.jpg\" alt=\"\" class=\"wp-image-8245\"\/><figcaption class=\"wp-element-caption\">ESP32-S2 \u2013 Choose a controller<\/figcaption><\/figure>\n\n\n\n<p>Demos are available in the example projects below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"676\" height=\"919\" src=\"https:\/\/www.fambach.net\/wp-content\/uploads\/2022-02-07-22_18_12.jpg\" alt=\"\" class=\"wp-image-8246\"\/><figcaption class=\"wp-element-caption\">ESP32-S2 \u2013 Beispielprogramme<\/figcaption><\/figure>\n\n\n\n<p>I used the MouseButtonControl example as a basis for my endeavours and created my own:<\/p>\n\n\n\n<script>\nvar project = \"sfambach\/ep32-s2\/tree\/main\/src\/AutoMouseToKeepTheComputerAlive\";\nvar file = \"\/AutoMouseToKeepTheComputerAlive.ino\";\nvar test = project + file;\nvar startAt = 7;\nvar endAt = 0;\n\n\ndocument.write('<div a class=\"wp-block-file\" ><a a class=\"wp-block-file__button\" href=\"https:\/\/github.com\/'+project+'\" target=\"_blank\">Link zu Git<\/a>');\ndocument.write('<a a class=\"wp-block-file__button\" href=\"https:\/\/downgit.github.io\/#\/home?url=https:\/\/github.com\/'+project+'\" target=\"_blank\">Download des Projektes mit DownGit<\/a><\/div>');\n\ndocument.write('<div style=\"font-size:1vw\">');\ndocument.write('<script src=\"https:\\\/\\\/gist-it-dot-helloid-roadmap.ew.r.appspot.com\\\/github.com\\\/'+test+'\\?slice='+startAt+':'+endAt+'\"><\\\/script>');\ndocument.write('<\/div>');\n<\/script>\n\n\n\n<p>Install the firmware and set the DIP switches to HID mode (OTG).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"337\" height=\"291\" src=\"https:\/\/www.fambach.net\/wp-content\/uploads\/2022-02-12-09_02_05.jpg\" alt=\"\" class=\"wp-image-8258\"\/><figcaption class=\"wp-element-caption\">Lilygo ESP32-S2 - Switch to OTG.<\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Probleme\"><\/span>Problems<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The mouse is not keeping the computer alive. <\/p>\n\n\n\n<p>Possibly the time between movements is too short, so the computer still goes into standby mode. <\/p>\n\n\n\n<p>Simply increase the value for the delay. Feel free to set it to 2000 as well, then you'll see the mouse jump.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Miscellaneous<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Track Own Mouse Movements<\/h3>\n\n\n\n<p>Stefan (see comments) suggests integrating the circuitry into the mouse. On the one hand, mouse movements could then be tracked, and on the other hand, with clever wiring, OTG capability would not even be necessary. <\/p>\n\n\n\n<p>Alternatively, a USB port that's passed through might be an option, an Arduino clone with a Host Shield. The original mouse connected to the Host Shield and the mouse data simply forwarded to the computer. If the mouse pauses, the Arduino clone takes over. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Fazit\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The programme was quickly written and works, I will hand it over for user testing in the coming days.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Verwandte_Beitrage\"><\/span>Related Posts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<ul class=\"display-posts-listing\">\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/esp32-c3-das-spiel-mit-der-mouse\/\">ESP32-S2 playing with the mouse<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-tasks-2\/\">Espressif IDF \u2013 GPIOs<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-tasks\/\">Espressif IDF \u2013 Tasks<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-menuconfig\/\">Espressif IDF \u2013 Menuconfig<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-timer\/\">Espressif IDF \u2013 Timer<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-log-nachrichten\/\">Espressif IDF \u2013 Log Messages<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-fehlerbehandlung\/\">Espressif IDF \u2013 Error Handling<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-konsolenausgabe\/\">Espressif IDF \u2013 Console Output<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/espressif-idf-projekt-erstellen\/\">Espressif IDF \u2013 Create Project<\/a><\/li>\n<li class=\"listing-item\"><a class=\"title\" href=\"https:\/\/www.fambach.net\/en\/lilygo-ep32-s2-v1-1\/\">LILYGO EP32 S2 V1.1<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Quellen\"><\/span>Sources<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/espressif\/arduino-esp32\">https:\/\/github.com\/espressif\/arduino-esp32<\/a> (Library for looking up USB and Mouse libraries)<\/p>\n\n\n\n<p><a href=\"https:\/\/ericdraken.com\/usb-mouse-jiggler\/\">https:\/\/ericdraken.com\/usb-mouse-jiggler\/<\/a> He has done a similar project with a different board.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/seife\/marble_fx\">https:\/\/github.com\/seife\/marble_fx<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/seife\/marble_fx_digistump\">https:\/\/github.com\/seife\/marble_fx_digistump<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Ein Bekannter hat mir neulich sein Leid geklagt. Er sei jetzt im Home-Office und bef\u00fcrchte, dass sein Arbeitgeber seine Computer Daten trackt. Da der Computer nach wenigen Minuten in den Standby-Modus schaltet kam er auf die Idee immer wieder die Mouse zu bewegen, um dies zu verhinden. Seine Funkmouse reiche sogar bis zur Toilette, sagte &#8230;<\/p>\n<a href=\"https:\/\/www.fambach.net\/en\/lilygo-esp32-oled\/\" class=\"read-more-link\">Continue reading <span class=\"screen-reader-text\">\"LilyGo ESP32-Oled\"<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a>","protected":false},"author":1,"featured_media":8254,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[175,184,472,496,256,211,255],"tags":[29,554,28,555,475,553,552,115],"modified_by":"sfambach","_links":{"self":[{"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/posts\/8242"}],"collection":[{"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/comments?post=8242"}],"version-history":[{"count":15,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/posts\/8242\/revisions"}],"predecessor-version":[{"id":9415,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/posts\/8242\/revisions\/9415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/media\/8254"}],"wp:attachment":[{"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/media?parent=8242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/categories?post=8242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fambach.net\/en\/wp-json\/wp\/v2\/tags?post=8242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}