ARduino micro + Wiz850IO

Hi,

I have trouble to make work an arduino micro with a Wiz850IO.
It Work with a UNO, but something wrong when i make it with the Mirco... I have try both the SPI pin on the top of the card and the side (board) pin.

my connection are :

Micro --------- Wiz850
Gnd -------------- Gnd
3v -------------- V
MISO ------------ MISO
SCK ------------SCK
MOSI ---------- MOSI
SS ------------- CS

I'm a bit confused about the CS Pin number and used Ethernet.init(8); to declare it.

what do I do wrong !?

Thanks for your help
F

my code is :

#include <SPI.h>        
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <OSCMessage.h>
#include <OSCBoards.h>
#include <OSCBundle.h>
#include <Servo.h>

byte mac[] = { 0xDE, 0xAF, 0xBD, 0xEA, 0xEE, 0xED };
IPAddress ip(192, 168, 1, 97); //ip of the arduino / ip to send On // change it on new card
unsigned int InPort = 8888;      // port to send on
const unsigned int outPort= 9000; //  computer port

EthernetUDP Udp; // An EthernetUDP instance to let us send and receive packets over UDP

Servo myServo_1, myServo_2;  // create servo object to control a servo

int Valve = 2;



//================================================================ SETUP =================================
void setup() {
  Serial.begin(9600);
  Ethernet.init(8);  // config CS pin
  pinMode(8, OUTPUT);
  
    pinMode(Valve, OUTPUT);

    myServo_1.attach(3);
    myServo_2.attach(4);
    delay(100);
    myServo_1.write(137);
    myServo_2.write(65);
 
delay(1000);

// start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(InPort);
 
  Serial.print("hello world");
}


// ============================================================== OSC ====================================
// ========================= Ping =========================== //
void OSCMess_Ping(OSCMessage &msg, int addrOffset ){
    OSCBundle bndl; //declare the bundle
    if (msg.isInt(0)){
    bndl.add("/System_Is_connect");
    Udp.beginPacket(Udp.remoteIP(), outPort); // UDP Call/Response: Report on Ip directory
    bndl.send(Udp);   // send the bundle...
    Udp.endPacket(); // mark the end of the OSC Packet
    bndl.empty();    // clear the bundle, ready to use for new messages          
    }  
}

void manageOSCMess_Valve(OSCMessage &msg, int addrOffset ){
    if (msg.isInt(0)){
            if(msg.getInt(0) == 1){
              digitalWrite(Valve, HIGH);
            }
            else{
              digitalWrite(Valve, LOW);
            }
    }  
}

void manageOSCMess_Servo_1(OSCMessage &msg, int addrOffset ){
    if (msg.isInt(0)){
            myServo_1.write(msg.getInt(0));
            Serial.println(msg.getInt(0));
    }  
}

void manageOSCMess_Servo_2(OSCMessage &msg, int addrOffset ){
    if (msg.isInt(0)){
            myServo_2.write(msg.getInt(0));
            Serial.println(msg.getInt(0));
    }  
}

// ============================================================== LOOP ====================================
void loop() {

OSCMessage messageIN;
   int size;
   if((size = Udp.parsePacket())>0){
       while(size--){
       messageIN.fill(Udp.read());
       }
       if(!messageIN.hasError()) {
       messageIN.route("/Valve", manageOSCMess_Valve);
       messageIN.route("/Servo_1", manageOSCMess_Servo_1);
       messageIN.route("/Servo_2", manageOSCMess_Servo_2);
       messageIN.route("/Ping",OSCMess_Ping);
       }
   }

}

are you using the ICSP header pins (next to the RST button) for SPI connections?
icsp-header-300x166

see arduino-micro-pinout-schematic-and-specifications

what is displayed on the serial monitor when you run the code?

Hi Horace,

I've try both: The ICSP on top and the side pin write MI/SCK/MO/SS

I spend some time again today connect on the ICSP header pin and still nothing.

If I run exemple LinkStatus I get on the Serial Monitor= LinkStatus : unknow
If I run exemple file UDPNtpClient :
Failed to configure ethernet using DHCP
Ethernet shield was not found. sorry, can't run wihtout hardware

I try 2 different Wiz850 and get the same result...
I also test Them with a Teensy LC laying around and everything work at 1st try...

Do I need to configure the CS pin as output same if I use ethernet.init(x) ?
Does the pin mark SS on the board is pin 8 ? still confused about that !

thanks
F

try

/*  W5500 Ethernet Web Server using DHCP - if it fails static IP address

using the Ethernet library ran File>Examples>Ethernet>WebServer

 A simple web server that shows the value of the analog input pins.
 using an Arduino WIZnet Ethernet shield.

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 modified 02 Sept 2015
 by Arturo Guadalupi
 
 */

// connections UNO, Feather 32u4, Due, MKRFOX
// W5500 CS  UNO 10 SS    32u4 D10  10  MKR D5         setup with Ethernet.init()
// W5500 MI  UNO 12 MISO  32u4 MISO 14  MKR MISO D10
// W5500 MO  UNO 11 MOSI  32u4 MOSI 16  MKR MOSI D8
// W5500 SCK UNO 13 SCK   32u4 SCK  15  MKR SCK  D9
// W5500 RST UNO RES      not connected
// W5500 VCC UNO 3.3V     32u4 3.3V     MKR 3.3V
// W5500 GND UNO GND      32u4 GND      MKR GND
// W5500 INT not connected
// NOTES:
// DUE is similar to UNO except use SPI pins (not pins 11 12 13)
//     says "Ethernet cable is not connected." but works OK - see fix in setup()
// ESP32 gives compile time errors


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


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields - Feather 32u4
  //Ethernet.init(5);   // MKR ETH Shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit FeatherWing Ethernet
  //Ethernet.init(5);  // ESP32 with Adafruit FeatherWing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");
  // start the Ethernet connection:
  // attempt to configure using DHCP if it fails static IP address
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Serial.println(" attempt to set static IP address");  // start the Ethernet connection and the server:
    Ethernet.begin(mac, ip);
  }
  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1);  // do nothing, no point running without Ethernet hardware
    }
  }
  delay(1000);  // FIX: added to give DUE time to find the Ethernet cable
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an HTTP request ends with a blank line
    bool currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the HTTP request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard HTTP response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");         // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

change the init to suit your configuration, e.g.

  Ethernet.init(8);  
 

if DHCP fails it attempts to set up a static IP address

Hi Horace

I finally get it to work !
SS pin is not number 8 but 17 !!
So it need to be Ethernet.init(17);

thanks & best
F

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.