Automate with the Onefinity Controller API

We’re doing it without modifying the machine or controller one bit. No custom g-codes or breakout boards needed!

We’re tapping into information from the firmware the same way the GUI on the touchscreen does. I’m not a techie by trade, so I’ll walk you through the train of thought that got me here.

When I first saw the 1F controller boot up, I noticed the GUI is just a webpage loaded in Chromium. You can’t see the address bar, but if you could, it would say “127.0.0.1” or “localhost” - both of which mean, “the IP address assigned to me” in IPv4.

The next thing I did was try to open the GUI from a computer on the same network. When I typed in the machine’s IP address like any other web page in a new tab, BAM, there it was! Homed it from the laptop and giggled like a doofus.

That let me know that somehow, machine state data was being sent to the browser. Traipsing through the Buildbotics github led me to the list of API endpoints in my first post.

When you load the GUI in a browser (whether on the touchscreen, locally, or on another device on your network), the browser starts receiving information to fill up the blank fields from:

your.machine's.ip.address/websocket

That’s where all the changing information (from “READY” to the x/y positions to the currently running file, etc.) on the GUI comes from.

In our Node-RED flow, we open that same socket, so we have access to all that information in our program.

I TeamViewered into my Old Man’s rig and hastily made a screen recording - sorry for the quality - but this video shows what the data from the websocket coming in looks like. Makes for a boring video, but it gets the point across.

The really important bit is that the data is in Node-RED - because Node-RED can talk to just about anything else. From here, it’s kind of “choose your own adventure” depending on how comfortable you are with a soldering iron.

I’ve seen people purchase a WiFi connected smart plug for their router and dust collection, and use Node-RED to trigger those. That’s a slick way to go. One of my goals is eliminating wireless communications wherever possible, though. When able, run cable.

I’m going to roll my own “smart outlets.” There’s a library called Firmata that lets Node-RED directly control the pins on an Arduino plugged into a USB port on the computer running Node-RED.

I’m going to use an Arduino Nano to control an L293d H-bridge driving the relay coils.

1 Like