Created
December 5, 2025 11:00
-
-
Save adenine/a24e3adc472a40f57fa43512ea0368a9 to your computer and use it in GitHub Desktop.
MQTT Processing Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import mqtt.*; | |
| MQTTClient client; | |
| String incomingData; | |
| void setup() { | |
| client = new MQTTClient(this); | |
| client.connect("mqtt://10.35.30.35:1883"); | |
| frameRate(1); | |
| size(500, 400); | |
| } | |
| void draw() { | |
| background(0); | |
| } | |
| void clientConnected() { | |
| println("client connected"); | |
| client.subscribe("#"); | |
| } | |
| void messageReceived(String topic, byte[] payload) { | |
| println("new message: " + topic + " - " + new String(payload)); | |
| incomingData = new String(payload); | |
| JSONObject json = parseJSONObject(incomingData); | |
| println(json); | |
| //int msg = json.getInt("values"); | |
| //fill(255); | |
| //rect(10,200, 30, 380-msg); | |
| //println(msg); | |
| } | |
| void connectionLost() { | |
| println("connection lost"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment