Pages

Friday, October 30, 2020

3D printed Anchor Hook

For an index to all my stories click this text

As you might know: I have a new 3D printer. And since I got it I have printed more as with my previous printers. I now own a Creality CR20 pro and it is a no hassle workhorse. Power it up and start printing. No calibration (except occasional bed levelling) and excellent print quality.

Then I saw an Anchor shaped clothes-hook on the internet. I thought it would be a nice surprise for a friend of mine who is a boat owner. However the pricetag just for downloading the STL file is a downer for me.

I just can not see why people make a very simple design and not offer it for free. The 3D printing world and Reprap world was once an open-source community and that is why I restarted my old hobby. Now loads of guys buy a cheap 3D printer and try making money with it. The hobby spirit is gone.

Well I am a tinkerer so I decided to make it myself.

First thing to do was to have a good look at the shape and start a search on the internet.
A quick search with Google immediately gave me a good image which was free downloadable from Pngimg.com



So I went to the website and there it was: http://pngimg.com/download/37294



I opened Gimp (a free open-source Photoshop clone) and editted the picture so it was pure black and white. You can do that by the "select by color" option. Select the black part, invert the selection and fill the rest with white.



Next I turned the picture at what I thought was the right angle.



Then I removed the right part of the picture and part of the crossection on the left side.



Last step was to add the bar which is going to be used to put it against the wall



Then I exported the picture as a JPG to my harddrive.

I was going to make the STL file in Tinkercad. Tinkercad however does not support JPG files so I had to convert the JPG to an SVG file that Tinkercad understands. You can do that with a public domain vector editing program like Inkscape. But I took the easy rad and used an web-oriented converter called: Convertio. You can find it on the web with this link: https://convertio.co/nl/

Converting just took a few seconds and then I could download the SVG file.

Next step: import the SVG into Tinkercad and scale it. I scaled it to a height of 15cm and a width of 10 cm



And the last step was to extrude the height to 2cm so you could put a screw in the bar.


And now I could export the STL file to my computer.
I sliced in the Creality slicer.



And here is a 50% reduced result. This printed in about 25 minutes. I amde several small ones and 2 large ones.



Actually this is technically not 3D but 2.5D. But whatever you want to call it, it worked out fine. Fun to do and my friend appreciated it. And that is the most important part.

So start designing and have fun. Till next time.


Luc Volders

Friday, October 9, 2020

Magic Wand

 For an index to all my stories click this text

Halloween is coming up and I wanted to build something to amaze friends and kids. So I decided to build a magic wand. But what should it do. I decided to make a magic wand that would set a lamp on or off.

Lots of lamps in my house are connected to my home automation system. This system is called Domoticz and is Open Source. You can install it on a Raspberry Pi like I did and that keeps the overall cost down. Check it out !!! You can find it here: https://www.domoticz.com/

The previous story showed how an ESP8266 could send a command to Domoticz to put a lamp on or off. I am going to use that to build my magic wand. Please re-read that story because some parts of this story lean on it. You can re-read that story here:
http://lucstechblog.blogspot.com/2020/01/sending-data-from-esp-to-domoticz.html

In that story I used a Wemos Mini D1 to send commands to Domotcz. However a Wemos Mini D1 is to large to build into a magic wand. So I am going to use an ESP-01 this time. And as usually it will be programmed in Arduino language.

The ESP01 has just a few IO ports. One of the ports has to be unconnected when starting up otherwise the ESP-01 will start in programming mode in stead of normal mode. So we have to find a clever way to use the scarce IO ports.

The next challenge was how to operate the magic wand.

The way I build it is this.
There is an on-off switch on the magic wand that is used to save battery life. The ESP-01 needs some time to connect to my router. And to be able to know wether the connection has succeeded I put a led on top of the magic wand. The led will light up when the connection is established.

