Thursday, 19 May 2016

Updated PC software for the DIY Chrono (and Combro)

Just a quick update for anyone that has tried the PC software application for my DIY Chrono before, I've re-worked it a bit and changed the layout and moved the settings to a separate screen.

Also now I've fixed the Combro option not working so it should now report the correct values, if not please let me know as I don't own a Combro ..... the whole point in making my own.

Some Screen shots ...

Main screen interface
The main screen shows all the shot details in FPS and M/S along with a min FPS, max FPS and a Delta FPS.
On the right there is a list that adds each shot's data to a row so you can see the history.
At the bottom is a chart section that, if the checkbox is checked, shows the data graphically, there is a tab for FPS and one for energy.
You can also select the option to store the shot data to a file on the PC, the path is set automatically but you can type in your own.  The data is stored as a CSV file and can be opened by excel and used to create a graph.

Settings screen
The settings screen is self explanatory, I hope, change the settings and they are stored for next time, the pellet data etc. is stored in the CSV file as well.  If you have a Combro then tick the checkbox and the software should work for you as well
Here you can set the PC to make a noise
You can set the PC to give you an audible warning every 'n' shots, this is good for knowing when you fired your last shot and you're not looking at the screen, the other check box resets the shot count after the beep.

You can download the file from here unpack the rar file and run the setup to install.

Comments and feedback always welcome and if you like buy me a pint with the donate button.

Sunday, 15 May 2016

Chronograph - Another option

Latest project update for 2026 here


After printing the last model I ran out of the white filament and decided to give the black filament a try and was surprised to get a print that looks and feels a better print, I think it's an optical illusion though, black just seems to look better.

Anyway I decided to do another design of the enclosure one without the battery for those that just want to connect to their laptop via the USB cable and us the PC software from elsewhere in my blog.

This design is a bit smaller that the first as there is no battery, switch or charging cable, I did leave in the holder for the Bluetooth module so it can be used with the smartphone app but you will need to power it from one of those portable emergency batteries via a USB cable.

You can get the STL files from Thingiverse


I've also been making some changes to the Arduino sketch to improve the functionality, I've implemented the use of interrupts to trigger the measurements so that some other things can be done via the main loop like checking if the trigger beams are blocked.

Some other options may be possible like adding and SD card to store shot data internally and use you PC later to recover the shot data for analysis, If you use a long enough piece of aluminium you could add a thread to the end to fit you silencer to and just use you gun for the day and download the shot data later.

Monday, 9 May 2016

Chronograph completed - Finally

Latest project update for 2026 here


As anyone who's read this blog before will know, there's a common theme throughout, the DIY Chronograph I made for measuring the speed of an airgun pellet.

Well since getting a 3D printer I've finally managed to finish off the project and put it in a case, it's not often I actually put things in a nice case.

The first case with the Nokia display, it was a bit clunky and easy to break, when I dropped it that is!

Second attempt, this is the one I've been using.  This one uses the Bluetooth module to talk to an app on the phone here
Collection of bits held together with heatshrink
The final one, this one contains all the gubbins from the shot above inside the cover.
The end that screws on with the USB connector below and the front
view with the on/off switch and battery charge connector
Side View

