Install latest Marlin on Creality Ender 3

If you own a Creality Ender 3 and want to deploy Marlin on it you should first ask yourself why.

Why

When searching Google for that topic, a bunch of results and video tutorials appear in front of you talking about the ‘benefits’ of that ‘improvement’. Well, if you read the details you will find comments like Ender 3 is a great 3D printer but comes with some defects and the new version of Marlin is the solution to that. But seriously, what are those defects?

I bought the printer 3 weeks ago and I have to say that the results are impressive. Ok, it is my first 3D printer, but before acquiring it I was reading a lot about the subject and the most common advice in every web I visited was: don’t get frustrated about the results of 3D printing? You will get a lot of bad results and that’s normal. I’ve got too few bad results with my Ender 3… until yesterday.

Is it worthy?

After reading and watching some tutorials I decided to install a bootloader on my printer to upload the latest Marlin version to it. Why? I still don’t know.

Burning the Bootloader

It wasn’t easy. I look for some old Arduinos I knew I had and found a Duemilanove and a Mega. The board used by Creality in it’s Ender 3 is compatible with ATMega Sanguino boards, so all you have to do is burn the bootloader on the board and then use Arduino IDE to upload the sketch with the latest Marlin version.

Burning the bootloader has to be done with an ISP programmer or using an Arduino as ISP. The procedure is quite simple:

  1. Open the board box of your  Ender 3
  2. Locate the ICSP connector
  3. Use five Dupont Female to Female wires to connect:
    1. GND to GND
    2. 5V (VCC) to 5V(VCC)
    3. SCK to SCK
    4. MOSI to MOSI
    5. MISO to MISO
  4. Use one Dupont Female to Male wire to connect:
    1. RESET to IO10 of your Arduino board
  5. Upload Arduino ISP sketch to your Arduino (in examples)
  6. Change board to Sanguino and Programmer to Arduino as ISP
  7. Burn Bootloader

I can’t remember how many times I tried. Changing port, reviewing wires many times, switching on / off, using Duemilanove and Mega… and nothing worked. I got the same error always and it seemed there was a problem getting synchronism in Avrdude tool.

Arduino’s ISP issue and the capacitor workaround

Then I remembered I had this problem years ago when playing with Arduinos. First Arduino models had problems with reset while negotiating ISP programming and the workaround is using a 10μF electrolytic capacitor between reset and GND pins.

Capacitor between RST and GND
The capacitor between RST and GND

Remember electrolytic capacitors have polarity and you shouldn’t reverse them:

After plugin the capacitor I was able to burn the uploader.

Uploading Marlin latest and ‘improved’ version

As expected, the printer was now reset. No printing program inside it and a blank LCD screen showing nothing.

That is the moment to upload Marlin latest software using Arduino IDE.

My intention is not telling you all the steps to do this, as the Internet is full of videos and tutorials (and remember, I don’t recommend doing it), but telling you what happened to my printer after doing that. 

I uploaded the latest Marlin software with some miracle customizations performed in the parameters code by an expert guy. The result? After leveling the bed I tried with a small box and… 

filament not sticking
Filament not sticking to build plate

That was the first time in three weeks. Before that, the adhesion was very good. I tried some more times, I calibrated and leveled the bed and always the same result. I found that when the nozzle never got enough close to the plate. Maybe the miraculous customizations?.

I decided then to go back to the Creality version, which is a previous Marlin version adapted for Ender 3.

Creality Ender 3: Going back to manufacturer version

The good news is that we can now upload code to our printer because we have deployed a bootloader on it.

All we have to do is to find the manufacturer’s original code.

Go to manufacturer’s download page and find Ender 3 model

ender 3 creality
Ender 3 picture in the download page

Click on Download button and save the .rar file

Extract the .rar file in a folder.

Locate the Marlin folder inside the folders created by the Unrar tool.

Copy the Marlin folder to a better location and edit the Configuration.h file.

