# New Maslow electronics using ESP32 instead of Atmega2560

**URL:** <https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155>\
**Category:** Technical Details\
**Created:** [February 1, 2018, 8:29pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155 "2018-02-01T20:29:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![whmountains](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/whmountains/32/2031_2.png) [@whmountains](https://forums.maslowcnc.com/u/whmountains)\
**Post date:** [February 1, 2018, 8:29pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/1 "2018-02-01T20:29:04Z")

</div>

Over the past few weeks I’ve been fascinated with the idea of re-designing the Maslow electronics to use an ESP32 module instead of an Arduino Mega. There are some compelling advantages:

- Arduino Mega costs $45 or $10 for a cheap clone. ESP-WROOM-32 module costs $3.50. 😲
- ATMega2650 is clocked at 16Mhz, ESP32 runs at 40Mhz or higher.
- ESP32 has built-in WiFi and Bluetooth support, opening up new possibilities for wireless control.

To top it off, the Arduino environment has already been ported to the ESP32 so I don’t expect it to take much work to get the existing Maslow firmware to run on it.

Thoughts? Comments?

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 1, 2018, 9:01pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/2 "2018-02-01T21:01:39Z")

</div>

I’ve looked into various versions of ESP32 for the Maslow, and the major obstacles are

- number of gpis required
- reliance on TimerOne library
- encoder routines written in assembly to handle interrupts.

None are insurmountable. The lack of gpios would mean having fewer AUX pins, and perhaps changing the PWM-to-gpio routines (see latest Firmware release as a partial example) to use fewer pins. The encoder interrupt routines currently use assembly for speed, the ESP32 is enough faster that they might work in C++.

I also looked at the Teensy3.5 and Teensy3.6 which offer more gpio as well as on-board SD storage. Significantly more expensive, though 🤔. The Maslow firmware doesn’t need too very much changing to compile for one of those.