The next step is to operate the magic wand. I used a tilt switch for that. It is called the SW520D. The way it operates is that there is a small ball inside the sensor. When the sensor is in upright position the ball shortens two contacts in the bottom. When the sensor is tilted the connection is broken. There are a few future projects coming up with this sensor.



The overal design is as follows.

The on-off switch puts the power on.
The magic wand is held upright. The tilt switch is reverse mounted so the contacts are broken as long as the magic wand is kept upright.  The ESP01 starts making a connection to the router. When the connection is established the led will go ON. Then we can lower the magic wand to a less then horzontal position and the SW520D sensor will make contact. This triggers the ESP-01 to send the command to Domoticz to set the lamp on. When the magic wand rizes again the connection in the SW520D is broken agian and then the ESP-01 will send a command to Domoticz to put the lamp off again.

I used GPIO-0 and GPIO-2 on the ESP for the sensor and the led. The problem is that it is best to have both IO pins not connected at booting, otherwise the ESP-01 will boot in programming mode. Therefore the SW520D is reverse mounted so there will be no contacts made at boot time. The led is also reversed connected. This means that the VCC pin is connected to VCC and the GND is connected to the GPIO-2.

Breadboard setup.



The GND and VCC pins are connected to the batteries. Do not forget to connect VCC to the CH-EN (enable pin) otherwise the ESP-01 will not start up.

GPIO-2 is connected with an 220Ohm delimiting resistor to the GND pin of the led. The VCC pin from the led is connected to VCC.
GPIO-0 is connected to the SW520D and the remaining connection on the sensor is connected to GND.

The power supply.

Well a magic wand can not be connected to a mains outlet. That certainly would look stupid. So it has to be battery operated. Testeing learned that I needed 3 AAA batteries to get good results. So I drew a custom battery pack in Tinkercad. It had to be small to keep the overall width of the magic wand narrow.





I started with a casing for 1 battery. Mulitplied it and made one long casing from this.

You can download my design from Tinkercad if you like. The STL file has to be sliced. I sliced it at 0.3mm which is accurate enough. It does not have to be pretty as it is going to be mounted inside the magic wand. here is the link.
https://www.tinkercad.com/things/7lT5xm1sNRq-3-aaa-bat

The contacts were made from paperclips. I did not print the holes for the contacts but just drilled them.

There are a few steps to go. First is the program.

Magic Wand program

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// WiFi settings
#define wifi_ssid "YOUR-ROUTERS-NAME"
#define wifi_password "ROUTERS PASSWORD"

// HTTP Domoticz settings
const char* host = "DOMOTICZ IP ADRESS";
const int   port = 8080;

int led = 2;  //GPIO1 TX
int sensor = 0; //GPIO2

HTTPClient http;

void setup() 
{
  pinMode(led, OUTPUT); 
  pinMode(sensor, INPUT_PULLUP);
  digitalWrite(led, HIGH);  // Led HIGH so starts off
  setup_wifi(); 
}


void switchonoff(){
      // Here is the Json format that Domoticz expects
      // /json.htm?type=command&param=switchlight&idx=99&switchcmd=On
      String url = "/json.htm?type=command&param=switchlight&idx=";
        url += String(3);
       if (digitalRead(sensor) == HIGH)
        {
        url += "&switchcmd=Off"; 
        }
        else   
        {
          url += "&switchcmd=On";
        }
      sendToDomoticz(url);
  }  


void loop() 
{
  switchonoff();
}

//Connect to wifi
void setup_wifi() {
  delay(10);
  WiFi.begin(wifi_ssid, wifi_password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  digitalWrite(led, LOW);
}

void sendToDomoticz(String url){
  http.begin(host,port,url);
  int httpCode = http.GET();
    if (httpCode) {
      if (httpCode == 200) {
        String payload = http.getString();
      }
    }
  http.end();
}

 

The code has a few pitfalls which I wil highlight.

// WiFi settings
#define wifi_ssid "YOUR-ROUTERS-NAME"
#define wifi_password "ROUTERS PASSWORD"

// HTTP Domoticz settings
const char* host = "DOMOTICZ IP ADRESS";
const int   port = 8080;


Fist thing is not to forget to put your own credentials here.

  pinMode(led, OUTPUT);
  pinMode(sensor, INPUT_PULLUP);
  digitalWrite(led, HIGH);  // Led HIGH so starts off


The pin for the LED is set as OUTPUT which is obvious but the pin is initially set HIGH. As the led is connected reverse the led will be off at the beginning.

void switchonoff(){
      // Here is the Json format that Domoticz expects
      // /json.htm?type=command&param=switchlight&idx=99&switchcmd=On
      String url = "/json.htm?type=command&param=switchlight&idx=";
        url += String(3);
       if (digitalRead(sensor) == HIGH)
        {
        url += "&switchcmd=Off";
        }
        else   
        {
          url += "&switchcmd=On";
        }
      sendToDomoticz(url);
  }


Here the string is created that will be send to Domoticz. The IDX which is the ID of the switch is dependend on your own system. In my case it is 3. The program tests wether the SW520 sensor is open or closed and puts the lamp accordingly on or off.

Detailed information on how to find the IP adress and the ID's of your switches can be found in the first part on sending commands to Domoticz which can be found here:
http://lucstechblog.blogspot.com/2020/01/sending-data-from-esp-to-domoticz.html

Stripboard

Well a breadboard is no good to hide your electronics in a magic wand. So I put it all on a small piece of stripboard.




I put headers on the stripboard to plug the ESP01 in. Do not forget to cut the connections between the headers so you do not short circuit the ESP's pins. As you can see I also cut some connections on the top of the breadboard otherwise the pins of the resistor would short circuit.

When I put the setup into the magic wand I did that upside down. The batteries are on the bottom the electronics on the top. That way the SW520D is upside down and does not make contact when the magic wand is held upright, just like we want.

Make sure you make the wires between the batterie holder and the electronics long enough to take the electronics out of your magic wand to replace the batteries.

The Magic wand

Luckily I found a carton tube at my job which was narrow but wide enough to put the electronics in. 


I printed a rounded top in which I put the led and used a push button as a power switch. As soon as I put the magic wand in my hand the pressure of my hand pushes the button and that powers the electronics. If I lay it down the pushbutton is released and the power is cut off.

Have fun !!!
Till Next time

Luc Volders






Friday, October 2, 2020

ESP32 Simplified world wide available

 For an index to all my stories click this text


Well it took a while but at last it happened. My book ESP32 Simplified is now available through Amazon and Barnes & Noble and your favorite local bookstore.

The big advantage is that it will save you on shipping costs. Often you even get free shipping.

So where can you get it internationally:

United States through Amazon: tinyurl.com/y24m9bk4 <==click to go there 

United States through Barnes & Noble <== click to go there

United Kingdom through Amazon  <== click to go there

France through Amazon <== click to go there

Germany through Amazon <== click to go there

Australia  through Amazon <== click to go there

If your country is not listed, try your local Amazon website.

You can also get it through my printer which also ships world-wide but that may be a bit more expensive: https://www.lulu.com/en/en/shop/luc-volders/esp32-simplified/paperback/product-5yr98e.html?page=1&pageSize=4

And of course through your local bookstore. 

348 pages in English with information on programming the ESP32 in Arduino language. Describing motion sensors, temperature sensor, tilt sensor, vibration sensor, neopixels, 7 segment display, oled screen, servo's, motors, relays, Thingspeak, IFTTT, webserver, etc.

Book is stuffed with schematics and programming examples 

De Nederlandse versie is verkrijgbaar via:

Boekenbestellen <== klik hier

Bol <== klik hier

En uw lokale boekhandel.

De Nederlandstalige versie is ook verkrijgbaar via:

Kiwi Electronics <== klik hier

Otronic <== klik hier