Monday 23 September 2024

 Time for another post.

A while ago I bought a new Oscilloscope, a RIGOL DHO914, but this scope doesn't have WiFi built in just a LAN connector on thre rear, luckily, as the Scope runs on Android someone has figured out how to get WiFi by using a TP-Link USB WiFi Dongle which, you can plug in the single USB port on the front of the scope.

I found this Youtube video explaining how to enable the WiFi using a plugin TP-link WiFi dongle.

Unfortunately it only has one USB port, you can plug in a WiFi dongle, mouse, keyboard or memory stick but only one at a time.

Now the problem is that I wanted to have the WiFi dongle and a mouse plugged in at the same time so I needed a USB gateway to do this but it's a bit ungainly so I thought I would have a go at making my own USB gateway that fits in with the layout of the scope (I know that they can be bought from Aliexpress for a couple of pounds but where's the fun in that!).  This will allow more than one thing to be  plugged in at the same time.

I found the FE1.1S chip that was a 4 port USB hub controller and JLCPCB had them in stock for $0.55 (£0.41) so I set about designing my own USB HUB.

JLCPCB Part Link

First Attempt


Two port hub

As usual I couldn't wait to get the design done and ordered from JLCPCB  but those eagle eyed amongst you will notice that this device gives me a problem for the DHO914 in that it blocks the Logic Analyser connection port, on the DHO800 series this would be fine as they don't have the Logic Analyser port but for me it will be a problem when I get the Logic Analyser option.

So on to design number 2....

Having proven out that I could make a working USB hub I decided to try and make a design that would better suit the DHO900 Series of scopes, this time I decided on a three port hub with the ports horizontal and below the Logic Analyser port.

Design Render
This design will plug into the single port and still allow the Logic Analyser to plug in although as of today I've not tried it with a Logic Analyser.

The design comprises two PCBs, one for the male USB plug and the other for the three USB sockets, they are connected together using some normal wires (ignore the PCB labels in the render as they are incorrect).  The cover holds the Male USB PCB in place and is screwed from the rear and sides to secure all the parts together.


With the front cover off



All the files including STLs and PCB gerbers etc. are available on Printables.com here.

Saturday 4 June 2022

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 controlling a couple of WiFi Switches for my TV and a Lamp.

Currently I'm using an aging 433MHz system which is slowly wearing out due to years of usage.

I realise there are many off the shelf solutions out there that I could buy and use but it wouldn't be as much fun as doing it myself although it would probably be alot quicker!

The basic principle of the supply circuit is that the LDO's enable pin is controlled by an OR gate, a positive trigger from one of the three switches fed via a diode, to stop the switch press affecting the other switches, triggers the output of OR gate which in turn enables the LDO and also switches the other OR gate High so the when the original trigger is removed the LDO remeaind enabled.

Power Supply and Triggering

Once the LDO is enabled it powers up the ESP and one of the first things done is for the output controlling the gate to be switched High to keep the gate's output from being switched off, once the code has finished it's job then the output is switched low which causes the OR gate's output to go low and turn off the power to the ESP.


The Buttons

The Buttons are connected individually to the inputs on the ESP and also connected all together via diodes to the Trigger input circuit.


The Schematic shows multiple buttons because I allowed for two types of button to be used, 6mm x 6mm pushbuttons or 12mm x 12mm pushbuttons, you can also use SMD tactile buttons soldered to the footprint of the 6mm buttons.

The ESP

The ESP connections are fairly standard with a Reset button and a Flash button.


Complete Circuit

Here is the overall schematic for the projecy, this one has the additional Pull downs, R15, 15 and 16 that I forgot to add on the first PCB design.

Get the KiCAD files from Github - https://github.com/gadjet/WiFiButtons


PCB

The initial PCB

Get the KiCAD files from Github - https://github.com/gadjet/WiFiButtons





The Mod to add the Pulldown resistors

