ESP32 + W5500 — Simple Working Example

Over the past couple of days, in the course of answering questions on the popular article on adding an ethernet port to the ESP8266, I found myself putting up a link to some new code for a work-in-progress project which simply replaces the ESP8266 with an ESP32 (which seems to make a lot of sense, given the falling cost of the ESP32 modules, nowadays).  ESP32 + W5500 moduleWhile that project is for an ESP-Now gateway, it seemed like there was a need for a nice, simple test and verify project where people can do a minimum of work with the hardware (an ESP32, a W5500 module, some jumper leads and a breadboard) and get a working result in a reasonably short time.  I’d said in various places that it shouldn’t take too much work to modify the code for the ESP-Now project to handle any of the examples shipped by default with the Arduino Ethernet library, so that’s what I’ve done.

Here’s the code (along with the pinouts in the README) for the simple “UdpNtpClient” example, munged very slightly to work with the ESP32Output exampleAll it does is connect to an NTP server, retrieve the current timestamp and display the UTC time.  This is basically a 30-minute project to produce a working demostration of an ESP32 using hard-wired Ethernet.

The configuration uses a static IP and network setup (router/gateway, netmask and DNS), as the original ESP8266 project seemed to have problems with DHCP (and quite honestly, I just haven’t gotten around to trying it with the ESP32 version, yet …let me know how it goes if you do).  All of the configuration options are in the “local_config.h” file.

The original library example code uses a single NTP server, “time.nist.gov”, which seemed a little anti-social to me, so I’ve added several of the more popular geographical pools into the config file and updated the default target to be the main “pool.ntp.org”.   You should choose the one closest to you (unless you’d like to see how unreliable bare UDP really is, in which case you might like to try “antarctica.pool.ntp.org”  —  apologies if you’re reading this from McMurdo Station 🙂 ).

 

 

Advertisements

Recent Updates (March 1st, 2019)

Otto Winter has been continuing his updates to esphome with improvements to the set-up wizard and the addition of min/max settings for rotary encoders (esphome enables you to add an ESP8266 or ESP32 to Home Assistant without writing any code).

Theo Arends has been working on reducing stack space usage in Sonoff-TASMOTA to fix some intermittent crashes.  If you’re having issues, please upgrade to version 6.4.1.18 or greater (see this post for more details).

Phil Bowles has been updating the API documentation and examples for his esparto rapid development framework for the ESP8266 (available as an Arduino IDE library; write concise, working code with no setup() or loop() functions).

Xose Pérez has made lots of changes to his espurna replacement firmware for ESP8266 devices over the past few weeks, with support for more than twenty new products added and the incorporation of many fixes (both from Xose himself and submitted by an ever-growing community of users).

Rich Heslip has published an ESP32 project, “Motivation Radio BLEMIDI”, to add WiFi and Bluetooth functionality to Eurorack based modular synthesizers.  The hardware for this module is also open source and available from a separate repository, courtesy of Jim Matheson.

 

TASMOTA exceptions and watchdog resets

Just a quick note on recent TASMOTA changes.  Theo has been pushing out some updates over the past couple of days to fix an intermittent stack overflow problem which has cropped up with some combinations of hardware and TASMOTA firmware.  The issue seems to manifest itself with TASMOTA versions 6.4.1.16 and 6.4.1.17 and some devices which do load current monitoring (eg:- the NX-SP201 series, double-outlet smart switches).  Initial indications are that executing a “status 0” command at exactly the same time as the current monitor is updating can run the device out of stack space.

Bottom line… update to release of 6.4.1.18 (or greater) if you’re seeing these symptoms.

Recent Updates (Feb 14th 2019)

I’ve added Mike Rankin’s Twitter feed to the ESP32 links section (RH column).  Mike has several ESP8266 and ESP32 projects in his Github repository and usually has some interesting commentary on his Twitter feed (ongoing status, problems, fixes, etc).  His latest project, a rechargeable-coin-cell based ESP32 mini board, is definitely worth a look, as are his previous ESP8266 creations.

Theo and his merry band of helpers have been hard at work pushing out more updates to Sonoff-TASMOTA.  Along with some code refactoring at the end of January to change “boolean” types to “bool” and “byte” to “uint8_t”, some other interesting updates have just slipped out in the last couple of recent releases:-

  • Templates.  This is a great new feature which allows people to  add new device GPIO definitions via JSON templatesA repository for user-submitted templates has already been created.
  • Support for multiple ADS1115 devices on the i2c bus.  If you’ve been limited by the single AtoD pin on the ESP8266, you can now add up to four, four-channel ADS1115 devices (on unique addresses) to the i2c bus and have them automatically recognized.
  • Numeric operators “==”,  “!=” ,  “>=”  and  “<=”  added to rules (the previously existing  “=”  string comparator frequently produced unexpected results when used in a numeric context).
  • HASS discovery and status for sensors.