This one uses the Bluetooth adapter and connects to an app on the phone and has an internal lithium Ion battery than can be recharged using an external supply and charging module, you can leave out the battery and use the USB connector of the Nano to power the chronograph from your laptop or a battery pack with a USB power output. (if you do this then the switch doesn't do anything)

The enclosure is essentially two parts, a carrier, that holds all the electronics and a slide on cover.
Both parts are a push fit onto the aluminium tube (16mm Dia. x approx 100m long)

Parts list: -

Item

Source

Approx. cost

3D printed enclosure - Thingiverse www.3dhubs.com
www.shapeways.com
£10 - £20
Arduino Nano (could be mini pro etc.) Ebay £2
Slide switch Ebay£2
Battery (Turnigy Nano-Tech 600mah 1S 3.7v 35-70C Lipo E-Flite) Ebay £5
Aluminium Tube - 16mm OD Ebay £5
Bluetooth Module Ebay £4
3V to 5V converter (NCP1402-3.3V STEP-UP BREAKOUT) Proto Pic £4
JST wired plug connector Ebay £3 for 10 off
IR Emitter x 2


Ebay
Farnell
RS Components


RS= £2.25, 5 off
IR Detector x 2 Ebay
Farnell
RS components
RS=£5, 5 off
Arduino SketchHere Free
Android App apk file (from Aptoide store) Here Free

So around £44 to put together, £24 'ish if you can 3D print your own enclosure.
You could also do away with the battery and 3 to 5V converter if you powered it from you laptop USB or battery with a USB socket on it.

More images

Battery and PCB modules in place with the tube

Barrel end showing the USB connector

Front end showing on/off switch fitted
Inside the cover

The Bluetooth module wired to the Nano

Nano and BT module in the carrier

Everything wired up... nearly. 3 to 5V converter top left under the battery
Tried and tested and working OK, the app works fine and I'm looking to add a graphing function so you can see the performance over a string of shots.

Fritzing schematic

As usual feel free to ask questions and comment below.

Monday, 21 March 2016

View Live data on your phone with Node-Red and Thingstud.io

Some time ago I came across a blog run by Pete Scargill (tech.scargill.net) which dealt with many tech gadgets to do with IOT and home automation.

There were a couple of subjects I found very interesting, Node Red and MQTT, these seemed to very useful tools to help develop home automation solutions.

Node Red turned out to be pivotal in my ability to glue everything together, there are so many different nodes that can be used to link into different services.

I'm running Node Red on my Raspberry Pi but it can also be installed on your PC and there is also a hosted installation of Node Red found here that allows to to try out an instance of node red without installing it on any platform at all, it runs in your browser and there is free account option.

The FRED Node Red runs even when your PC is switched off, there are some limitations around hardware inputs that would normally come from your PC like serial data and data from your OS, also you cannot install any of your own nodes.

Another important aspect of home automation was remote access to the data, whilst you are in your home on your own network this is not too difficult but when you are out and about and want to know what you hot water temperature is or if your central heating is on then it's a bit trickier, unless you expose your network to the outside world that is.

This is where cloud hosted MQTT servers came in for me, they allow me to send and receive data to and from the outside world easily and securely (at least I hope it's secure).

So to learn how to use the tools I set a goal to measure the hot water temperature in my storage tank and transmit an MQTT topic via WiFi and using Node Red to receive it and process it, if required before displaying it on my phone using Thingstud.io, the next step will be to have a button in the app to switch the hot water heating on/off manually and/or automatically switch it on from Node Red.

Step1 - Measure the hot water temp and send via an MQTT topic

For this I used and ESP-12 mounted on a development board I bought from AliExpress
There are also other boards that can be used
WeMos D1 Mini
Witty Cloud
The Fritzing circuit looks like this

In the Fritzing diagram above I've shown a battery for the supply but I actually use a 5V mains USB supply plugged into the USB connector and the DS18B20 Temperature sensor I used is the probe version so that the sensing part can be fed through the tank's insulation to touch the copper tank near to the top.

Before writing the sketch for the ESP-12 I tried out a couple of different MQTT providers: -
  • Mosquitto installed on my raspberry Pi
  • CloudMQTT.com private broker with password access.
  • HIVEMQ - free public access MQTT broker (no password)
I settled on Cloudmqtt using a free account but found that the app I created in Thingstud.io wouldn't work on my Android phone, I got in touch with the thingstud.io support and they were very helpful and said it worked on their Android phone and offered to help debug my phone to find out why but I didn't really want to spend the time trying to fix it so I tried the public server version of HIVEMQ and that worked great.

If you are new to MQTT then HIVEMQ have some really good introduction documents here that explain everything.

Before using the Arduino IDE to program your ESP12 you will need to add the details to your boards manager, details can be found here.

Then you can program your ESP with this sketch, don't forget to edit the SSID and passwords sections in the code to suit your network and mqtt broker.

This sketch uses the Cloudmqtt broker.

/*
 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 minutes
  - 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
- Read the temperature of a single DS18B20 device and publish it to the MQTT broker
- Read the battery supply voltage and publish it to the MQTT broker
 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.
 After publishing the data it will then go to sleep for nnn seconds  (set nnn in the int interval)
 For the ESP-12 to wake up after the nnn interval you will need to connect D0 to the reset pin
 or if supplied from a mains adapter you can remove the sleep command altogether.
 I have also commented out the code that switches on the LED.
 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 "onewire.h"
#include "dallastemperature.h"
#include "pubsubclient.h"

// Update these with values suitable for your network.
const char* ssid = "#######";
const char* password = "#######";
const char* mqtt_server = "m20.cloudmqtt.com";
const char* mqttUser = "#######";
const char* mqttPass = "#######";
float temp; //store temperature value
float BattLevel; //Store Battery voltage
int interval = 120;//Interval between messages in seconds
char msg[50];

ADC_MODE(ADC_VCC);//Set the ADCC to read supply voltage.

WiFiClient espClient;
PubSubClient client(espClient);
#define ONE_WIRE_BUS 2  // DS18B20 pin (D4)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

void setup() {
  Serial.begin(115200);
  setup_wifi();
  delay(5000);
  client.setServer(mqtt_server, 10388);
  client.setCallback(callback);
}

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(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(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",mqttUser, mqttPass)) {
      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 loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
  //Read Temperature from DS18B20
  DS18B20.requestTemperatures();
  temp = DS18B20.getTempCByIndex(0);
  //Read supply voltage
   BattLevel= ESP.getVcc();
  /*Print Temp and Battery level [optional]
  Serial.print("Temperature: ");
  Serial.println(temp);
  Serial.print("Supply Voltage: ");
  Serial.println(BattLevel);  
  delay(200);
  */
  //Publish Data to MQTT
  dtostrf(temp, 4, 2, msg); //Convert float to string
  client.publish("Temperatures/HotWater/Temp", msg, true);
  Serial.print("Published message Temp: ");
  Serial.println(msg);
  dtostrf(BattLevel, 3, 1, msg); //Convert float to string
  client.publish("Temperatures/HotWater/Battery", msg, true);
  Serial.print("Published message Batt Level: ");
  Serial.println(msg);

  //Disconnect from WiFi before sleep
  client.disconnect();
  WiFi.disconnect();
  delay(100);

  Serial.print("Entering deep sleep for ");
  Serial.print(interval/60);
  Serial.println(" Minutes");
  ESP.deepSleep(interval * 1000000, WAKE_RF_DEFAULT);
  //ESP.deepSleep(10 * 1000, WAKE_NO_RFCAL);
  delay(500);   // wait for deep sleep to happen
}
To test the sketch you can use the Websocket UI in the Control panel
In the next part I'll go through setting up Thingstud.io to display the data on your phone.

Friday, 18 March 2016

Wireless Battery

Over the years I've made a few projects all centred around the Arduino, in its many forms and more recently I've started to use the very useful ESP8266 device, both of these are happy to run on 3.3V (ESP8266 should be 3.3V).

As I use batteries to power the various project around the house and garden I've accumulated a number of different batteries, mainly Lithium Ion ones at 3.7V.
I use some 18650 cells from an old laptop battery that comprise two cells wired in parallel and some mobile phone type batteries that are thin and light.
Two 18650 cells in parallel housed in a 3D printed case

Galaxy S4 QI Charge pad
I'm continually charging these batteries up and running them down and I had an idea the other day when I came across an old QI charge receiver I had used in a Samsung S4 to wirelessly charge the phone.

I wondered if I could connect the output to a lithium Ion battery charger PCB,  from China and stick the pad onto a battery, this would allow me to just place the battery on a QI pad to charge it up and even place the device using the battery on the pad to keep it powered/charging.






It was quite simple to remove the USB socket from the PCB and solder to the charge pad and connect to the battery.


The battery, charge pad connected to the charger PCB

The QI pad folded around the battery

After that I used some heat shrink tubing used for battery packs to hold it all together.
Whole assembly going into the shrink tubing
The final package can then be used to power the project.


The next step is to 3D print a new case for the two 16850 cells to include the charge pad and PCB and look at using a 5V supercap and charge pad to power my temperature monitor project.

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...

New Accessories for the AirChrony S3

With the increasing abilities of AI it has become so much easier to take an idea to a finished, working item in a really short time. I was t...

Popular Posts