This repo contains Arduino and Processing code to control a visualization using:
-
an MPU-6050 motion sensor (with accel + gyro)
-
a Wemos, an Arduino compatible board with WiFi (using ESP8266)
-
the OSC protocol to communicate with a computer
-
If you don't have Arduino, download it: arduino.cc/en/main/software
-
If you use Mac or Windows, you need drivers: wiki.wemos.cc/downloads
-
If you never used ESP8266 with your Arduino IDE you need to follow this procedure:
github.com/esp8266/Arduino#installing-with-boards-manager (but you can stop before the "Using git version", unless you want to contribute to their work).
- If you never used the MPU-6050 or OSC in Arduino, use the following keywords in the Library Manager:
-
MPU6050_tockn
-
OSC (Open Sound Control) by Adrian Freed and Yotam Mann
It will allow you to install these libraries, here is the procedure:
arduino.cc/en/Guide/Libraries#toc3
-
If you don't have it, download Processing: processing.org/download
-
As in the Arduino section, go to
Sketch -> Import Library... -> Add Library...to install the following libraries:
-
oscP5 by Andreas Schlegel
-
controlP5 by Andreas Schlegel
-
Close the Arduino IDE, unplug and replug your Wemos board, then re-open the Arduino IDE (it can help for many problems)
-
Select the port at the bottom of the list of
Tools -> Port(or the latest that appeared at least), it looks like:
-
OS X: /dev/cu...
-
Linux: /dev/tty...
-
Win: COM...
-
Select your board:
Tools -> Board -> LOLIN (WEMOS) D1 R2 & mini -
In the Arduino IDE, open the ESP8266 blink example from
File -> Examples -> ESP8266 -> Blink -
Upload the code (command-U / ctrl-U)
-
Change the delay times (ex: remove a zero), the blue LED should blink at a different speed.
-
Upload the Arduino file in the
1_tests/a_sensorfolder -
Open
Tools -> Serial Monitor, you should observe values -
Open
Tools -> Serial Plotteryou should observe a graph of these values (shake the accelerometer!) -
Challenge: modify the Serial.print(...) section to trace these values in ASCII (hint: amplify the measured value in a "for loop")
- Create an access point in your phone:
-
Get your computer's local IP with ifconfig (Mac/Linux) or ipconfig (Windows)
-
Open the Arduin file in the
1_tests/b_communication/arduino/folder, put your WiFi login/password, your IP address (look forIPAddress outIp(192.168...)), and upload... -
Open the Processing sketch in
1_tests/b_communicationand run it (command-R / ctrl-R) -
If both your computer and the Wemos are connected to the same network, some values should appear in the console part of Processing (black background), they actually came by WiFi!
-
Optional challenge: send a String message from the Wemos over OSC and print it in the console (see documentation section below)
Now that we can sense and communicate, let's use the data!
-
As earlier, open the Arduino file in the
2_playfolder, put your WiFi login/password, your IP address, and upload... -
Open the Processing sketch in the
2_playfolder and run it, now you know... -
Challenge: make it your own, change the color, the speed, or the entire visualization!
Credit: the visualization is derived from the work by Andreas Schlegel, more info here:
github.com/sojamo/Movement-of-Things
- With Processing:
github.com/processing/processing-sound/blob/master/examples/Oscillators/SawWave/
github.com/processing/processing-sound/blob/master/examples/Demos/SineCluster/
github.com/processing/processing-sound/blob/master/examples/Effects/Filter/BPF
- With Sonic Pi: sonic-pi.net/tutorial.html#section-12-1
Try them all but this board can even host a webserver for instance:
File -> Examples -> ESP8266WebServer
arduino-esp8266.readthedocs.io/en/latest
wiki.wemos.cc/products:d1:d1_mini
sojamo.de/libraries/oscP5/reference/oscP5/OscMessage.html
If the board doesn't appear in Arduino for OSX, the follwoing links should help:
mblock.cc/docs/run-makeblock-ch340-ch341-on-mac-os-sierra
github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver#ch340g-ch34g-ch34x-mac-os-x-driver
https://sparks.gogo.co.nz/ch340.html
If you get espcomm_open failed, try again, restart Arduino, check the connection and the cable, use another USB plug...
...and if it persists, use a slower upload speed in Tools -> Upload Speed
cannot access [serial port]
This might help:
sudo usermod -a -G dialout $USER # needs logout (it might be plugdev too)
Or make a udev file:
RULES='SUBSYSTEMS=="usb", ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86", MODE:="0666", GROUP="plugdev"'
echo $RULES | sudo tee /etc/udev/rules.d/30-HL-340.rules
sudo restart udev