Change the language for display. Locate the line (line #1188 in my version)

#define LCD_LANGUAGE cn

and replace cn with your language code (en, de, es, it, fr, …)

Compile and upload to the printer port detected when plugged in. 

Remember you have to set these options in Tools menu:

Board: Sanguino

Processor: ATmega1284 or ATmega1284P (16MHz)

Port: The one detected by your machine.

Programmer: AVRISP mkll

Conclusion

I think it isn’t worthy of it deploying the latest Marlin version on your Ender 3, mainly because you are not going to get a lot of improvements.

In the other hand, it is very interesting having a bootloader installed and the capability of loading the code into the printer, but only if you need to customize the code.

 

ILI9341 + ESP32 (Parallel)

Today I’ve received two ILI9341 TFT screens that I ordered some weeks ago. These screens are in fact a shield designed for Arduino Uno but they work nicely when connected to other developer boards and the price is amazingly cheap: just US$4.

ILI9341 Front
ILI9341 Front
ILI9341 Back
ILI9341 Back

In this case, we will connect the screen to an ESP32 Dev Board.

The pins are configured in a slightly different way than other examples you could find in the web: I’ve tried to minimize mistakes because we will use 13 pins so I thought the best way would be to use as much as possible consecutive pins.

ILI9341 pin to pin ESP32
ILI9341 pin to pin ESP32

 

ILI9341 to ESP32
ILI9341 to ESP32

You can also connect the ILI9341 using only 4 IO pins (not this model), but the refresh/painting speed is not comparable.

The library we will use is TFT_eSPI library by Bodmer and our only purpose by the moment will be executing an example demo script successfully.

During testing, you can connect TFT 3V3 pin directly to ESP32 3V3 pin, but do it only during a short period of time because the current drawn by the screen LEDs is 134mA and you will notice how the LEDs and the Development Board voltage limiter will become hot.

A 22Ω resistor (not 220) between the two 3V3 pins it’s enough to reduce the current to 23mA and though the screen is not the brightest one in the world I think it is enough for testing purposes.

Once you have finished the connection of the pins as described in the diagram above, you can install the TFT_eSPI library if you don’t have it already installed.

Open Arduino IDE, go to Library Manager and in the search box type TFT_eSPI. In the results list, look for the next and install it.

TFT_eSPI Bodmer Library for Arduino
TFT_eSPI Bodmer Library for Arduino

Now you have the library installed you have to configure the IO pins where we have connected our screen. Other libraries use the definition of constants at the top of each sketch to do this, but TFT_eSPI uses a common file to define the configuration.

Find in your Arduino installation the file called User_Setup.h

It should be located in a path equivalent to this:

[Arduino Folder]/libraries/TFT_eSPI/User_Setup.h

Now, copy the file for backup purposes and edit the original to place inside it this following content (replacing all the previous content):

// See SetupX_Template.h for all options available

#define ESP32_PARALLEL


#define ILI9341_DRIVER


// ESP32 pins used for the parallel interface TFT
#define TFT_CS   27  // Chip select control pin
#define TFT_DC   14  // Data Command control pin - must use a pin in the range 0-31
#define TFT_RST  26  // Reset pin

#define TFT_WR   12  // Write strobe control pin - must use a pin in the range 0-31
#define TFT_RD   13

#define TFT_D0   16  // Must use pins in the range 0-31 for the data bus
#define TFT_D1   4  // so a single register write sets/clears all bits
#define TFT_D2   23
#define TFT_D3   22
#define TFT_D4   21
#define TFT_D5   19
#define TFT_D6   18
#define TFT_D7   17


#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts

#define SMOOTH_FONT

Save the file and go back to Arduino IDE.

Open the example sketch UTFT_demo (it is under File / Examples / TFT_eSPI /  320 x 240 / UTFT_demo)

At this point, you can compile and upload the sketch to your ESP32. If everything went ok you should see some graphics, backgrounds and texts appearing in your TFT screen. Otherwise please review carefully the IO pins configuration (hard and soft).

If it works, probably you’ll see the results like in a mirror. To solve this, go to the sketch and edit the line that sets the screen orientation. This is done in the setup function.

void setup()
{
  randomSeed(analogRead(A0));
// Setup the LCD
  myGLCD.init();
  //myGLCD.setRotation(1); //Comment out this one and insert the one below
  myGLCD.setRotation(7);
}

The result now should look like this

Breadboard adapter for ESP32 dev. board

It is frustrating the first time you insert an ESP32 dev board into a breadboard and you notice there’s no room for wires.

ESP Dev Board on Breadboard
ESP Dev Board on Breadboard

What I usually do is putting a breadboard aside another one, but I don’t like it very much.

Workaround for ESP Dev Board on breadbord
Workaround for ESP Dev Board on two breadboards

I decided then to split the small board into two pieces and insert them in a 3D printed base so that the dev board pins get into the first row of holes and the rest remain available.

Splitted breadboard
Split breadboard
ESP32 Dev Board on split breadboard
ESP32 Dev Board on the split breadboard
Breadboard splitter design
Breadboard splitter

.stl file available at www.thingiverse.com

Breadboard Splitter
Breadboard Splitter
Breadboard Splitter side view
Breadboard Splitter side view
Breadboard Splitter top view

Claudio, the box

The box of the prototype consists of 4 pieces designed with Freecad to be 3D printed.

I used PLA, heating the bed up to 60ºC and the nozzle to 200ºC.

Claudio Front side
Frontside (from inside view)
Base (from inside view)
Cover (upside down)
Backside (from inside view)

Mounting is very simple and though the design includes eight blocks at the corners to allow screwing I found it wasn’t necessary as the pieces stay together after mounting due to pressure.

The four ‘columns’ at the base allow mounting a PCB over them and some wires can pass down it.

Some more pictures follow below:

Buzzer placement

DHT11 placement

 

MicroUSB hole
Mounted box

 

Claudio, parts and some links

Claudio consists of just five (or six) components, the wiring between them and code. No resistors, capacitors, diodes… no discrete components apart from 3 five cents of € coins. 😉

List of components:

  1. ESP32 Development Board: I’ve tested two different boards, and though they are very similar the results were not the same. 
    ESP32 Development Boards Front
    ESP32 Development Boards Front

    ESP32 Development Boards Back
    ESP32 Development Boards Back

    Price: US $7
    The first one was the one on the right side. It is a board I bought a year ago and it was working fine (for small tests) since then. When I first tried to put all the components together I noticed that ILI9341 TFT Display and WiFi connection were not good friends working at the same time. After 3 or 4 display operations (text, area fill, …) the screen went always blank and only when WiFi library was loaded. I tried multiple pin configurations, alternate libraries loading order. I tested voltage on each significant pin (D/C, CLOCK, MOSI) and no result.
    Finally, I decided to give a try one of the last boards I bought: the model on the left side. The result was successful. No blank screen. But, these boards have a bug design: they don’t allow uploading schemas directly from Arduino IDE (Error: Timed out waiting for packet header) and you have to ‘play’ with EN and BOOT buttons every time.
    Workaround: once Arduino IDE tries to upload the schema, press BOOT and without releasing it press also EN button, wait for a half second, release EN and when IDE stops waiting and starts the uploading you can release BOOT button.

    Error Time_out_waiting_for_packet_header
    Error uploading schema from Arduino IDE

    ebay.com search for ESP32 Dev Board
  2. ILI9341TFT Screen – SPI
    Again, the component I had at home was about one year old. The only difference is that the one you can find now implements a set of pins to control a touch panel (though they say at the product description “non-touch”). Anyway, I think the one is being sold now is perfectly compatible with the previous model.
    What we need for this design is a model with an SPI pin configuration. Sellers usually refer to these as “driven with at least four IO”
    Price: US $7
    ILI9341 SPI TFT Display
    ILI9341 SPI TFT Display
     Sample ebay.com link to ILI9341

  3. DHT-11 Temperature and Humidity Sensor
    This is a low-cost sensor very easy to use. Though it has four pins, only three of them have a function (the other one is not connected).
    Simply connect ground pin to GND, VCC pin to 3V3 and Data Out pin to any ESP32 IO pin.
    Depending on the range of temperature/humidity you need to measure, you should take a look also to DHT-22 sensor (which implements a wider range and more accuracy), but in my case, 0-50ºC/20-80%R.H. is quite enough.
    Price: US $1
    DHT-110 Temperature and Relative Humidity sensor

    ebay.com link to DHT11 search

  4. BH1750FVI Digital Light Intensity Sensor
    I think the best feature of this sensor is, apart from ease of use, the sensibility and stability.
    It measures ambient light and gives the result in Lux
    It has 5 pins, but once again we can ignore one of them (ADD) by connecting it to GND. So, we only need two ESP32 IO pins to connect  SDA and SCL sensor pins.
    GND and VCC pins go to GND and 3V3 ESP32 pins respectively.
    Price: US $1
    BH1750FVI Ambient Light Sensor
    BH1750FVI Ambient Light Sensor
    ebay.com link to BH1750FVI search

  5. Passive Piezo Buzzer
    The most basic part of the system.
    Just two pins (the middle one can be ignored), one goes to GND and the other one to an ESP32 IO pin.
    Price: US $0.2
    Passive Piezo Buzzer
    Passive Piezo Buzzer

    ebay.com link to Piezo Buzzer search

  6. Touch sensors (5 cents of € coins)
    Each one connected to an ESP32 Touch pin.
    Price: 0.15€
    5 cents euro coin
    5 cents euro coin
    Mounted coin touch sensors
    Mounted coin touch sensors

Claudio, a wake-up alarm not so simple

New blog and to tell you the truth, my first blog. No personal introduction, no sensitive content… 🙂

I made some basic tests with an ESP8266 a couple of years ago and I was very pleased with the board capabilities, the freshness of NODEMCU, the quick schema uploading… everything. But I didn’t like one aspect, in the same way, I didn’t like some years before about Arduino boards: connectivity.

The ESP32 arrived, WiFi and BLE connectivity, a bunch of IO pins, a lot of different pin working modes… and for someone with limited knowledge of electronic theory… a marvelous tiny thing.

Lately, I am having much more spare time that I used to have, so I decided to start doing things I always wanted to do but I never had the time to. I don’t like using my cellular for all purpose. I like WakeUp alarm clocks, but not the ones they sell. My last WakeUp alarm was a Sony, very nice, spectacular design but “who the hell designs an alarm clock supposed to be stopped while you are sleeping by pressing a tiny switch in the middle of a lot of more tiny switches? Yes, Sony” And what if I design my own Alarm Clock with that ESP32 Developer board I have? And that’s what I did.

The requirements:

  1. Time visible in the dark, but not like a red UFO. Light intensity has to accommodate to room light.
  2. No need for time adjustment. No need to change the hour every spring or autumn.
  3. Minimal use of buttons, tiny buttons, micro switches… :S
  4. If there’s enough room on the screen… some other indicators like temperature and relative humidity (these are enough important in the dry & hot Madrid nights)
  5. If possible, some communication capabilities: remote configuration, remote alarm stopping, …
  6. Easy to wire components between

The prototype:

I needed a box to fit all the components in. Perfect reason to buy my first 3D printer, and that’s what I did.

This is the screen design today… it’s evolving and probably will not be the same in a couple of days.

Claudio WakeUp Alarm Screen

The box is 11cm x 65mm x 65mm and though is a bit bigger than I expected it to be I think of it as a prototype and time will bring smaller designs.

Claudio Wake Up alarma box
Claudio Box

This has been only the introduction. Check out the rest of the posts to know more about the design, the code and the possibilities of ‘the creature’.