Etch a Selfie

18,134

87

12

Introduction: Etch a Selfie

About: Trust me I'm an engineer

Motivation

I'm planning to build my own home automation system with an ESP32 as the main microprocessor. So I was looking for a fun project to test it's capabilities and to get to know it's good and bad sides.

I bought my daughter an Etch A Sketch but it turned out she is too young to play with it and I'm myself really bad in controlling it. So my idea was that I could implement a joystick so my daughter could play with it easily.

I found some builds what have done this already. So I needed to add something extra to make it special. I was already planning to use a camera for the home automation so naturally I want to play around with that too.

So the "etch a selfie" idea was born.

In the end it turned out it was harder to implement than expected. But don't worry it's working and you can use my firmware and I designed the PCB in a way that it should be really easy to solder even for a beginners :-)

How does it work?

First we need something to control the stepper motors. For that I use grbl. The ESP32 has a real time operating system. So it's possible to run grbl in the background. It needed a lot of modifications but in the end it's working.

Then we need to take a picture. That's easy. There is a library for that and it's working fine

So now we get a colored image. Not usable for etching. We can only etch (black) or not etch (white). We need a way to convert the colored image into a black and white image. One idea is to use an edge detection algorithm. But this doesn't look very pretty...

I found an algorithm called XDOG (eXtended difference-of-Gaussians compendium including advanced image stylization) this makes really good results. But it's a challenge to run this on a microcontroller.

To reduce development time I made a feasibility test in JavaScript. There I tried to implement XDOG with the limitations of the ESP32 in mind. This worked in the end and is somehow fast enough. I hosted the results here.

Next problem is we cannot stop etching and start somewhere else. So everything needs to be connected. The connection lines can look ugly. So we need a way to use as few and and as short lines as possible.

I also implemented a test algorithm in JavaScript to see if it's possible to do that. My best solution is still very slow O(n^4). If someone has a more efficient algorithm be my guest. With a lot of optimisations it is not too bad. But in worst case scenario it can take a while to process ....

Last step is to etch everything. This is not so hard to do. Just find the longest line to etch, etch it and search for the next on. Here we could also implement something more advanced. Like finding cycles and etch cycles. This may look better in the end result. But for me just simple lines work fine.

Etch A Sketch Version

There are a lot of different versions of the "Etch A Sketch" out there. So we need to measure its properties to order the right parts! You can order this on. The knobs have a distance of 190mm and a diameter of 6mm.

Step 0.1

Remove the knobs from the "Etch A Sketch". Mine were glued. So they were nearly impossible to remove. I used scissors and a lot of force to remove them.

Warning: Be careful. Don't hurt yourself. I assume no liability for any damage.

Nevertheless it's constructed in a way that you later can attach them again without gluing.

Step 0.2

Measure the distance between the knobs and its diameter. Depending on its values you have to order different parts.

PCB

To make the life easier for you I designed a PCB. It's used to mount the motors and all electronic components. So you do not need to do woodwork and wiring yourself.

The only problem is you have to order it. I can recommend JLCPCB (not sponsored) they are the cheapest for the dimensions used but you can use any other manufacturer. Just download the gerber files depending on your distance and send it to the manufacturer.

Tools

To assemble everything you need the following tools:

  • soldering iron
  • wire cutter
  • screwdriver cross and smale straight
  • smale hex key
  • some tweezers
  • USB to serial adapter (this one is recommended)
  • multimeter to measure voltages unter 20V
  • superglue

Order

I have some PCBs left to ship. But international shipping is expensive. So I was thinking if enough of you want to order a kit from me, I can make lager orders and so we all save on the shipping cost and I can get some coffee as well. I will not include the "Etch A Sketch" because it's expensive in europe :-(

Send me an email if you are interested: etchaselfie@im-pro.at but it can take up to one month to process.

UPDATES:

  • 29.10.2019: OLED Display needs to be a SSD1306 driven one => update links to buy the right one.

Supplies:

All together should be under 100$.

The build time is around 1 to 2 hours.

Step 1: DC-DC Converter

Step 1.1

Solder the DC jack onto the PCB top side.


Step 1.2

Use 4 pins from the pin row to solder the DC-DC converter to the PCB. This is the only component on the bottom side. Be careful to match the text "in" and "out" on the PCB with the DC-DC converter.

Step 2: DCDC Calibration

Plug in the power supply and measure the voltage between out- and out+ of the DC-DC converter.

Turn the potentiometer on the converter until you measure 5V.

Optionally you can use superglue to fix the potentiometer so that it's not possible to accidently change it.

Step 3: Resistors

Solder the resistors

  • R1 and R2: 4k7 (4700 Ohm)
  • R3: something between 1k and 100k or just use another 4k7

Step 4: Capacitor

Solder the capacitors. This step is optional. It's recommended from the stepper driver datasheet but it should work without it.

  • C1 and C2: 100µF 35V Capacitor E2,5-6

Be careful with the polarisation. The white strip must be on the opposite side of the plus symbol.

