TCP debug port

TCP debug port © GPL3+

My project will allow you to use your current serial debug statements over an Ethernet network.

  • 49 views
  • 0 comments
  • 1 respect

Components and supplies

About this project

My project is a TCP debug port. The main purpose is to use your existing debug statements in your code that you monitor using something like Arduino serial monitor. In stead of bringing your laptop to the device and connecting it up though USB, you can add this project to your project, connect it to an ethernet cable and monitor the output anywhere on the same network.

The way it works is with WizNets Wiz750sr serial to Ethernet board. Now this board works on 3.3v so if you connecting it to something like the Arduino UNO which IO runs on 5v, you will need a level shifter board ( if you dont have one, you could use a couple of resistors to do the same thing). See the schematic for hookup an arduino UNO.

Once everything is hooked up and powered up, run the monitoring java program from a pc on the same network. If all is correct you should see the same serial printout as you would see using the arduino serial monitor. My sample arduino program uses both the usb serial and the serial to ethernet module. This is mainly testing.

During initial setup of the wiz750sr I updated the firmware and not fully understanding what I was doing I inadvertently overwrote the MAC address. After a lot of searching I found this Trouble shooting guide https://wizwiki.net/wiki/doku.php?id=products:wiz750sr:troubleshooting:en It tells you the proper settings to use.

Code

monitor.javaJava
This code will make a connection to the WizNet750sr. I will output any data that was sent to it to the screen.
import java.io.*;
import java.net.*;

class monitor{
 

  public static void main(String argv[]) throws Exception {
    Socket clientSocket = new Socket("192.168.11.2", 5000);
    InputStream is = clientSocket.getInputStream();
    byte[] buffer = new byte[1024];
    int read;
    while((read = is.read(buffer)) != -1) {
      String output = new String(buffer, 0, read);
      System.out.print(output);
      System.out.flush();      
    };
    clientSocket.close(); 
  }
} 
Sensor codeArduino
For the purpose of this project, I created this demo code that will count from 1 to 100 and send the output out to a software serial port. It will also read the the software serial port (expecting an inputted number) to set the maximum count, ie, if you send in 1000 it will now count from 1 to 1000.
#include <SoftwareSerial.h>

#define resetPin 3

int sensorValue = 0;
int maxValue = 100;

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("USB Conected");
  
  mySerial.begin(115200);
  while (!mySerial);
  pinMode (resetPin,OUTPUT);
  digitalWrite(resetPin,HIGH); 
  mySerial.println("Wiz750sr Connected"); 
}

void loop() {
    mySerial.println(sensorValue);
    sensorValue++;
    if (sensorValue == maxValue)
      sensorValue =0;
    delay(1);
    //Check to see if any data was sent to the sensor.
    if (mySerial.available()) {
      int i;
      char c;
      char readData[100];          
        while (i<100 && mySerial.available()){ 
          c=mySerial.read();
          readData[i]=c;
          i++;
        }
        readData[i]=0; 
        Serial.println("Read TXT:" + String(readData));
        //Do something with the data, in this case we will set the maxValue to the input data.
        //Some error checking needs to be done here 
        maxValue = String(readData).toInt();
        //because this is just a demo, we will take the data read and send it out the USB serial port to the arduino serial monitor.  
        Serial.println("maxvalue:" + maxValue);
        Serial.println(maxValue);
        Serial.flush();
   }
}

Schematics

Demo Setup
This is the setup for the demo circuit.
Schematic tcp debug port sheet 1 20180627151540 veyefia60k

Comments

Add projectSign up / Login