> [@whmountains](#):
>
> Arduino Mega costs $45 or $10 for a cheap clone

Maslow uses [this](https://www.amazon.com/gp/product/B016JWNYBE/ref=od_aui_detailpages00?ie=UTF8&psc=1) clone, inexpensive but well made and reliable. At $13, not a bad deal.

---

<div class="post-metadata">

**Author:** ![Bee](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bee/32/2160_2.png) [@Bee](https://forums.maslowcnc.com/u/Bee)\
**Post date:** [February 1, 2018, 9:38pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/3 "2018-02-01T21:38:17Z")

</div>

The ESP32 is a development platform. It is not stabilized at this point. It’s considered an experimental stage still being developed. Their are parts that are not working in the Arduino IDE. It is a very powerful platform but it has many cheviots to specific uses. I’d say it’s not ready for prime time yet.

Thank you

---

<div class="post-metadata">

**Author:** ![whmountains](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/whmountains/32/2031_2.png) [@whmountains](https://forums.maslowcnc.com/u/whmountains)\
**Post date:** [February 2, 2018, 12:58am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/4 "2018-02-02T00:58:57Z")

</div>

> To top it off, the Arduino environment has already been ported to the ESP32 so I don’t expect it to take much work to get the existing Maslow firmware to run on it.

Okay, I take that back. It will take a fair bit of work. Still promising though.

Fewer AUX pins is a good point. I didn’t realize how useful they were until you pointed it out and I did a bit of digging. Also the ESP32 pins aren’t 5v tolerant and could be more sensitive to transients, etc.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 2, 2018, 2:05am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/5 "2018-02-02T02:05:54Z")

</div>

The Maslow board will run from the 3v3 logic supply that most ESP32 boards provide. I spent some time getting the firmware up on a Sparkfun ESP32 Thing, it can be done. The Teensy boards are easier to port to, though - the guy who designed them wrote the TimerOne library that the Maslow uses, and he has a version of that for the Teensy3.x boards. They have plenty of gpio pins, too.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [February 2, 2018, 4:40am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/6 "2018-02-02T04:40:50Z")

</div>

> I’ve looked into various versions of ESP32 for the Maslow, and the major obstacles are
> 
> - number of gpis required
> - reliance on TimerOne library
> - encoder routines written in assembly to handle interrupts.
> 
> None are insurmountable. The lack of gpios would mean having fewer AUX pins, and perhaps changing the PWM-to-gpio routines (see latest Firmware release as a partial example) to use fewer pins.

TheESP32 has far more GPIOs available than the arduino

> The encoder interrupt routines currently use assembly for speed, the ESP32 is enough faster that they might work in C++.

something to do with operating at 240 MHz and having two cores available instead  
of operating at 16MHz 🙂

if needed, the assembly could be ported, but I don’t expect that it would be  
needed.

a bigger problem would be that the ESP32 doesn’t have EEPROM, it has flash, so  
things would have to be tracked a bit differently

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 2, 2018, 4:53am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/7 "2018-02-02T04:53:45Z")

</div>

> [@dlang](#):
>
> TheESP32 has far more GPIOs available than the arduino

We’re comparing the Arduino Mega with boards based on the ESP-WROOM-32, which make up almost all the ESP32 market right now. The Mega has many more gpios available, count the pins.  
The EEPROM library was ported to the ESP32 Arduino environment about 6 months ago, and works with the Maslow firmware code without modification. It leaves room for over-the-air updates and a separate file system besides. Not enough room to store a 60,000 line gcode program, though.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [February 2, 2018, 5:24am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/8 "2018-02-02T05:24:58Z")

</div>

Ok, I didn’t realize the Mega has 54 GPIOs, vs the 32 on the ESP32

even so, 32 is far more than we use

If there are so many GPIOs on the Meg, why do we only have 4 aux pins on the  
maslow?

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 2, 2018, 8:08am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/9 "2018-02-02T08:08:19Z")

</div>

> [@dlang](#):
>
> why do we only have 4 aux pins on the maslow?

There are six on the current board…

---

<div class="post-metadata">

**Author:** ![mooselake](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/mooselake/32/6218_2.png) [@mooselake](https://forums.maslowcnc.com/u/mooselake)\
**Post date:** [February 2, 2018, 2:50pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/10 "2018-02-02T14:50:18Z")

</div>

> [@dlang](#):
>
> having two cores available

You don’t know what head bashing is until you start debugging multiprocessor real-time code. It’s even worse when your 50MHz 68030 VME board has an intermittent off board test and set and after you isolate it on a bus analyzer the vendor insists it’s Motorola’s bug, not his.

---

<div class="post-metadata">

**Author:** ![whmountains](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/whmountains/32/2031_2.png) [@whmountains](https://forums.maslowcnc.com/u/whmountains)\
**Post date:** [February 2, 2018, 5:18pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/11 "2018-02-02T17:18:24Z")

</div>

> [@mooselake](#):
>
> You don’t know what head bashing is until you start debugging multiprocessor real-time code.

I can only imagine. That sounds hard!

Usually one of the ESP32’s cores is dedicated for the wireless stack and the other one is for application code. Doing it that way let’s you write real-time code without fear of interruption from an incoming wireless packet.

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [February 2, 2018, 8:57pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/12 "2018-02-02T20:57:04Z")

</div>

expand that to communications, and you have what I think is the right  
architecture for maslow

one core dedicated to handling the movement, the other one handling  
communications (and possibly g-code parsing /planning when we get to that point)

---

<div class="post-metadata">

**Author:** ![whmountains](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/whmountains/32/2031_2.png) [@whmountains](https://forums.maslowcnc.com/u/whmountains)\
**Post date:** [February 2, 2018, 9:08pm UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/13 "2018-02-02T21:08:24Z")

</div>

> [@dlang](#):
>
> expand that to communications

I was about to say that the Arduino IDE doesn’t support multi-core programming on the ESP32, but I googled it and was pleasantly surprised.

[![](https://img.youtube.com/vi/k_D_Qu0cgu8/maxresdefault.jpg "#168 ESP32 Dual Core on Arduino IDE including Data Passing and Task Synchronization") ](https://www.youtube.com/watch?v=k_D_Qu0cgu8)

---

<div class="post-metadata">

**Author:** ![whmountains](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/whmountains/32/2031_2.png) [@whmountains](https://forums.maslowcnc.com/u/whmountains)\
**Post date:** [February 4, 2018, 1:47am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/14 "2018-02-04T01:47:26Z")

</div>

> [@blurfl](#):
>
> I spent some time getting the firmware up on a Sparkfun ESP32 Thing, it can be done.

This is exciting! How much work do you think was left?

> [@blurfl](#):
>
> The Teensy boards are easier to port to, though - the guy who designed them wrote the TimerOne library that the Maslow uses, and he has a version of that for the Teensy3.x boards. They have plenty of gpio pins, too.

Not a bad idea if it comes to that. A $12 price increase isn’t going to make or break my decision to buy a Maslow. I guess it depends on how much time we’d save vs running everything on the ESP32.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 4, 2018, 2:52am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/15 "2018-02-04T02:52:55Z")

</div>

> [@whmountains](#):
>
> How much work do you think was left

The current generation of Maslow PowerControl boards need 15 pins (9 output, 6 interrupt input) for motor control and four pins for version detection. That’s without any AUX pins. That’s a tight squeeze for any available ESP32 board and some compromises would be needed. I got this far trying to wedge the Sparkfun ESP32 Thing onto the Maslow PowerControl board, with a possible connection schema for the Maslow motor signals in blue:

 ![Sparkfun%20ESP32%20Thing%20to%20Maslow%20PowerControl](https://canada1.discourse-cdn.com/flex031/uploads/maslowcnc/original/2X/c/c56a537f1edd3a9f66539530c011bdbdfce92d81.jpg)  
Many of the ESP32 pins that I avoided need to be in special states at power-up, or have other duties or limitations beyond pure gpio. When I compared those limits to the Teensy3.5/3.6, I put it aside.

I spent more time on the Teensy3.5/3.6 boards, made a carrier to connect a Maslow PowerControl board and have had a first go at bringing the firmware up on it. That seemed like an easier way to get higher speed, with fewer trade-offs.

---

<div class="post-metadata">

**Author:** ![Bryan\_Pollock](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@Bryan\_Pollock](https://forums.maslowcnc.com/u/Bryan_Pollock)\
**Post date:** [February 4, 2018, 4:14am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/16 "2018-02-04T04:14:39Z")

</div>

What about using a multiplexer such as a 4051?

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [February 4, 2018, 4:36am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/17 "2018-02-04T04:36:25Z")

</div>

using one of the thing/feather/etc boards that they have stuffed a ESP32 on is going to be very limiting. the raw ESP32 castelated module is not nearly as limiting

---

<div class="post-metadata">

**Author:** ![Bee](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bee/32/2160_2.png) [@Bee](https://forums.maslowcnc.com/u/Bee)\
**Post date:** [February 4, 2018, 6:47am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/18 "2018-02-04T06:47:02Z")

</div>

I’m going to lean towards the teensy board. They are being used in 3D printers all ready & Paul has put a ton of work it to them.

[https://www.pjrc.com/teensy/](https://www.pjrc.com/teensy/)

I’d look at the 3.5

my 2 cents

Thank you

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [February 4, 2018, 6:48am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/19 "2018-02-04T06:48:57Z")

</div>

> [@Bee](#):
>
> I’d look at the 3.5

There are many similarities. What’s the deciding factor? Is it the lower cost?

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [February 4, 2018, 7:02am UTC](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155/20 "2018-02-04T07:02:32Z")

</div>

The ESP is more powerful and includes wifi and bluetooth

the teensy is designed to be closer to a drop-in arduino board replacement.

if it was me, I’d be looking really hard at the ESP32, and not in any of the  
plugin modules, just as something soldered to the motor controller  
board (eliminating all those connectors saves cost and space 🙂 )

but there are a lot of options out there now.

[Next page](https://forums.maslowcnc.com/t/new-maslow-electronics-using-esp32-instead-of-atmega2560/2155.md?page=2)
