Page 1 of 1

Arduino experiments

PostPosted: Fri Dec 31, 2010 6:06 pm
by alverman
Good evening,
I would like to experiment with the sensor / encoder connected to an Arduino board which then interfaces to the WD.
I would use the WD node Serial and TCP.
Could you tell me the protocol for the transmission of data to different nodes?

Thanks, Alberto

Re: Arduino experiments

PostPosted: Tue Jan 18, 2011 4:38 pm
by mkohler
Hello,
Try these libraries and then use the following code.

https://bitbucket.org/bjoern/arduino_os ... /Ethernet/

Best,
Michael

Re: Arduino experiments

PostPosted: Tue Jan 18, 2011 4:42 pm
by alverman
Great :)

tnx

Re: Arduino experiments

PostPosted: Thu Feb 03, 2011 3:59 pm
by dantronic
I have been connecting Arduino and WDPro quite a bit. It is possible to send multiple streams of data over serial without a lot of code on the Arduino side, and no OSC needed. The analog input pins translate to 10-bit values {0-1023} and then you just need to package the values from Arduino-->PB like this:

void setup() {
Serial.begin(115200);
int data1 = 0;
int data2 = 0;
int data3 = 0;
}
void loop() {
// read the pins
Analog.Read(1,data1);
Analog.Read(2,data2);
Analog.Read(3,data3);
// and write to serial
Serial.println("a",data1,"/",data2,"/",data3,"b");
}

What you have done is set a "start" character, "split" characters, and "end" character that the COM connection in WD looks for.
So on the WD side...
Start a COM connection in the Connection Manager, with the proper port and speed,
Make a COM node with the same start/split/end characters (I use "a" "/" "b")
Once you activate this node you should see the three values streaming live to the properties window.

Some tips
-use the maximum connection speed allowed for the Arduino board. You can find this in the Arduino Serial Monitor.
-in WDPro the Range node is your friend! Quickest way to convert {0-1023} to {0-65535} etc
-a potentiometer connected to an Arduino input can tend to "flicker" at the top end of the voltage range. Solution = in WDP set Range input max to 1021 instead of 1023, and it will stay steady at the top.

Re: Arduino experiments

PostPosted: Thu Feb 03, 2011 4:28 pm
by alverman
My arduino Sketch

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x08, 0xE6 }; // Eth shield Mac
byte ip[] = { 192,168,1,10 }; // Arduino
byte server[] = { 192,168,1,195 }; // Widget
int Dx = 0;
int Sx = 0;

// Initialize the Ethernet client library
// with the IP address and port of the server
Client client(server, 8084);

void setup() {
// start the Ethernet connection:
Ethernet.begin(mac, ip);
// start the serial library:
Serial.begin(115200);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");

// if you get a connection, report back via serial:
if (client.connect()) {
Serial.println("connected");
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}

void loop()
{
Dx = analogRead(0);
Sx = analogRead(1);
client.print ("*");
client.print(Dx);
client.print ("@");
client.print(Sx);
client.print ("#");

if (!client.connected())
{
Serial.println("disconnecting.");
client.stop();
}
}

Re: Arduino experiments

PostPosted: Thu Sep 29, 2011 1:34 pm
by rubendesnoo
Hi Alverman,

We did successfully connect an arduino uno over usb with widged designer, with a compass sensor.But because we would like to have a wireless solution we bought an ethernet shield. We first programmed some sripts and did get tcp data in the browser of the widgets computer, but not in widget designer.

After that we loaded your script on the board but we still couldn't get it working with widget designer.

Could you tell us how you set this up?
- which connection (tcp/udp/client only/multiclient/broadcast etc.)
- which input node?
- which ip-adresses?
- which port?

We would be very grateful if you could help us,

regards

Re: Arduino experiments

PostPosted: Fri Sep 30, 2011 10:46 am
by alverman
I send you my little project.
The port is 8084 but you can modify from a arduino schetch
The ip address for arduino is 192.168.1.10 but you can modify
The ip for widget is 192.168.1.195 but you can modify
The widget connection is tcp

I have used an ethernet shield only because I dont have wifi shield but the configuration is the same of eth shields

Try, modify for your scope and say me if you need more information.

enjoy

Alverman

Re: Arduino experiments

PostPosted: Tue Mar 24, 2015 11:19 pm
by trafalmejo
Hi dan and everyone,

I tried your solution and it worked, but just once :( !. i didnĀ“t use any split ASCII, just set up de connection ID. and it sent useful data to me. but it is not working anymore. This is my code:

long distancia;
long tiempo;
void setup(){
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(8, INPUT);
}

void loop(){
digitalWrite(9,LOW);
delayMicroseconds(5);
digitalWrite(9, HIGH);
delayMicroseconds(10);
tiempo=pulseIn(8, HIGH);
distancia= int(0.017*tiempo);

Serial.println(distancia);
}


It is about a ultrasonic sensor to measure distances. I just need one data.....the current distance.

Can u help me?
Thanks for all.

Re: Arduino experiments

PostPosted: Mon Mar 30, 2015 10:10 pm
by sune
which Arduino module are you uses to do the network connection ?