• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created over 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A socket.io client for the Arduino Ethernet shield

SocketIO Arduino Client, an Arduino client for connecting and messaging with Socket.io servers

Based on Kevin Rohling's arduino websocket client modified to work with socket.io servers. Along the way, all uses of the String class were replaced with fixed char buffers so as to use less memory.

The bitlashsocketio.ino example provides an integration with Bitlash on the Arduino and a node.js example server that can be used to send Bitlash commands over the Websocket fabric to the Arduino, and see its output in reply.

Example setup

You'll need node.js and npm installed first.

cd examples/bitlashsocketio
npm install             // only need this once, the first time
node index.js           // start web server.  optionally add --port=8080 to change port

========================================================

======================================================== Kevin's documentation is reproduced hereinafter, with changes as needed.

Caveats

This library doesn't support every inch of the Websocket spec, most notably the use of a Sec-Websocket-Key. Also, because Arduino doesn't support SSL, this library also doesn't support the use of Websockets over https. If you're interested in learning more about the Websocket spec I recommend checking out the Wikipedia Page. Now that I've got that out of the way, I've been able to successfully use this to connect to several hosted Websocket services, including: echo.websocket.org and pusherapp.com.

Installation instructions

Clone this repo into your Arduino Sketchbook directory under libraries, then restart the Arduino IDE so that it notices the new library. Now, under File\Examples you should see SocketIOClient.

How To Use This Library

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "echo.websocket.org";
WebSocketClient client;

void setup() {
  Serial.begin(9600);
  Ethernet.begin(mac);
  client.connect(server);
  client.setDataArrivedDelegate(dataArrived);
  client.send("Hello World!");
}

void loop() {
  client.monitor();
}

void dataArrived(WebSocketClient client, char *data) {
  Serial.println("Data Arrived: " + data);
}

Examples

There example included with this library, EchoExample, will connect to echo.websocket.org, which hosts a service that simply echos any messages that you send it via Websocket. This example sends the message "Hello World!". If the example runs correctly, the Arduino will receive this same message back over the Websocket and print it via Serial.println.

More Repositories

1

bitlash

Bitlash: a programmable command shell for arduino
C
345
star
2

bitlash-commander

Web-based dashboard builder for Arduino.
JavaScript
37
star
3

serial-web-terminal

Web terminal for USB Serial devices like Bitlash-enabled Arduino, based on node.js/tty.js
JavaScript
24
star
4

beadsynth

An audio sound effects synthesizer for Arduino, based on Mozzi
Arduino
13
star
5

serial-network-proxy

Exposes a usb serial port as a TCP network service, for Bitlash on Arduino
Python
9
star
6

arduino-livechart

Generates a D3 chart of data logged from a USB-connected Arduino
JavaScript
9
star
7

bitlash-1-atmega168

Bitlash: a command shell for Arduino
C
5
star
8

arduino-redis-datalogger

Node.js/D3 app to graph data logged to Redis by the BitlashRedisClient
JavaScript
5
star
9

arduino-whistle-to-midi

Drive your synth by whistling: Audio in, MIDI-like serial out, for Arduino
Arduino
2
star
10

cw

Morse world
JavaScript
2
star
11

run

Arduino function scheduler library: runs your C function at a specified interval, like the Bitlash run command
C++
2
star
12

Bitlash-2.0-RC3

BitlashSD Beta: run script from SD card
C
1
star
13

wikidrop

wiki / dropbox for ESP32 / MicroPython / MicroWebSrv
JavaScript
1
star
14

notesoup

The Note Soup sticky note web organizer and dashboard factory for node.js/redis
JavaScript
1
star
15

jchart

JavaScript
1
star
16

bloader.py

bitlash code loader and interactive tty
Python
1
star
17

hook-express

A micro-hook host and laboratory for ExpressJS
JavaScript
1
star
18

Bitlash-2.0-RC2

Bitlash 2.0 Release Candidate 2
C
1
star
19

Bitlash-2.0-RC1

Bitlash 2.0 RC1
C
1
star
20

node-red-contrib-morse

A morse-code output node for node-red
JavaScript
1
star