SMW3D OpenCNC

Check out my collection on Google Plus: https://plus.google.com/collection/ERlkgB for more details!

 

16 - 1 (1)

LaserWeb Version 2

laserweb2

LaserWeb 2.0 is ready for use!

See openhardwarecoza.github.io/LaserWeb2

New Design: Open Source Pick and Place Machine

My newest machine design!

Sticking to my usual folded sheetmetal methodology:

See https://github.com/openhardwarecoza/PickAndPlaceMachine

 

pickandplace.png

 

Big toys

In a follow up from https://openhardwarecoza.wordpress.com/2016/03/17/setting-up-an-electronics-lab/, here’s a list of the items that’s getting heavy on my wishlist these days (as production starts to ramp up and the projects get more complex)

Note I have not ordered any of these yet, but, the selected parts are all well researched and recommended by the independant repair community and makers alike:

  • Laser: The infamous K40, after conversion to Smoothieware, becomes a useful prototyping tool:

AliExpress.com Product – small 40W laser engraver carving machine 3020

  • Infrared Reflow Oven:  A hacked Toaster works, up to a point (;

AliExpress.com Product – 220V/110V Smart Reflow Oven Infrared IC Heater Soldering Machine 800 W 180 x 235 mm BGA SMD SMT Rework CE Certificate / T962

  • Hotplate: Not just for assembly but also for rework preheating

AliExpress.com Product – YIHUA 946A BGA Preheating Station

  • Heated Ultrasonic Cleaner
    I had the unheated model before and that didnt work to get flux off the board. Apparently I was supposed to get the heated model (;

AliExpress.com Product – Digital Heated Ultrasonic Cleaner Cleaning Machine 6L

  • Solder Paste Dispenser:  Currently use one of Magnum’s little manual models that look like a caulking gun.  Really a pain in the hand (literally)

AliExpress.com Product – YDL-983A Professional Precise Digital Auto Glue Dispenser Solder Paste Liquid Controller Dropper 220V Free Shipping

AliExpress.com Product – Free Shipping Mini CNC Milling Machine Router CNC 3040 Z-DQ 3 AXIS 220V 230W With Ball Screw

Setting up an Electronics Lab

Over the last few months I have been very fortunate and a lot of my readers / followers has clubbed together to buy me some much needed tools.   But it took quite a journey to figure out what was worth getting and what was not. Aliexpress / eBay can present as many duds as they can treasures.   Below is a curated list of the equipment I orders, and have now used for at least one month, and can vouch that I am quite happy with them (:

Hand Tools:

  • The lil’ blue side cutters:  I ended up buying another 3. These beat the $12/pair ones I got locally, hands down.  I’ve had one for over a year, still sharp as the day I bought it. Handles are of a hard plastic (I hate those soft touch rubbery materials that corode under exposure to skin oils, this one – much better than that)

AliExpress.com Product – Diagonal Pliers Electrical Wire Side Cutter Cutting Craft Repair Cut Tool Useful

  • Scalpel:  I can’t count the number of things I have used mine for! It really is indispensible, whether for plying prints of a bed, or trimming wiring, or enlarging PCB holes that you accidentally picked a wrong drill size for when ordering and you just have to make this prototype work!

AliExpress.com Product – 9 Blades Wood Carving Tools Fruit Food Craft Sculpture Engraving Knife Scalpel DIY Cutting Tool PCB Repair

  • Vernier:  Yeah, you get the fanboys of fancy verniers.  I don’t need one super fancy, but it is nice to not have to count lines on a ruler late at night with weary eyes.  This little $5 jobbie has served me very well over the past two years.

AliExpress.com Product – 150mm 6inch LCD Digital Electronic Carbon Fiber Vernier Caliper Gauge Micrometer free shipping

  • Gas Pencil:  Using the buddy’s lighter all the time gets them angry, and a normal cigarette lighter burns your thumb. No fun at all.  This little pencil style works a treat for all those jobs where you need fire (a.k.a detroying failed prototypes, evidence, etc lol)

AliExpress.com Product – Mini Gas Blow Torch Gun Soldering Solder Iron Cordless Welding Pen Burner Wholesale hot new

Soldering  stuff:

  • 868 Hot Air station – I worked with a $200+ magnum air pencil at my local hackerspace for a while, and this, to me, works better than the expensive ones.  I use it for all kinds of things from SMD rework, to assembly, heatskrinking to even just blowing some warm air over that darn DHT11 sensor that I am not sure if its picking up temperature changes or not…

AliExpress.com Product – ATTEN AT8586 Advanced digital hot Air Soldering Station, Rework Station, 750W, 2 in 1

  • AMTech No Clean Paste Flux – I learned about it from the local cellphone repair Pakistani, and he’s right, for the price it can’t be beat. Order 10 pack, you will go through it in no time! Even soldering connectors and wires together – with added flux – goes sooo much easier.  If you think you suck at soldering, get some flux and watch how your soldering starts to look pro in 0-6seconds.

AliExpress.com Product – Free Shipping BGA 10ml AMTECH RMA-223 RMA 223 BGA PCB Flux Paste No-Clean Solder / SMD Soldering Paste Flux Grease

Lab Equipment:

Time to go pro?

Decide now whether this hobby is sticking – the sooner you get these the easier starting out with electronics will be (making it more likely to stick anyway)

  • Lab PSU:  I waited way too long because of what people kept telling me. Get a linear. Get an expensive dual channel one. Get a $12 power supply PCB and build it yourself.   To all those, just NO. This little PSU has been used non stop since I unpacked it.   The DIY version never got a case so was never used due to the shock risk and pure lazyness (i want a PSU, not the pain of designing an enclosure) – don’t kid youself that you need a super fancy one either. Adjustable voltage, current limit and some displays. Thats ALL you need

AliExpress.com Product – New lw-K305D Mini Switching Regulated Adjustable DC Power Supply Single Channel 30V 5A Variable LW K305D

 

ESP8266 With PIR and DHT11

/*
 Basic ESP8266 MQTT example

 This sketch demonstrates the capabilities of the pubsub library in combination
 with the ESP8266 board/library.
m
 It connects to an MQTT server then:
  - publishes "hello world" to the topic "outTopic" every two seconds
  - subscribes to the topic "inTopic", printing out any messages
    it receives. NB - it assumes the received payloads are strings not binary
  - If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
    else switch it off

 It will reconnect to the server if the connection is lost using a blocking
 reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
 achieve the same result without blocking the main loop.

 To install the ESP8266 board, (using Arduino 1.6.4+):
  - Add the following 3rd party board manager under "File -> Preferences -> Additional Boards Manager URLs":
       http://arduino.esp8266.com/stable/package_esp8266com_index.json
  - Open the "Tools -> Board -> Board Manager" and click install for the ESP8266"
  - Select your ESP8266 in "Tools -> Board"

*/

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "DHT.h"

#define DHTPIN 13     // what digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);

// Update these with values suitable for your network.

const char* ssid = "openhardwarecoza";
const char* password = "novell1234";
const char* mqtt_server = "192.168.1.13";
int counter = 0;
int previousReading = LOW;



WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network18
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

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

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is acive low on the ESP-01)
  } else {
    digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
  }

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP8266Client")) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outTopic", "hello world");
      // ... and resubscribe
      client.subscribe("inTopic");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
  pinMode(12, INPUT);
  dht.begin();
}

