ENC28j60 fail

weslleymata
Wed Aug 31, 2016 5:18 pm
Hello ,
I’m ethernet problems with ENC28J60 module, I bought the card in the aliexpress .

[img] https://pt.aliexpress.com/item/1pcs-STM … .81.GS0mOZ[/img]

tested in arduino 1.6.3 and 1.6.11.

my code example enc28j60:

// PIN Connections (Using STM32F103):
//
// ENC28J60 - STM32F103
// VCC - 3.3V
// GND - GND
// SCK - Pin PA5
// SO - Pin PA6
// SI - Pin PA7
// CS - Pin PA8
//-----------------------------------------------------------------
//
//

#include <EtherCard_STM.h>
#include <SPI.h>

#define REQUEST_RATE 5000 // milliseconds

// ethernet interface mac address
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
// remote website name
const char website[] PROGMEM = "google.com";

byte Ethernet::buffer[700];
static long timer;

// called when the client request is complete
static void my_result_cb (uint8_t status, uint16_t off, uint16_t len) {
Serial1.print("<<< reply ");
Serial1.print(millis() - timer);
Serial1.println(" ms");
Serial1.println((const char*) Ethernet::buffer + off);
}

void setup () {
Serial1.begin(19200);
Serial1.println("\n[getDHCPandDNS]");

if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial1.println( "Failed to access Ethernet controller");

if (!ether.dhcpSetup())
Serial1.println("DHCP failed");

ether.printIp("My IP: ", ether.myip);
// ether.printIp("Netmask: ", ether.mymask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);

if (!ether.dnsLookup(website))
Serial1.println("DNS failed");
ether.printIp("Server: ", ether.hisip);

timer = - REQUEST_RATE; // start timing out right away
}

void loop () {

ether.packetLoop(ether.packetReceive());

if (millis() > timer + REQUEST_RATE) {
timer = millis();
Serial1.println("\n>>> REQ");
ether.browseUrl(PSTR("/foo/"), "bar", website, my_result_cb);
}
}


zmemw16
Wed Aug 31, 2016 8:29 pm
you posted a picture of the ‘Blue Pill” – not a network module.
stephen

weslleymata
Thu Sep 01, 2016 1:57 am
Hi, Sorry.
O AM use a Enc28j60 with maple mini.
Not work enc28j60 with maple mini “stm32f103”.

RogerClark
Thu Sep 01, 2016 3:26 am
Why didnt you just search the forum for anyone else who has used the ENC28j60

I quickly found this

https://github.com/Serasidis/Ethernet_STM

Which seems to use the same Ethernet chip


weslleymata
Thu Sep 01, 2016 10:49 am
hello RogerClark ,
I am creating an application that sends data through the internet using GET PHP before I used the ATmega328 , but I miguei for STM32F103 for reasons of memory and better performance.
When I used the ATmega328 with ENC28J60 everything it worked properly, but I’m now using STM32F103 with ENC28J60 and does not work .

I use the STM32duino -master library, usually carries STM32F103 ( MAPLE MINI ) , but it seems not work.

I am using the IDE arduino 1.6.3 .

Someone using the Arduino IDE and ENC28J60 and MAPLE MINI with a GET php sample code , please help me .
thank you now.


weslleymata
Thu Sep 01, 2016 11:03 am
see the tests failed DNS with my serial1 , bad when I use ATmega328 everything works normally.

[getDHCPandDNS] DNS failed

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ
<<< reply 1077 ms
tii-01Àêäd
<<< reply 1077 ms
tii-01Àêäd

>>> REQ
<<< reply 371 ms
tii-01Àêäd


RogerClark
Thu Sep 01, 2016 12:01 pm
Try PM’ing @vassilis he wrote that code, I don’t have that hardware

zoomx
Thu Sep 01, 2016 2:17 pm
Check if it works with 8.8.8.8 instead of google.com

martinayotte
Thu Sep 01, 2016 2:43 pm
There is also the Arduino_UIP library which I’ve used under F4, it should be trivial to port it under F1.
https://github.com/rogerclarkmelbourne/ … rduino_uip