Step 5: ADC and Display

Step 5.1

Solder the ADC (ADS1115) onto the PCB.

Step 5.2

Solder the display onto the PCB.

Step 6: Joystick

Step 6.1

Remove the plastic cap from the joystick.

Step 6.2

The joystick comes with a pre installed 90 degree pin row. It's not the way we want it. So we need to desolder it. This can be hard to do... if you have problems check this out

Use 5 pins of the straight pin row to replace the old one.

Step 6.3

Solder it directly onto the PCB

Step 6.4

You can use some M3 screws, spacers and nuts to better mound the joystick to the PCB. This is optional and should work without it.

Step 7: ESP32

The thinker AI camera board is cheap and easy to get. But it's a little bit useless if you need IOs.
A lot of exposed pins are used for something else. But for example GPIO33 is not and only wired to an LED.
Also the reset pin is not accessible. If you want to program it you always have to reset it manually. This is annoying ...

Nevertheless we need at least 6 IOs. 4 for the stepper drivers and 2 for i2c bus. There is not enough unused IOs. So I had to use GPIO4. This port is also used for the flash LED.

Step 7.1

For that to work we have to remove two resistors on the ESP32 module otherwise the flash will just light all the time and the load on the port will stop the i2c bus from working.

The resistors in question are R12 and R13.
Just remove them with a wire cutter. Desoldering them can be hard because they are really small.

Just check after removing them that there are no shorts.

Step 7.2

Then solder the ESP32 module onto the PCB

Step 7.3

Glue the camera in place with a drop of superglue.

Step 8: MPU-6050 and Stepper Driver

Step 8.1

Solder the acceleration sensor (MPU-6050) onto the PCB.

Step 8.2

Solder the 2 stepper drivers onto the PCB. Be careful that the pin names on the PCB matches the names on the stepper drivers.

Step 9: Stepper Motors

Step 9.1

Cut the wires of the stepper motors at roughly 5 cm length. Then strip and twist them.

Step 9.2

Solder the wires directly onto the PCB:

  • 1A => red
  • 1B => green
  • 2A => yellow
  • 2B => blue

If your motor have different colors measure the resistance between every wire. There should be two pairs with a low resistance between them. Solder one pair to 1A and 1B and the other one to 2A and 2B

Step 9.3

Screw the motors onto the pcb.
The connectors have to face inside.

Optionally you can use cork to make the mounting more damped.

Step 10: Mounting

Step 10.1

Use the couplings to connect the stepper motors to the etch a Sketch.

Screw the worm screws tight.

Step 10.2

Add the cap of the joystick again.

Step 11: Stepper Current

The stepper drives both have a potentiometer to set the current for the stepper motors. Stepper motors need an idle current to hold their position.


Too much current and the motors get very hot and will die earlier. Not enough current and the motors will lose steps. So we need to make a compromise.


Turn the potentiometer with a little screw driver and test with your fingers how easy it is to turn the motor.
It should be hard to turn but also the motor should not get too hot. Take some time to adjust it. You will get a good feeling for it. Repeat the same process with the other motor.

If the current is too low you will later hear a rattle sound when the motors are turing and losing steps. Then you have to increase the current.

For me it was possible to find a setting that the motors just got hand warm.

Step 12: Firmware

Download the Sketch file from my github release page and extract it on your computer.

Arduino version 1.8.9 is recommended.

You need to install the board ESP32 version 1.0.2

You need to install the following libraries:

  • adafruit/Adafruit-GFX-Library 1.5.6
  • adafruit/Adafruit_SSD1306 1.3.0
  • tockn/MPU6050_tockn 1.5.2
  • adafruit/Adafruit_ADS1X15 1.0.1


Later versions should work but are not tested.

The following settings should be used:

  • Board => ESP32 Wrover Module
  • Upload Speed => 921600
  • Flash Frequency => 80MHz
  • Flash Mode => QIO
  • Partion Scheme => Huge APP (3Mb No OTA)
  • Core Debug Level=> None

Use a USB to Serial adapter.

The adapter I recommend can be plugged directly into the PCB. With some pressure a good connection can be assured. Be careful to use a 3.3V compatible serial adapter.

Make a connection on S1. This can be done with some tweezers.

Then plug in the the power supply and remove the connection on S1.
Now you should be able to program the esp32.

After you are done programming just unplug and replug the power supply and you are ready to go.

HAVE FUN!!!!

Step 13: Troubleshooting

If you have problems comment here and I will try to help you:

Troubleshooting

No troubles for now

Step 14: More Information

Sensors Contest