void loop() {

    if (!client.connected()) {
      reconnect();
    }
    client.loop();

    long now = millis();
    if (now - lastMsg > 5000) {
      lastMsg = now;
      float h = dht.readHumidity();
      // Read temperature as Celsius (the default)
      float t = dht.readTemperature();
         
      // Check if any reads failed and exit early (to try again).
      if (isnan(h) || isnan(t)) {
        Serial.println("Failed to read from DHT sensor!");
        return;
      }
    
      // Compute heat index in Celsius (isFahreheit = false)
      //float hic = dht.computeHeatIndex(t, h, false);
      char t2[50];
      char h2[50];
      dtostrf(t, 5, 2, t2);
      dtostrf(h, 5, 2, h2);
      
      client.publish("/sensor/temp", t2 );  
      client.publish("/sensor/humidity", h2 );
    }

    int reading = digitalRead(12);

    Serial.println(reading);
    if (previousReading == LOW && reading == HIGH) {
    counter++;
    client.publish("/sensor/movement", "Motion!");  
    delay(1000);

    }
    previousReading = reading;

  
}

PIR sensor, ESP8266 and MQTT

MQTT

Install MQTT and start a test subscribe:

 

sudo apt-get install mosquitto mosquitto-clients
mosquitto_sub -t outTopic

Arduino/ESP8266 Sketch

 

On the ESP8266:  Install the following sketch using Arduino ( Note I won’t go into detail on setting up Arduino for ESP8266, lots of articles on the Internet already explain that)

NB: Do make sue you install the MQTT library: https://github.com/knolleary/pubsubclient

 

/*
 Basic ESP8266 MQTT example

 This sketch demonstrates the capabilities of the pubsub library in combination
 with the ESP8266 board/library.

 It connects to an MQTT server then:
  - publishes "hello world" to the topic "outTopic" every two seconds
  - subscribes to the topic "inTopic", printing out any messages
    it receives. NB - it assumes the received payloads are strings not binary
  - If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
    else switch it off

 It will reconnect to the server if the connection is lost using a blocking
 reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
 achieve the same result without blocking the main loop.

 To install the ESP8266 board, (using Arduino 1.6.4+):
  - Add the following 3rd party board manager under "File -> Preferences -> Additional Boards Manager URLs":
       http://arduino.esp8266.com/stable/package_esp8266com_index.json
  - Open the "Tools -> Board -> Board Manager" and click install for the ESP8266"
  - Select your ESP8266 in "Tools -> Board"

*/

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.

const char* ssid = "openhardwarecoza";
const char* password = "novell1234";
const char* mqtt_server = "192.168.1.13";
int counter = 0;
int previousReading = LOW;



WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

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

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(BUILTIN_LED, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is acive low on the ESP-01)
  } else {
    digitalWrite(BUILTIN_LED, HIGH);  // Turn the LED off by making the voltage HIGH
  }

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP8266Client")) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outTopic", "hello world");
      // ... and resubscribe
      client.subscribe("inTopic");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
  pinMode(12, INPUT);
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();
  int reading = digitalRead(12);
  Serial.println(reading);
  if (previousReading == LOW && reading == HIGH) {
    counter++;
    client.publish("outTopic", "Motion Detected");  
    Serial.print("Triggered ");
    Serial.print(counter);
    Serial.print("x Times! ");
    delay(1000);

  }
  previousReading = reading;

}

Wiring

Connect VCC on the IR Sensor to 5v (NB it has an onboard 3.3v regulator, so the output voltage is 3.3v (safe for ESP) but it needs to be powered off 5v!)
Connect Signal to pin 12 on the ESP8266 (or change the Arduino code to the pin where you wired it to)
Connect GND to GND

Order PIR Sensors?

AliExpress.com Product – 1pcs High Quality HC-SR501 Infrared PIR Motion Sensor Module For Arduino Raspberry pi

AliExpress.com Product – New HC-SR501 Adjust IR Pyroelectric Infrared PIR Motion Sensor Detector Module SG039-SZ

#include