weslleymata
Thu Sep 01, 2016 2:52 pm
Hello everyone,
yet still the same error . see the serial monitor :

[getDHCPandDNS] DNS failed

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ

>>> REQ
<<< reply 185 ms
tii-01Àêäd
<<< reply 186 ms
tii-01Àêäd

>>> REQ
<<< reply 538 ms
tii-01Àêäd


weslleymata
Thu Sep 01, 2016 2:55 pm
I need the stm32 use a dynamic IP , ie , the card will plug into several different networks , after getting an IP it will start to send data via GET PHP.

I decided to change to ATmega328 STM32F103 for memory reasons.

and so I am new to the world of CORTEX – M3


danieleff
Thu Sep 01, 2016 9:01 pm
I tried your code, and what I got was: using Serial, it worked, but using Serial1 (and the correct pins of course), it only got to [getDHCPandDNS], and then stopped (probably inside ether.begin(…)).

So maybe try Serial with A9/A10 pins.


weslleymata
Fri Sep 02, 2016 10:46 am
Good Morning,
I use Serial1 because I’m using the ST -LINK V2 cable and use one card arduino in Serial1 to communicate send the data in the serial monitor .

Using the ST -LINK V2 cable and look at the serial monitor ?


weslleymata
Fri Sep 02, 2016 1:35 pm
I connected the micro USB cable to the mini Maple plate , now I’m using serial and no more Serial1 , and carrying scketch with ST -LINK V2 cable and IDE arduino 1.6.3 , bad even then the Ethernet network does not work.

Upload to RTCclock and led PC13 blink and everything works normally.

#include <RTClock.h>

RTClock rt (RTCSEL_LSE); // initialise
uint32 tt;

#define LED_PIN PC13

// This function is called in the attachSecondsInterrpt
void blink ()
{
digitalWrite(LED_PIN,!digitalRead(LED_PIN));
}

void setup()
{
pinMode(LED_PIN, OUTPUT);

rt.attachSecondsInterrupt(blink);// Call blink
}

void loop()
{

if (rt.getTime()!=tt)
{
tt = rt.getTime();

Serial.print("time is: ");
Serial.println(tt);
}
}


weslleymata
Fri Sep 02, 2016 2:00 pm
Looking for maple mini board , when I upload the scketch of UIP_ethernet or serasidis_ethernet_stm , the serial does not work , but when I upload the scketch blink led normally works the serial .

what could it be?


Vassilis
Mon Sep 05, 2016 1:05 pm
@ weslleymata
Sorry for the delay but I was very busy (as most of us) during the last months.
I saw the example code you posted and it works ok, at least on my STM32F103C8T6 and ENC28J60 ethernet module.

Arduino IDE: 1.6.5
Libray: Ethercard_STM

Serial terminal snapshot
My IP: 192.168.1.9
GW IP: 192.168.1.1
DNS IP: 192.168.1.1
Server: 62.1.38.163

>>> REQ
<<< reply 86 ms
HTTP/1.0 404 Not Found
Content-Type: text/html; charset=UTF-8
Content-Length: 1568
Date: Mon, 05 Sep 2016 12:19:19 GMT

<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content=”initial-scale=1, minimum-scale=1, width=device-width”>
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body


The only thing I need to notice is that by default the Chip Select (CS) pin is the PA8. If you want to use any other pin you have to declare it to the ether.begin line.

PA8 is used as Chip Select pin (default setting)
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)


weslleymata
Fri Sep 09, 2016 7:23 pm
Hi Vassilis ,
I tested in my house and this normal functioning , thank you.

Another question , the crystal is on the board is 8MHZ but works in 8MHZ or 72MHz ?

Another question , I’m using a dynamic IP , it will be used in several different types of networks , poor have any networks that does not work , even turning off the firewall network ETH ENC28J60 card can not connect to the internet.

Thanks for everything .


RogerClark
Fri Sep 09, 2016 8:31 pm
There is a clock multplier on the clock frequency inside the STM32.
( It is set to 9 times multiplication, hence 72mhz which is the normal clock freq for this device)

Leave a Reply

Your email address will not be published. Required fields are marked *