sobota, 22 października 2016

How to go wireless with Mastech MS8340A

Reason

Have you ever dreamed about cheap multimeter with bluetooth? And how it is possible that so many chineese cheap multimeter manufacturers are unable to pus $2 worth of bluetooth hardware inside? I just simply cannot understand this lack of feature... Several weeks ago I managed to buy cheap second hand MS8340A:
This is crappy multimeter however with secret feature: can do UART just OOTB. Press and hold REL button for 2 seconds and magically "RS232" wil popup on display. Magic.

Inside

Since there is no warranty, let's open it and see what hardware we have:
A-ha! FS9922-DMM4. This chip has in fact simple UART capability. And good news is that some multimeter sofware already supports it. So there is hope that by using some kind of cheap bluetooth hardware we can get some data. BTW this multimeter is kind of poor at input protection so I do not recommend it for mains. However it has quite fine resolution for the price so it seems to be usefull anyway.

$2

There are many sellers on aliexpress that do sell HC-05 bluetooth module. This module has crap documentation and design, however seems to work just fine on many Arduino projects, stable enough to convert multimeter into data logger.
This simple transmitter can be configured to use any name, pin and baudrate. It is kind of suprising that it cannot be configured (at least for baudrate) from connected operating system. You have to configure it first to one desired speed before use. So, we have to do some magic before we can use this in multimeter. We need 2400 baud and set some name for bluetooth device. First let's build setup wiring.
Now we need some kind of USB<->3.3V UART converter. There are many on aliexpress/ebay however I'm using and old Nokia data cable for $0.5 that already does 3.3V conversion. Please notice that HC-05 might or might not survive 5V on inputs. I prefer not to use 5V converters.
Nokia connector was cut off and all we got are Tx,Rx and GND. Now about how to connect to HC-05. In documentation of this module You will find proper way to power it up in setup mode. Look at KEY (pin 34) and connect it to the 3.3V rail. This will put HC-05 into setup mode where You can talk at 38400bps directly from any terminal. So, connect 3.3V, GND. Pull pin 34 high. Connect Rx,Tx to Your USB<->UART converter. Run termonal software (I used GtkTerm, however seems that Putty also works) and enable local echo. Now the magic: AT+ROLE=0 AT+UART=2400,0,0 AT+NAME=MS8340A After every command there shuld be acknowledge "OK" from module. If You have any problems with talking to HC-05 first, disconnect converters Rx,Tx from module and connect them together. There should be doubled letters (due to local echo + loopback character).

Searching for power

We need 3.0V at least to power up HC-05. And, be reading documentation we can leant that current consumption can be as high as 80mA. This is really big deal and we cannot use just any 3.3V rail because it can create some kind of measure error in internal circuit of meter. However after close inspection of pcb we can se that there is SMD linear regulator as U2 with markings: N301 ONB3Z, near negative bettery spring connector.
I was unable to find any info on that, however seems that is gives at least stable 3V at 100mA. So it should be just enough. Please notice that GND connector of this rgulator is NOT directly connected to battery, there is small signal diode so we expect 0.6V difference between bat- and GDN. It is a bit too high for HC-05. So I decided to connect directly to regulator. By looking on traces we can find missing compoment C15B that is near top edge of PCB and both connectors are direcly wired to regulator. Perfect place to add our wiring:

Data stream

Now we need to connect data output line from main chip. Single wire have to be soldered to pin number 92. To make it possible use good flux. Since this is probably lead-free we have to use trick first: put flux on pins, use soldering iron only to apply just a bit lead-tin on pins. This will allow to solder wire in next step. Soldering it directly to lead-free covered pins is almost impossible. After about 3 tries I got it right:

Saving power

We cannot directly connect HC-05 to 3.0V rail. It will drain our batteries in no time. Instead lets find a way to power it up if data stream is enabled. There is special line for this on FS9922 called TXEN that can be used to control HC-05 enable/disable. I could use it but decided not to. Simple because You will find this hack usefull in other devices that do not have such control line. So, to make this hack more usefull: lets use only data line to enable/disable power to HC-05. This is tricky. Data line goes high if nothing is transmitted and while feature is disabled. Line goes low just for single 0 bits transmitted. We can enable bluetooth at any time because it is easy to resync even if we enable power in the middle of transmission. Also, we should disable power after several seconds if no transmission is detected. And let's do it in old-school way.
IC1A is used to charge capacitor via low resistance (1k). Charging is possible only if transmission line is in low state. So, every time CPU is sending '0' we will charge capacitor just a bit. Diode is needed to disallow discharge via 1k resistor. After several 0's voltage on capacitor will be high enough to trigger high state on IC1B and IC1D. D will power up HC-05 via PNP transistor, while IC1B will allow data line to pass into bluetooth module. We need this trick because we should not send any data to bluetooth module if power is not enabled. 1M resistor is used as slow discharge of capacitor that will eventually disable bluetooth after several seconds if no 0's are visible on data line. Lets build a prototype:
It works! Meter will enable bluetooth after 2s pressing REL button and disable it after another 2sREL. But hey, did we break anything? Does still shows what it supposed to do? Well, answer is: probably everything works just fine. I've got exactly the same values with bluetooth and without it on all ranges and sources I've checked. There is no visible change on meter behaviour. Just works as expected.

Shrink

It should be possible to do a single-sided pcb with smd components. I did not have much time to play around with layout, so simple auto router from Eagle did smoething that look bad, but works. Who cares?
Looks ugly after soldering but again: who cares?

Putting it all together

Just connected bluetooth module to connector already glued on meter's pcb:
Everything seems to works just right. And now I have wireless multimeter for just $2 and about 4 hours of working including hand made pcb. Not a bad deal.

Brak komentarzy:

Prześlij komentarz