Thursday 28 January 2016

3D printed bezel for the Nextion LCD display

Prompted by a post on another blog I read I dug out the 2.4" Nextion LCD display and thought I'd give it another go and whilst looking around the Nextion website I found that they'd designed some 3D bezels for the different size displays they do.
Well, as I got a 3D printer at Christmas I thought I would print one out for my display.




The result wasn't too bad. I think the bezel had been designed with some fancy curves on the front edges and because I printed it face down they had quite pronounced bits of filament that had to be removed, I think I will modify the bezel in Tinkercad to make the face flat.
I tried to sand the face a little smoother but the PLA became slightly discoloured from the glasspaper I used.

The rear was quite good with some strengthening ribs included and I found some small screws that made a tight fit and held in the display.

Next step is to make a backing box for the bezel to fit into but I'm waiting until I finalise the design of the project so I know what depth I need in the case.
I got a quote from Shapeways 3D printing service to print this design and it was £7.65 plus postage, although the quality would be better than from my printer I'm quite happy with the quality and I suppose I could also paint it to get a better finish, I'd better google "painting PLA".

Monday 11 January 2016

3D Printer Pushbullet Notification

I recently bought a 3D printer XYZ Dzvinci Jr.), mainly because it was £100 off at Ebuyer, and I've been printing loads of stuff from Thingiverse and designing some of my own stuff using www.tinkercad.com.

One of the things you soon notice is how long it takes to print a design, it can take hours for a large design and as the printer is upstairs and I was constantly going up and down stairs seeing if it had finished yet.

So I thought I'd use some electronics to send a notification when it had finished.  I decided to use an ESP8266 to connect to my network and send a Pushbullet notification which I will receive on my phone and also my PC, through a Chrome add-on.

I noticed that after the printer had finished the table moved right to the front of the printer and I thought to use a micro-switch that would be triggered by the table when it moved to the front.
As luck would have it I had the perfect switch in my box of bits and I was able to mount it using two screws and two Tee-Nuts into the existing aluminium profile frame of the printer.

Test setup running off batteries through the micro-switch
I found an Arduino sketch that sends a Pushbullet notification on the ESP8266.com forum, this sketch makes an HTTPS connection to Pushbullet and sends a text note, the code is all in the setup section of the sketch and only runs once, this was actually just what I wanted as I was going to use the micro-switch to power up the ESP8266 rather that use it as a button input.

The hardware I used was a development ESP board from ALiExpress they are less than $3 each and come in two parts, one being the USB/serial interface and the other the actual ESP board.
I use the RGB LED on the board to show the progress of the connection
  • Red = Waiting to connect to your WiFi router.
  • Green indicates a successful connection.
  • Blue LED to show the Pushbullet notification was sent.

You can probably use this sketch with any of the ESP8266 variants and if you don't want the status LED then you could use a bare ESP-12 or even an ESP-01.

After the notification is sent I've tried to put the ESP to sleep to reduce the drain on the batteries but I'm getting some funny results so far, the current does reduce significantly but not as much as I would expect, more work required...
I expect to be home when a print finishes so the battery drain isn't too much of an issue and I think I'll look at taking power from the printer itself once I make the install more permanent.

I also thought that this could be used for all sorts of things like security monitoring etc. the message could be triggered from an input connected to a magnetic switch or a PIR possibly or connected into an existing security system to give you a notification on your mobile when triggered if I can get the power usage down it would make a good portable warning system.  Although I used Pushbullet because it's a convenient way to get in and out of your home network without exposing it, you could use other cloud solutions or just use it internally with Node-Red on a Raspberry Pi ?? 

Sketch
#include esp8266wifi.h
#include wificlientsecure.h
/*
 This Sketch posts a text message to you phone via Pushbullet indicating that my 3D Printer
 has finished printing, the message is triggered whenever the ESP8266 is powered up.
 The code runs in the setup not the loop so it will only run the once.
 The source for this code was found on www.esp8266.com forum under example sketches and was
 posted by DedeHai.
 The code uses an RGB LED on three outputs to indicate the status of the message:
 RED = Not connected to the WiFi
 Green = Connected to router
 Blue = Pushbullet note sent.
*/
const char* ssid = "*******"; //Your WiFi SSID
const char* password = "**********"; //Your WiFi password
const char* host = "api.pushbullet.com";
const int httpsPort = 443;
const char* PushBulletAPIKEY = "****************************"; //get it from your pushbullet account
const int REDLED = 15; //LED Pins
const int GREENLED = 12;
const int BLUELED = 13;
long t = 0; // timer count
// Use web browser to view and copy
// SHA1 fingerprint of the certificate
const char* fingerprint = "2C BC 06 10 0A E0 6E B0 9E 60 E5 96 BA 72 C5 63 93 23 54 B3"; //got it using https://www.grc.com/fingerprints.htm
WiFiClientSecure client;
void setup() {
  pinMode(GREENLED, OUTPUT);
  pinMode(BLUELED, OUTPUT);
  pinMode(REDLED, OUTPUT);
  analogWrite(REDLED, 100);//No wifi connection
  analogWrite(GREENLED, 0);//No wifi connection
  analogWrite(BLUELED, 0);//No wifi connection
  Serial.begin(115200);
  Serial.println();
  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  analogWrite(REDLED, 0);// wifi connection
  analogWrite(GREENLED, 50);//wifi connection

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // Use WiFiClientSecure class to create TLS connection

  Serial.print("connecting to ");
  Serial.println(host);
  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }
  if (client.verify(fingerprint, host)) {
    Serial.println("certificate matches");
  } else {
    Serial.println("certificate doesn't match");
  }
  String url = "/v2/pushes";
  String messagebody = "{\"type\": \"note\", \"title\": \"3D Printer\", \"body\": \"3D Print Finished\"}\r\n";
  Serial.print("requesting URL: ");
  Serial.println(url);
  client.print(String("POST ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Authorization: Bearer " + PushBulletAPIKEY + "\r\n" +
               "Content-Type: application/json\r\n" +
               "Content-Length: " +
               String(messagebody.length()) + "\r\n\r\n");
  client.print(messagebody);
  Serial.println("request sent");
  //print the response
  while (client.available() == 0);
  while (client.available()) {
    String line = client.readStringUntil('\n');
    Serial.println(line);
    analogWrite(GREENLED, 0);//Message answer recieved
    analogWrite(BLUELED, 100);//Message answer recieved
    t = millis();
    while (millis() <= t + 1000);
    yield();
    analogWrite(BLUELED, 0);//Message answer recieved
  }
ESP.deepSleep(60000000);
}
void loop() {
}
More on the 3D printer later...

Three button WiFi Remote

Using the power control circuit from the Wirelesse door/Window sensor I have designed a simple 3 button WiFi remote with the intention of co...

Popular Posts