Arduino: Is it possible to communicate with Arduino through Ethernet, using a Processing (PDE) script?
I've already created a desktop application using Processing, but in this case I communicate with Arduino through the USB.
Yes you can
You could for example create an arduino chat server : http://arduino.cc/en/Tutorial/ChatServer
And create a processing client like this : http://processing.org/reference/libraries/net/Client_write_.html
ofcourse you would need to change the
myClient = new Client(this, "127.0.0.1", 10002);
to
myClient = new Client(this, "IP of Arduino", 23);
If you would then connect with a telnet session to the arduin o you would see output from the prosessing script comming back from the arduino
Related
I am trying to pragmatically control scanning operation of Gryphon I GPS4400 barcode scanner.
Scanner is attached to host over usb cable and scanner is programmed to act as virtual serial port.
I have control over serial port on host and I am receiving data from scanner regularly, also I am able to send some data to scanner over serial port. Scanner from my random text sent sometime response to serial port some time just beep.
I am trying to activate scanning mode:
Serial On Line: Scanning is initiated by command sent through the
host interface (manual triggering can be enabled in this read mode
through option setting).
(I know how to activate this mode on scanner, by reading configuration barcodes, but after that I do not know how to send command to trigger scanning)
My problem is that i can't find what sequence I need to send to scanner to start scanning?
Is it possible at all to control scanning by commands over virtual com port attached by USB or I need to have dedicated serial cable with special wiring ?
I looking for clarification on how the WiFiClient and WiFiServer objects in this example ESP8266 sketch starts a TCP connection and allows an Android app to read and write to buffers that's setup in the sketch.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
WiFiServer server(port);
WiFiClient client;
uint8_t buf1[1024];
server.begin(); // start TCP server
client = server.available(); // wait for it to connect
buf1[i1] = (uint8_t)client.read(); // read char from client (RoboRemo app)
client.write((char*)buf2, i2);
This sketch talks to a closed-source Android app call Roboremo. It uses WiFiServer to create a TCP server, and WiFiClient to read/write to buffers. What is this TCP server, and what mechanism is being used to read/write to the ESP8266? So, if I were having a conversation with an app developer, how do I tell them how to write to this TCP server (other than IP and port number)? Is this a "TCP socket", and does that translate into something that mobile app people would know how to proceed?
Another way to ask this question: I'd like to be able to test read/write to the ESP8266 without the Android app. So if I have a Raspberry Pi on the same network as this ESP8266, what utility (mechanism again) can I use to read/write to those buffers from the Pi?
Checking the Roboremo sketch shows that you will be working with esp8266 on STA mode by providing your ssid and pass into the sketch. That means you need to find the ip address of esp8266 before making a connection. A ridiculous comment from sketch is :
Then somehow find the IP that the ESP got from router
So, if you will continue with STA mode, you may go to your router settings and find the ESP8266 from DHCP clients.
For a raspberry TCP client connection, you need nothing else from a Linux socket client. Here a basic python client to test on raspberry :
import socket
import sys
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error, msg:
print 'Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1]
sys.exit();
print 'Socket Created'
host = 'YOUR_ESP8266_IP '
port = 9876
s.connect((remote_ip , port))
print 'Socket Connected to ' + host
#Send some data to remote server
message = "test esp8266 server"
try :
s.sendall(message)
except socket.error:
print 'Send failed'
sys.exit()
print 'Message send successfully'
Is it possible to get sensor output from Arduino via Ethernet connection and to send data to Arduino via Ethernet?
So basically can "replace" serial port with Ethernet port?
The typical way to do this is with an Arduino Ethernet shield, a small hardware module that plugs into your Arduino board:
http://arduino.cc/en/Main/ArduinoEthernetShield
Updated:
One very common approach for client to server communication would be to use HTTP over TCP/IP. See this example on the Ardunio site of a simple client on an Ardunio connecting with a server (in this case google):
http://arduino.cc/en/Tutorial/WebClient
For your use case you can simply create your own server and modify the example to send data to it.
Alternatively you can skip the HTTP part and just use sockets - there is an open source example here:
https://github.com/billroy/socket.io-arduino-client
I have a Temp sensor connected to my arduino uno sending its data to the serial monitor e.g
16c
How can I send the data from the serial monitor to a local webserver so that i could access the temp from a internet browser?
In the setup I use with my arduino I am using NodeJS SerialPort module to listen to signals of my arduino with a motion sensor. To serve the signal data to the web in real time, I use the socket.io module for NodeJS. You can find quite a lot about this on the internet, for example this tutorial which is somewhat close to what I use.
http://www.codeproject.com/Articles/389676/Arduino-and-the-Web-using-NodeJS-and-SerialPort
I've been using Twisted for a while to connect a computer with some devices over the net. I wrote a custom Protocol and Factory.
factory = TModBusFactory()
reactor.listenTCP(9007, factory)
Now I'd like to connect the devices to the serial port of the server machine. As long as I know, no change in the protocol is needed but I need to switch from sending bytes over TCP to send them over the serial port.
How hard to do is this change? How can I change the code snippet in order to make it work?
Thanks!
Serial port setup looks like this:
from twisted.internet.serialport import SerialPort
from twisted.internet import reactor
factory = TModBusFactory()
protocol = factory.buildProtocol(None)
deviceName = "ttyS0"
port = SerialPort(protocol, deviceName, reactor)