Grand Prize in the
Sensors Contest

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    12 Discussions

    0
    Pizzazzz8
    Pizzazzz8

    1 year ago

    sorry Patrick, was looking for libraries under the wrong menu, got all libraries and compiled with no missing libraries. :)

    0
    Pizzazzz8
    Pizzazzz8

    1 year ago

    Hi Patrick, I got adafruit/Adafruit_SSD1306 installed - now it is hanging on tockn/MPU6050_tockn 1.5.2
    your input would be appreciated - thanks

    0
    Pizzazzz8
    Pizzazzz8

    1 year ago on Step 14

    Hi Patrick,

    I am having troubles with your Sketch program - in your instruction you said to install the following Libraries:
    • adafruit/Adafruit-GFX-Library 1.5.6
    • adafruit/Adafruit_SSD1306 1.3.0
    • tockn/MPU6050_tockn 1.5.2
    • adafruit/Adafruit_ADS1X15 1.0.1
    I think I added them but when I try and compile Sketch I get the following error message - hopefully you can help me.

    Please help me get through this - Thanks, Donald
    **************************************************************
    Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "ESP32 Pico Kit, 921600, None"
    Build options changed, rebuilding all
    Sketch:9:30: error: Adafruit_SSD1306.h: No such file or directory
    Multiple libraries were found for "Adafruit_GFX.h"
    compilation terminated.
    Used: C:\Users\Donald\Documents\Arduino\libraries\Adafruit_GFX_Library
    Not used: C:\Users\Donald\Documents\Arduino\libraries\Adafruit-GFX-Library-master
    exit status 1
    Adafruit_SSD1306.h: No such file or directory
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    ****************************************************************

    0
    Pizzazzz8
    Pizzazzz8

    1 year ago

    Hi Patrick,
    "Yes!" I configured the power supply to output of 5v. I asked my wife to help turn the screw on potentiometer since you sort of need 3-hands (LOL) She said all concerned, "...am I going to get shocked?" Nah, as soon as she start to turn the screw I "Buzzzzzzz!" and she screamed, LOL - but I did configure the 5v as your design.

    Okay, I confess, I have never used the Arduino IDE, I got it downloaded with the required libraries and downloaded your "Sketch" files.
    I am done for the day and will attempt to load the firmware tomorrow.
    Below is a screen shot of the included libraries.

    Thanks!!

    BTW: I recommend that R1 and R2 be mounted on the backside of the PCB, this way the ESP32-CAM can be mount more flush on the PCB.

    /*
    Etch-a-Selfie
    Copyright (c) 2019 Patrick Knöbel
    */
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #include <MPU6050_tockn.h>
    #include <Adafruit_ADS1015.h>
    #include <esp_camera.h>
    #include <math.h>
    //we use GRBL as a library
    #include "src/grbl/grbl.h"
    #include "convert.h"
    #include "logo.h"

    Final.jpg
    0
    Pizzazzz8
    Pizzazzz8

    1 year ago

    1-Resisters R1 and R2 are in the way with
    ESP32-CAM – see picture
    2-The component called GRYO impedes with the LCD -
    my LCD is wider than the one you used on your project
    3-My LCD screen was cracked in the lower left hand
    corner - hopefully this will not be a problem – see picture
    4-My Stepper motor wires are the same colors-
    however, the green and yellow are in reverse order: see picture
    red
    yellow
    green
    blue
    5-I soldered the wires the same order/colors as
    your example. I hope this works correctly...? see picture
    6-I was having difficulty measuring the resistance
    – been a long time since I used my meter.



    I am going to stop for now until I get some
    feedback from Patrick regarding the stepper wires.

    Thanks again Patrick...

    resisters are in the way.jpgtightfit-1.jpgCracked LCD.jpgstepperwires.jpgfull view of project.jpg
    0
    im-pro
    im-pro

    Reply 1 year ago

    1- just used the space under the esp32 ;-)
    2- ok banggood is not so strict about changes to there parts ....
    3- you should be good as long there is no other damage
    4- ok just try . A wrong wiering should not damage anything ;-)
    5- yes this can be hard. But it will save you time otherwise there will be too many combinations to try ...

    The 5 Volt calibration worked?

    1
    Pizzazzz8
    Pizzazzz8

    1 year ago

    Hi, I love this project - just be aware when ordering PCB there is a 5-PCB limit; not sure if I'll be make 4 additional etch-a-selfies. When ordering from Banggood expect your parts to be delivered to the USA very slowly. But they finally arrived - I started soldering the components to the PCB this morning when I discovered the power supply has a different plug configuration :( I'll need to order a new power supply that has the correct configuration for USA.
    BTW: Patrick has been very cool answering my many questions - Thanks!

    power supply plug arrangement.jpgMy-Power Strip.jpgPCB-etch-a-selfie.jpg
    0
    im-pro
    im-pro

    Reply 1 year ago

    Thanks! And yes 5 is minimum but they are still cheaper than everyone else .... If you need it quicker use oshpark ;-)

    0
    im-pro
    im-pro

    Reply 1 year ago

    Thanks

    0
    OptimisticPessimist

    Really slick! I've never heard of this esp module, but it looks fun. I always wanted to do some projects with video, or even stills, but was always afraid of the learning curve. That, and with the prices not sure what to buy first.

    0
    im-pro
    im-pro

    Reply 1 year ago

    The esp8266 is really popular. The esp32 is it's follow-up. Yes the camera module is fun. But also very buggy ... Don't expect too much.