Unfortunately I forgot to add some pulldown resistors on the original circuit (have been added on the later PCB layout.


The Transmitter Code

The following code sends an ESP-NOW message packet whenever a button is pressed comprising the Device ID, the MAC Address, the button pressed and the battery voltage.  Once the message has been sent the power is turned off by setting GPIO2 LOW.

Get the code from Github - https://github.com/gadjet/WiFiButtons


The Receiver Code

This Code takes the received data from the Transmitter and sends it to the Serial port.

Get the code from Github - https://github.com/gadjet/WiFiButtons

Quiescent Current Profile

The point of the trigger circuit is to reduce the standby current as much as possible so the battery will last as long as possible, this configuration consumes around 1.5uA in standby and an average of 60mA for around 200mS when a button is pressed.






Monday 28 March 2022

The many versions of the Wireles Door Sensor an Version 5

 

The Journey so far

I have to admit that it's become a bit of an obsession to try and get this sensor smaller and to use less power at each revision. well I've just finished version 5 which has definitely got the consumption down to a really low level, 3.9uA at its lowest.

Versions 1 to 4 in a row

....... and Version 5
Version 5 assembled PCB




Version 5 has two functions, the normal reed switch trigger so it can be used as a Window/Door sensor and a single button input so it can be used as a Doorbell switch or general WiFi button.

The trigger circuitry combines an edge triggered Monostable circuit from two XOR gates and a single OR gate latch circuit, this latch is triggered either by a pulse from the Monostable or the press of a button which sets the latch.
Once the latch has been set it can then be reset by a LOW signal from the ESP12 when the code has finished running on the ESP12, I used GPIO16 as it is held high during boot.

Schematic

Circuit diagram V5

Using the circuit above the quiescent current of the whole device when there is no magnet next to the reed switch, i.e. door open is 3.90uA and if you were using it as a WiFi connected button then that would be the Quiescent drain, if used as a door/Window sensor then when the magnet is next to the reed switch the quiescent is slightly higher at 5.4uA due to R1 drawing current when the reed switch is closed.

Battery Life

Actual Current consumption

Using a  Nordic Power Profiler Kit II I made some current measurements of the device in the different states: -
Current Consumption Graph


Using an online battery lifetime calculator I found here I calculated these battery times based on a usage of 10 activations per day: -
As you can see the worst consumption will give a battery life of more than 7 years! although this will only be an esitmate and in "real life" I assume there will be other factors that may impact on the battery life but only time will tell but I think you would have a good chance of getting a few years out of a relatively small cell.

The files are available on my Github page



Saturday 4 December 2021

Door/Window Sensor with an ESP8266

It's been a long time since my last post but I thought I would write up about my latest project - a door/window sensor using an ESP 8266.

I've bought a few door sensors in the past from Tuya and a Hive one (load of rubbish) but I came across a brilliant YouTube video from a gent called MakerMeik who used a logic toggle circuit to wake up the ESP from sleep mode when a reed switch is opened or closed (https://youtu.be/vxbuO1zWo3w).

Using the two XOR logic gates alowed both the door open and door closed to wake up the ESP by toggling the Enable pin whilst also passing the reed switch state to the ESP to publish.

Mike used the ESP to connect to the router via DHCP (or fixed IP) which took a few seconds to establish before then logging onto your MQTT server and publishing the door status.

So I downloaded Kicad and gave it a try, I had tried Kicad a few years ago and was a bit disappointed but the latest version was streets ahead of what I remembered and I soon had a PCB ready to send off for fabrication.

Bare PCB

Populated PCB

The PCBs were delivered and I assembled one which worked as expected (nice surprise) and while I was waiting for the PCBs to arrive back from PCBWay I exported the PCB design as a 3D model (STEP file) which I was able to import into Fusion360 and use as the basis for an enclosure.
Initially my idea was to use an 18650 Lithium cell as I had plenty that I'd reclaimed from old laptop batteries, which still had reasonable capacities, my idea was to use two halves that could be screwed together holding the PCB and battery, this could be screwed to a surface or stuck on with double sided adhesive tape.
 
 


The design is quite tall at 33mm but this is OK for my back door which is double glazed and the door is quite deep so the deep back places the reed switch nicely inline with the magnet on the door.
Printed enclosure

Having finished this version of the sensor I've been investigating ways to increase the battery life and reducing the overall size.

I found some smaller batteries that I could use with this design in conjunction with ESP-NOW code that uses alot less transmission time so I designed another rear half that is alot shallower for the new battery.



Smaller rear half for smaller battery

One tip I can give is to buy the plastic encapsulated reed switches instead of the normal glass ones as they are prone to breaking, even though I used surface mount pads to solder the switch rather than having to bend the wires to go through holes.


With my next version I will be trying out the PCB assembly service from JLCPCB so that I can utilise smaller SMD components and not have to solder them together myself!!

Some things I want to improve: -
  • Smaller size
  • Longer battery life and/or smaller battery
  • Add voltage divider to monitor actual battery voltage
  • Have a dual supply solution to use 1.5V AA cell with booster or single 3.6V Lipo cell without booster
  • Learn about ESP-NOW
There are plenty of clever people out there on YouTube with some great ideas around home automation and using the ESP8266 and ESP32 so time to watch some videos.

Gerbers, STL files etc. available from here https://1drv.ms/u/s!AkqVSEM4Y7kDhuZ0Lg1CdJrBs745Ug?e=ACkTkJ

The code for the device is available from MakerMeik's GIThub page, watch his video.

Version 2 coming soon .......




Sunday 14 May 2017

Hot water control using a Raspberry Pi Zero W


Following on from the first blog about the hot water heating control here's what I put together for the mounting.
Whilst looking for a suitable enclosure I came across an surface mount electrical socket back-box and I got to thinking "how can I mount the RPi W and relay in this?" so after some head scratching I thought about 3D printing some carriers to go inside the back-box.
The picture above shows two carriers printed to support the RPi and the relay board.

Then I made the required entry holes in the back-box for the power cable (USB), the mains switching cable for the relay and the temperature sensor cable.

This contraption has been sitting on my desk for a few weeks running quite happily and I've been checking the event log to make sure it's been switching on and off when it should.

Next to interface it to the existing wiring.

Saturday 11 March 2017

Hot water Remote Control using a Wemos D1 .... then a Raspberry Pi Zero W

For quite a while now I've been meaning to put together a project to control the Hot water heating remotely from my phone, I all ready have a 2nd generation Nest to control the heating but don't fancy spending the money for the 3rd generation just to add the water heating function.
I started with the plan to use a Wemos D1 Mini with a couple of the plug-in modules like a relay module, processor module and a button module all placed on the dual base PCB.


Button Module

Processor Module
Relay Module


Dual footprint Motherboard
For those of you not familiar with the Wemos D1 you have to be aware of which pins the different modules use because the relay module uses D1 which also happens to be used for one the I2C pins so if you wanted to use the I2C OLED display module it would clash.  I decided to re-wire my relay pin to use D6 (GPIO12) as this is the default pin that the Sonoff / arendst software uses for the relay anyway.

Once the parts were assembled and the software flashed (the button module happens to be the flash button as well)

The idea was to load some software written by a chap called arendst on Github this software allows you to control a relay via MQTT, usually used in WiFi controlled power sockets found at ITEAD but there's no reason why it can't be used on any ESP8266 to drive a relay and more importantly read a connected temperature sensor like a DHT22 or DS18B20.

I planned to control this from my Raspberry Pi 3 running Node Red, I would design a control layout using the Dashboard module, which serves up a webpage I can view on my phone/PC/tablet etc. inside my WiFi network.
Work in progress Dashboard UI in Node Red

 but could also be controlled outside my network using an MQTT app on my phone via the Cloudmqtt service using 4G data.

I also got hold of an Amazon DASH Button which I've configured using a node "node-dash-button", I've configured it so that pressing this button gives a 30 min boost to the Hot Water.

I tried several MQTT apps and found the one I liked the most was MQTT dash it let me create quite a nice interface.
Sample layout for MQTT Dash
Another one I liked was MQTT Dashboard because this has widgets that you can have on you phone desktop to switch something on or off  without opening the app first (Android only, I think).

So all was going well and starting to work when I saw that the lovely people that make the Raspberry Pis had just launched a new version of the Pi Zero, this time with WiFi and Bluetooth included and it was just under £10 .....Whoa! .... hold on a minute! under a tenner! .... I'm quite prepared to use a Pi Zero W instead of a Wemos D1 mini and shut it in the airing cupboard controlling the hot water.

The Pi Zero isn't very fast but I was certain it was plenty fast enough to control one relay and read the temperature using a DS18B20.

So I changed plans at this point a turned toward the Pi Zero W, if you want to use an ESP8266 then go over to Github and use arendst's code (I use it on 3 Sonoffs) and make it happen.

I will put together a blog entry for the Pi Zero W in a few days, I'm just sorting out the housing and wiring to put it in the airing cupboard.

As usual if there are any questions just ask them in the comments and I'll do my best to answer them.



Sunday 15 January 2017

DIY Chrono Mark II

Well it's been a long time since I started off this project and I've made a few changes along the way and a few people have had a go at making their own Chronos based on the entries in this blog, some followed the design and some incorporated elements of their own into the design to improve it.
Chrono Mark II Assembled
There were a couple of the things I wasn't keen on with my design: -
  • The fact that it was not a round tube but a teardrop and therefore may not always line up with the rifle and look a bit odd.
  • An external charger circuit was required to charge the internal battery.
  • The switch was mounted at the other end of the tube from the electronics and was a bit of a pain to wire up and assemble.
So along came the Mark II with the intention of improving on those issues.

The main reason for the teardrop design was to fit in the electronic modules with the central tube so I needed to come up with a design where I could place the modules and battery around the perimeter of the tube whilst keeping the overall diameter as small as possible.

I also wanted to add a charging circuit inside the tube so there was only one part to worry about so you could just plug it into a phone charger to charge it.  If I could get all this inside the tube, along with a switch located at the same end as the electronics then it would be a big improvement IMO.

First test was putting the modules around the tube .... using Tinkercad I messed around with all the modules trying to fit them in.


Having got them to all fit in a round base I set about figuring out the charging the battery and powering the Nano from the 3.6V battery as the IR receivers were specified to use 5V.

After a good Googling around for some modules I finally found some modules that fit the bill, one to convert 3.6V to 5V and another to charge a single lithium cell from 5V.  These module need to be pretty small and I wanted them to be on a single PCB to make wiring up the modules easy so I designed a PCB to mount them on and had the idea to attach the PCB to the switch which would be securely screwed in to the base.
Power PCB Circuit

Design layout
Final PCB
The outcome for this design means that when switched on the 3.6V battery is connected to the DC/DC converter supplying 5V to the Nano, BT module and the IR beams, when switched off the battery changes to the output of the single cell charger module, which gets it's 5V supply from the nano USB connector therefore charging the battery.  Also all the supply connections for the modules are also on the PCB making it easier to wire up when assembling.

Some More Images


 

Things you'll need
 Item Link  Cost 
 Pololu 5V Step-Up Voltage Regulator U3V12F5 Link  £3.32
 DD08CRMA Mini 5V 1A Lithium LiPo Charger Module eBay Link  £1.97
 Mini Miniature On/On 6 Pin Slide Switch DPDT eBay Search Link  ~£0.40 ea.
 Power PCB gerber files Link  £0.00
3D Print files for carrier and tube Link £0.00







 Time for another post. A while ago I bought a new Oscilloscope, a RIGOL DHO914, but this scope doesn't have WiFi built in just a LAN co...

Popular Posts