Martin Ger has just updated his esp_wifi_repeater package to handle MQTT QOS (in version 2.2.5).

Adding Alexa control.  Phil Bowles has released a tiny Wemo emulator library, “weenymo.  It’s about 60 lines of code and adds Alexa on/off functionality to your ESP8266 projects (and don’t forget to check out his “esparto” rapid development library while you’re visiting his GitHub repository).

Otto Winter has integrated the esphomeyaml and esphomelib projects under the umbrella name of “esphome.  If you haven’t come across either (any) of these before, the basic idea is that a user can write a short configuration file and have code automatically generated for an ESP8266 or ESP32.  With esphome, you can have an application up and running on your ESP in a few minutes without writing a single line of code yourself.

ENC28J60 Gateway (Was:- Not-So-Recent Changes)

While answering a question in another thread, I realized that I’d missed an exciting change which, from the number of hits related pages get, is sure to be of interest to readers of this blog.

Back in the March/April time frame, Martin Ger updated his ESP WiFi Repeater to support an SPI-connected ENC28J60 ethernet module.  The work was quite well hidden, way down the page in a very long README (which catalogues the tremendous amount of work that Martin has put into this project).  Martin credits Andrew Kroll “…for his great work on getting [this] right”, so kudos to both of them for a very useful addition.

ENC28J60 hardware

You’ll need to run your ESP at 160MHz and have a decent power-supply to have this mod work effectively, but as Martin points out, once you have the ENC28J60 hardware configured with his ESP WiFi Repeater package, you’ve got yourself a super-cheap, DIY access-point.

Recent Updates (20th Oct 2018)

esp-go  –  Pete Scargill’s re-badged “Hackitt & Bodgitt” code for a universal i2c Nano peripheral extender for the ESP8266.

Pete has mainly been updating the documentation for his code over the past couple of weeks.  In the latest release, the name has changed to “esp-go.doc” to reflect the re-branding.

 

badgy  –  SQFMI’s “Swiss Army” e-Ink badge,based on the ESP-12F.

SQFMI has updated the code to work with the latest version (3.0) of the GxEPD library.

 

mobile-rr  –  idolpx’s ESP8266 Mobile Rick-Roll Captive Portal.

idolpx has added some images to the documentation to help novice ESP8266 users get a better grasp of what they’re doing, as well as updating the code to add DNS overrides and improve the WiFi scan filtering.

 

Sonoff-Tasmota  –  Theo Arends’ all-purpose replacement for Sonoff firmware.

Theo has been steadily updating and improving the 6.2.1 version of his firmware with (in no particular order):-

  • A change to a non-blocking MQTT library as the default.
  • Add support for the DS3231 RTC.
  • Add TasmotaModbus library.
  • Add support for the HX711 load cell.
  • Add support for Pzem energy monitors.

…as well as various fixes.

 

IRremoteESP8266  –  A library to enable IR send and receive on the ESP8266.

Mark has updated the package to support Disney’s “Made With Magic” protocol.

 

 

 

Recent Updates

JLed – a library to provide painless control of LED blinking, breathing and fading effects.

Jan Delgado has updated his JLed library a couple of times over the past week.  The first update was a change specific to the ESP8266 to improve the 8-bit to 10-bit scaling, so that LEDs now reach full brightness.  The second change is the addition of a boolean return value to the Update() function to indicate whether the target effect is still active, or has completed.

OpenMQTTGateway – Bidirectional gateway for the integration of 433MHz, BLE and IR devices with MQTT.

Florian has made a small change to his OpenMQTTGateway to make the “TRACE” function compile-time selectable, in order to reduce the overall code size for those who don’t use it.

IRremoteESP8266 – A library to enable IR send and receive on the ESP8266.

Mark and his various contributors (including “crankyoldgit”) have added initial support for Elektra, Samsung and Whirlpool air-conditioners and experimental support for  Coolix and Lutron.  There are also additional fixes for Mitsubishi A/C and the IRMQTTServer code.

Esparto – A rapid development framework for ESP8266

Phil Bowles has added MQTT username & password functionality to his (relatively new) rev-2 version of Esparto, as well as fixing a couple of minor bugs.

 

esp8266-weather-station-color – An ESP8266 and ILI9341/XPT2046 based weather display.

Daniel and Marcel continue to update the colour weather-station display, with fixes for some I18N and WiFi issues.