Everything is Talkative: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
|||
Zeile 21: | Zeile 21: | ||
8 run the Processing sketch | 8 run the Processing sketch | ||
== PROCESSING <-- OSC --> PROCESSING == | == PROCESSING <-- OSC --> PROCESSING == |
Version vom 12. April 2021, 23:18 Uhr
We like to embed electronics in everything these days, and while we’re at it why not include wifi so that everything can communicate with everything via The Internet.
E X A M P L E S
ARDUINO Uno / Flora <-- Serial --> PROCESSING
1 download and install newest version of Processing (https://processing.org)
2 download and install newest version of Arduino (https://www.arduino.cc)
3 ARDUINO --> open --> EXAMPLES --> COMMUNICATION --> GRAPH
4 upload Arduino Code to Arduino
5 connect sensor to Arduino and open the Arduino Serial Monitor to see the values coming in
6 scroll down in the Arduino code and copy Processing code to a new Processing sketch
7 edit port name "myPort = new Serial(this, Serial.list()[0], 9600);"
8 run the Processing sketch
PROCESSING <-- OSC --> PROCESSING
INSTALL : PROCESSING OSC LIBRARY
1) in the Processing top menu go to: “Sketch” –> “Import Library” –> “Import Library”
2) type “OSC” in the search box
3) select the OSC library
4) click on “Install”
DONE!
PROCESSING <-- MQTT(shiftr.io) --> PROCESSING
INSTALL : PROCESSING MQTT LIBRARY
1) in the Processing top menu go to: “Sketch” –> “Import Library” –> “Import Library”
2) type “MQTT” in the search box
3) select the MQTT library by Joel Gaehwiler
4) click on “Install”
DONE!
see also: https://www.shiftr.io/try?lang=processing
ARDUINO <-- Serial --> PROCESSING <--- MQTT ---> PROCESSING <-- Serial --> ARDUINO
www.youtube.com/embed/8nRm6WNk57I
ARDUINO ESP32 <-- MQTT(shiftr.io) --> PROCESSING
INSTALL: ARDUINO ESP32 HARDWARE
1 Menu: Preferences —> Additional Boards Manager URLs:
https://dl.espressif.com/dl/package_esp32_index.json
2 Menu: Tools —> Boards —> Boards Manager:
search for: “ESP32”
Install: “esp32 by Espressif Systems”
3 Menu: Tools —> Board: ESP32 Dev Module
Menu: Tools —> Port: dev/cu…
(unplug and plug to see which port appears)
Menu: Tools —> Flash Mode: QIO
Menu: Tools —> Flash Size: 4MB
Menu: Tools —> Flash Frequency: 80Mhz
Menu: Tools —> Upload Speed: 115200
INSTALL : ARDUINO MQTT LIBRARY
1 Menu: Sketch —> Include Library —> Manage Libraries
2 search for: “MQTT”
3 Install: MQTT library for Arduino by Joel Gaehwiler
see also: https://www.shiftr.io/try?lang=arduino
TEST: ESP ARDUINO CONNECTION
Menu: File —> Examples —> Basics —> “Blink”
edit: LED_PIN = 2;
—> blue LED should blink on/off
TEST: ESP SENSOR CONNECTION
READ ANALOG SENSOR
Menu: File —> Examples —> Communication —> “Graph”
edit: Serial.begin(115200);
edit: pick a GPIO pin with and ADC
(GPIO = General Purpose In Out)
(ADC = Analog Digital Converter)
for example: analogRead(34);
Note: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead, that should solve your problem.
SEND: SENSORDATA OVER MQTT
Menu: File —> Examples —> MQTT —> ESP32DevelopmentBoard
edit: your wifi info:
your network name / SIID
(SIID = Service Set Identifier)
your password
edit: the “ClientID” so that you can see yourself connect:
client.connect(“ClientID”, “try”, “try”)
edit: the topics you subscribe and publish to by adding “/yourName”
you can also change the “message” you are sending!
client.subscribe(“/hello/yourName”);
client.publish(“/hello/yourName”, “message”);
[diagram]