User Tools

Site Tools


notes:mqtt

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:mqtt [2024/04/18 20:31] discordnotes:mqtt [2024/04/20 20:46] (current) discord
Line 1: Line 1:
-Written by Jacob Haip on April 17, 2024+====== MQTT and Microcontroller Folk Integrations ====== 
 +Jacob Haip, April 2024
  
-I am interested in integrating more physical hardware and sensors into Folk Computer to help expand the scope to the full room and to take advantage of the affordances of hardware that the projected AR system alone can't do. Things like sensing the noise level of the environment, motors that spin a fan and create wind, and the physical feel of a knob that clicks when turning off.+I am interested in integrating more physical hardware and sensors into Folk Computer to expand computing to the size of the room and to take advantage of the affordances of hardware that the projected AR system alone can't do. Things like sensing the noise level of the environment, motors that spin a fan and create wind, and the physical feel of a knob that clicks when turning off.
  
 WiFi-connected microcontrollers are the primary tool I have been using to integrate sensors and actuators with Folk. Boards I have used include the [[https://www.adafruit.com/product/5400|Adafruit Feather ESP32]], [[https://www.adafruit.com/product/5526|RPi Pico W]], and the [[https://store.particle.io/products/photon-2|Particle Photon]]. They are either programmed using Arduino or MicroPython. I have also integrated microcontrollers using BLE or a wired serial connection but I tend to like WiFi for long-lived stable devices embedded in my space. WiFi-connected microcontrollers are the primary tool I have been using to integrate sensors and actuators with Folk. Boards I have used include the [[https://www.adafruit.com/product/5400|Adafruit Feather ESP32]], [[https://www.adafruit.com/product/5526|RPi Pico W]], and the [[https://store.particle.io/products/photon-2|Particle Photon]]. They are either programmed using Arduino or MicroPython. I have also integrated microcontrollers using BLE or a wired serial connection but I tend to like WiFi for long-lived stable devices embedded in my space.
Line 74: Line 75:
 ===== Getting a button input into Folk ===== ===== Getting a button input into Folk =====
  
-TODO: GIF of button press.+{{micro-button-press.gif}}
  
 <code c rpi-pico-w-micropython-button-press.py> <code c rpi-pico-w-micropython-button-press.py>
Line 352: Line 353:
 ===== Using MQTT on web pages for bidirectional communication with Folk ===== ===== Using MQTT on web pages for bidirectional communication with Folk =====
  
-Making simple web pages using the [[https://github.com/mqttjs/MQTT.js|MQTT.js]] library also bring bidirectional communication to Folk. In the current state of the Folk code, you had to long poll for updates but using MQTT like this is nice because you don't have to poll. +Making simple web pages using the [[https://github.com/mqttjs/MQTT.js|MQTT.js]] library also bring bidirectional communication to Folk. In the current state of the Folk code, you had to long poll for updates but using MQTT like this is nice because you don't have to poll. I like these basic web apps as a way to bring phones and laptops into the Folk system as new inputs and outputs.
- +
-I like these basic web apps as a way to bring phones and laptops into the Folk system as new inputs and outputs.+
  
 First we make a web app that plays a sound when it receives an MQTT messages: First we make a web app that plays a sound when it receives an MQTT messages:
Line 414: Line 413:
 </code> </code>
  
-And then in folk you can make every phone and laptop with that web page open play a sound by flipping over page:+And then in folk you can make every phone and laptop with that web page open play a sound when button is pressed: 
 + 
 +{{button-horse.mp4}}
  
 <code tcl trigger-sound.folk> <code tcl trigger-sound.folk>
-set ts [clock milliseconds] +When MQTT claims message /message/ topic "/button1" timestamp /t/ { 
-Wish MQTT publish "make some noise" on topic "/web/playsound" at timestamp $ts+   Wish $this is labelled "BUTTON 1 PRESSED" 
 +   set ts [clock milliseconds] 
 +   Wish MQTT publish "make some noise" on topic "/web/playsound" at timestamp $ts 
 +}
 </code> </code>
notes/mqtt.1713472273.txt.gz · Last modified: 2024/04/18 20:31 by discord

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki