ESPHome TopGreener setup

The TGWF115PRM can be used with ESPHome – the process I used may be somewhat convoluted, but I can confirm it works well and accurately shows power consumption (Watts) through measurement of voltage and current.

Example display in HomeAssistant dashboard

[A note for future readers]

This was written in December 2021. I probably won’t update this in the future – so if you’re reading this sometime far in the future, you may want to look for a newer guide!

Step One

Plug in the device and use Tuya-Convert to load tasmota-lite.bin (see Tuya docs at that link)

Step Two

Make an ESPHome binary (or use mine)

I have the ESPHome integration installed on my Home Assistant server. Select the ESPHome button in the left-side panel in Home Assistant:

Then click on the “Add new device” button, the green circle:

You should name it something useful but short, and you can put in your WiFi info.


The TopGreener smart plug is an ESP8266 device.

Click “EDIT” to change the configuration for your new ESPHome device.

Copy and paste the following configuration into the text window. Makes sure you don’t have duplicate data which was automatically generated. For example you can’t have two esphome, logger, api, ota, or wifi sections. Should be pretty obvious.

  name: splug
  platform: ESP8266
  board: esp01_1m

# Enable logging

# Enable Home Assistant API

  password: "ota_pass"

  ssid: "netgear"
  password: "notmypassword"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Splug Fallback"
    password: "somepw"

  - platform: gpio
    name: "Smartplug Relay"
    pin: GPIO14
    id: relay
  - platform: gpio
    name: "Smartplug Button"
    pin: GPIO03
    - invert:
          min_length: 50ms
          max_length: 350ms
            - switch.toggle: relay
      number: GPIO01
      inverted: true
#      number: GPIO13
#      inverted: true

  - platform: hlw8012
    sel_pin: GPIO12
    cf_pin: GPIO04
    cf1_pin: GPIO05
      name: "Smartplug Current"
      name: "Smartplug Voltage"
      name: "Smartplug Power"
      name: "Smartplug Energy"
    update_interval: 15s
    voltage_divider: 14850
    current_resistor: .0127


Change the details highlighted with red text to the appropriate values.

Step Three

Select “INSTALL”

Then select “Manual Download”
Download the .bin file and save it somewhere safe.

Connect your Tasmota device to your WiFi

But first — You have to now connect to the Tasmota backup hotspot that shows up when you plug in the smart plug and tell it to connect to your wifi router. Open up your phone or laptop and connect to the WiFi AP which shows up as something like: “tasmota-xxxxx

Open up your web browser and you should find a page that has fields such as:

Input your home WiFi AP password and SSID under “AP1”. You can leave the other fields as they are. Click “Save”

Then I had to login to my LAN router to see what IP address was assigned to the new tasmota-0688 device. Unfortunately I wasn’t able to navigate to the device in Firefox. I suspect Tasmota isn’t using mDNS (though my build was a year old — apparently Tasmota has mDNS support now)

So if you have a newer build of Tasmota on your device you can try to navigate to the Tasmota device setup page by going to the url: http://tasmota-nnnn.local/ of course the “nnnn” refers to the ID which is automatically generated. My device in this example gave itself an ID of 0688, so I would attempt to go to http://tasmota-0688.local/ to get to the setup page.

This is from my router’s DHCP info. I had to go here because Tasmota didn’t support mDNS.

BUT anyway I had to login to my router to get the IP address, so I went to (for example): http://192.168.60/

If your browser forces you to go to https then you’ll have to figure out how to turn that off because it will fail.

Upload the bin file to the smart plug

Last step! When you get to the Tasmota setup page, select Firmware Upgrade

Find the .bin file you created earlier from HomeAssistant and upload it to your smart plug device.

You can close that tab, you won’t see that page again.

If this was successful, your ESPHome device should be detected in Home Assistant:

Click “Check it out”:


Select an area to add it to, then FINISH

Back in the Home Assistant Overview page, we see our new device:

A note on Calibration

The ESPHome configuration has two constants for voltage/current calibration. I chose these numbers based on my own measurements and devices. They may be accurate for you, but if not, do not despair. If you attach a known load, such as a 100W incandescent bulb, you can use change these values to fairly accurately reflect the load. If you have a decent way to measure the AC current and AC line voltage, you can do that too.

voltage_divider: 14850
current_resistor: .0127

The “Smartplug2 Voltage” value shows an odd value, 10.5 V, because the Relay is turned off. When we turn it on, with a load, it shows up with the correct value of 117 V

The first step to calibrate the device would be to measure the actual AC line voltage. If I measured 118.2 V I could change the voltage_divider value by multiplying it by the ratio of new/old:

voltage_divider = 14850 * 118.2 / 117.0 = 15002

The same procedure applies to the current_resistor value, except that increasing the current_resistor value will LOWER the measured current, and vice versa. Therefore you have to invert the ratio. If the measured current was 0.36 A then you would set:

current_resistor = 0.0127 * 0.35 / 0.36


I hope this was useful in all or part. I realize going from tuya-convert to Tasmota to ESPHome is not direct, but it happens to be the way I did it for this.


Tasmota TGWF115PRM configuration

Tasmota Documentation


Altium libraries – capacitors and resistors

I generated several libraries for Altium (or Circuit Studio) using Database Libraries which I then exported to IntLibs.

I realize you can get many of these parts from Altium or other third parties. I wanted to figure out on my own how I could scrape data from Digi-Key and (almost) automatically create part libraries.

Altium Designer has a powerful feature called Database Libraries which take an external database and link entries to a schematic symbol and physical footprint. The database can take many forms such as an Excel spreadsheet, Microsoft Access database, or in theory any SQL or ODBC source.

I’ll start here by giving you the libraries I generated and I’ll make another post about how I generated them.

INTLIBs (for Altium or Circuit Studio):

Panasonic ERJ resistors libraries download

Murata capacitors libraries download

DBLIBs (for Altium only):

Panasonic ERJ resistors Altium DBLIB

Murata capacitors Altium DBLIB


There are 6,029 resistors, all are Panasonic ERJ series. The resistors are split up into 6 different IntLibs according to package size: 0201, 0402, 0603, 0805, 1206, 2512. I scraped the data from Digi-Key to create these libraries and thus they contain a significant number of parameters that you can use for your BOM generation.

The capacitor libraries are similar. There are 4,739 capacitors in 6 different libraries split up according to package size: 0201, 0402, 0603, 0805, 1206, 1210. They all contain similar parameters as the resistors. All capacitors are Murata – because it was easier to scrape one manufacturer without getting thousands of duplicate value parts.


Altium Circuit Studio review part 1

I was given a license of Altium CircuitStudio in exchange for my opinion. I’d like to think I’m not biased, but the fact is that I was given free stuff. So I’m going to present facts in the hope that you’ll find it useful. You should use your own judgement where applicable.

I did not agree to, nor was I asked to provide positive feedback about any product in exchange for goods.

Altium Circuit Studio review Part 1

I will try to answer questions related to how an individual would value Circuit Studio vs. Altium Designer in their small-shop business.

First I want to give you an idea of my experience so you know where I’m coming from.

I started using EDA software in 2001 with Eagle, then made by cadsoft. Actually I started a little earlier by using Protel EasyTrax when there was a free version of that. But I had no idea what I was doing then. I was pretty young.

I used Eagle up until around 2012 when I was designing a VME board for a real-time control system. It was the largest and most complicated PCB I had ever designed. Eagle simply could not do it. It became bogged down. Routing traces was an absolute mess because it was so slow it would crash. The manual router had no online intelligence of design rules so you had to guess about where you were placing traces and cross your fingers when running the DRC check. It was OK for small boards, but I had moved in scope and complexity. I was designing boards with high speed buses and controlled impedance.

VME board designed in Eagle 6.
VME board designed in Eagle 6. Do you like pain?

I was able to get my employer to pony-up for a license of Altium Designer after significant research and watching how-to videos on YouTube.

I use Altium to this day at my current day job. They have a single license of Altium but for “official” designs I have to use Mentor Graphics DxDesigner.


Enough of that for now. Let’s get on with it.


Installation and first impressions


[ any image can be clicked to view a larger version ]

CircuitStudio has an installer downloader – 8 MB initial download. Full install is around 530 MB. I didn’t have any trouble downloading the installer. I am not sure if you can acquire a standalone download of the software.

Installation went along without a hitch. I have to say – at least Altium has figured out installers. If you’ve installed Dassault or Autodesk or Mentor Graphics software lately you might realize how wrongly it can work out.

Schematic Editor


The color scheme for CircuitStudio is a little different than Altium. Altium is heavy on the yellows and CircuitStudio has a much larger panel with logos. Here they are next to each other:




Circuit studio is new and flashy looking, but who cares? DxDesigner looks like it was designed in 1995 and it still works fine.

I’m starting to get the feeling at this point that Altium is going to be less frustrating for the professional CAD types out there. I don’t look at the toolbar when I’m using Altium, after all, I’ve been using it almost every day for a couple years. Most of my work is done through shortcut keys.

On the other hand I think the designers made a good effort of reducing the confusing user interface features of AD. They appear to have reduced the options (and features) to what they think the price point justifies.

Making a new project

One of the first things I noticed about CircuitStudio is that it doesn’t have Workspaces.

Note the lack of Workspaces
Note the lack of Workspaces

Altium Designer has workspaces


Fortunately you are still able to open more than one project at a time. This would have been a serious limitation. It’s common to have several projects open at the same time. I often have several libraries open at minimum.

The libraries panel is very similar to Altium:

CircuitStudio libraries panel


Look familiar?

Fortunately CS had no problem loading my existing AD libraries. If you’re like me, you’ve been creating your own part models for years. The sweat equity should not be discounted.

In doing some backup research for this review I noticed that Altium seems to have gone back and forth on features that they would allow in CS. I noticed some people complaining about old Altium libraries not working in CircuitStudio. I can confirm that I opened all of my Altium Designer libraries in CircuitStudio and they worked just fine.

Altium Designer libraries panel. I find this design less confusing but perhaps it’s just because I’ve been staring at it for years.


Making a simple board – impressions

Schematic Entry

Drawing the schematic for this simple design seemed like no big deal. The schematic editor in CS appears to be identical to AD.

CircuitStudio schematic editor

One positive for Altium is that their schematic entry is easy to read by default. I use Mentor Graphics software at my day job and it uses that horrible stroke font that is designed for pen plotters. It’s not 1998. Nobody should be using pen plotters!

Anyway I’ve always been reasonably impressed with Altium (and hence CircuitStudio) schematic editor because it’s right there at the top, as good as or better than the most expensive tools.

Component Parameters

I took some screenshots of common schematic editor windows so you could see that they’re almost direct copies.

Component parameters


Part annotation


Update PCB / Forward annotation


CircuitStudio has a slightly different feel than Altium Designer. The flow is a bit different but the underlying concepts are the same so I’m hesitant to say the process is fundamentally any different.

The basic flows is:

  1. Draw the schematic
  2. Annotate parts
  3. Run ERC
  4. Add a PCB to your project
  5. Update PCB Document (also known as Forward Annotation)


In Altium a lot of the design flow process was spread out over several different menus. CircuitStudio has condensed a lot of this into primary drop-down menus from the UI. It actually stresses me out a little seeing how much functionality from AD is packed into one menu in CS. Generate Outputs is in the same menu as adding new files. It just seems odd, that’s all!

Inconsequential complaining aside, like I said, a lot of the underlying functionality is nearly identical in AD and CS. For example here is the forward annotation / ECO window in CS:



For those of you playing along at home, you might notice I’m designing a very simple little microcontroller PCB here. After updating the PCB I get the parts on the layout which, no surprise, looks exactly like Altium Designer:


One thing I notice here is that CS does not know about the concept of Rooms. That’s fine with me. They always get in my way anyway. Maybe you like Rooms if you’re designing highly compartmentalized and complicated designs.

I haven’t completely explored the shortcut/hot keys yet, but I have to say I don’t understand why they changed them. In Altium you hit ‘Z’ on the keyboard to bring up the Zoom context menu:

Altium Designer hotkey context menus make a lot of sense. CircuitStudio – doesn’t have them at all.

Pressing ‘Z’ in CS does nothing at all. Interesting. I have to remember the illogical keypress Ctrl+PgDn to “zoom all” which is the extremely easy to remember keypress sequence: Z,A in Altium.


The default layer coloring for a board in CS is thus:


Ouch! That’s rough. You’re going to want to know how to change the layer rendering color if you want to have any chance of understanding what’s on what layer. Fortunately it is pretty easy to change layer colors. Right click on any layer tab on the bottom of the PCB editor and select “Layer Colors…”


I can’t find the PCB List panel.

In Altium you can select several components, for example the 4 mounting holes on this board:


And it would allow you to edit properties of all four components in spreadsheet form. It’s a really handy tool. I’m not very happy that it’s missing.

The 3D view still works in CS:


Obviously this stupidly simple design I made here would be easy in any EDA CAD software. I just wanted to get started and show you the “unboxing” and first impressions.

A few questions I plan on answering for my own edification in future posts:

  1. How sophisticated are the PCB rules?
    1. Can I constrain trace impedance?
    2. Can I define differential pairs?
  2. Does the software limit me to through-vias?
  3. What other signal integrity features exist?
  4. What export formats exist?
  5. Can I import DXF to the layout?
  6. Does the push-shove manual router work like it does in Altium Designer?

I will go into more depth in Part 2 when it goes live. I would like to hear feedback from you – what would you like to know? I have access to several different tools so I can compare features. What do you care about?


PT100 interface to I2C (Raspberry Pi)

I was looking for a way of reading a PT100 temperature sensor with a Raspberry Pi. I couldn’t find an inexpensive way of accomplishing this on a hobbyist budget. And to be honest I like to build things so this was how I did it.


Amazon and eBay are full of things like this now. This is a $10 PT100 temperature sensor. I wouldn’t use this for a commercial application but it works just fine and I personally trust it for my beer brewing application.

It’s a three terminal sensor. A PT100 thermistor is just a resistor that varies with temperature. The resistance goes up when the temperature goes up. For a chart, see the wikipedia page.

There are three ways to hook up a thermistor.

Typically you have somewhat long, thin, wires so the resistance is not negligible.

The resistance of a PT100 varies at about 0.38 ohms per degree celsius, so if your wires measure a total of 0.5 ohms, you’re off by over 1 degree. And the thermal coefficient of copper is significant (3.8 Ohm/Ohm/K) so your wire resistance cannot be linearly calibrated out.

The first way is to use two wires.


R1 and R2 represent the two wires leading to the thermistor.

The thermistor (R3) is sensed by measuring the voltage V = V1 – V2

And you calculate R3 by using Ohm’s law, R = V / I

R2 and R1 can be measured but like I talked about, you can’t just calibrate these.

Nobody does this except when the leads are very short. For example if your thermistor is on the PCB with the ADC.

On to method #2:

Three wire thermistor sensing


The 1mA current flows from the positive supply through the wire (R2) through the thermistor (R3) and through the final wire (R1) before reaching the current sink (I1) (and on to ground)

Here I added another wire represented by R4 and terminated at the node V3.

Almost no current will be flowing in or out of V3 – we’re just using it to measure the voltage on the other side of R1.

We can use this extra wire (V3) to measure the voltage drop across resistor R1 because we also know the voltage V2. The voltage drop across R1 is:

V(R1) = (V3-V2)

which also happens to be the same as the voltage drop across R2. The wires are the same size and length (approximately)

V(R2) ≈ (V3-V2)

Now that we have a third wire (V3) we should use this in place of V2 to measure the thermistor. Consider the value (V1-V3). This eliminates the voltage drop due to R1 but it still has the voltage drop due to the 1mA current flowing through R2. Since we already calculated the voltage drop V(R2) we can simply subtract it, giving the voltage across the thermistor Vtherm:

Vtherm = (V1-V3) - V(R2)
Vtherm = (V1-V3)-(V3-V2)

Four wire sensing

Four wire sensing is the easiest but nobody uses it. You need an extra wire.


I added a wire represented by R5 and terminated into node V4 in the above schematic. Measuring the thermistor would be really simple if you have a four wire setup: you just measure V4 and V3 with a voltmeter (or differential ADC). The voltage across the thermistor is (V4-V3).

On to the PCB!

The following board that I’m sharing is free-for-all. It’s not perfect but it worked for me the first time around and I was incredibly surprised. As an engineer you come to expect your designs to be nearly FUBAR on the first try. Actually – I’m being modest; they often work reasonably well. I just stopped being modest. I’m sorry.

Here’s the schematic. Click the image to see a larger view:


This board has two current sinks. Each sinks 1.0mA with a reasonably wide compliance range (TBD).

The current sinks are connected between the EX+ and EX- pins. The ADC inputs are connected across SENSE+ and SENSE-.

The current sink is fixed at 1mA.

The ADC is the Microchip MCP3427. It is a 16 bit I2C converter with an onboard 2.048v reference. It also has a programmable gain amplifier (PGA) that can multiply the analog input by 2, 4, or 8. This allows you to achieve higher dynamic range in the digital domain. The analog inputs are differential so you can measure a differential voltage without adding external op-amps, which is perfect for this application.

Let’s say you want to measure between -50 Celsius and +200 Celsius using a PT100 with a 1 mA current sink. The Wikipedia chart shows that the resistance varies between about 80 and 176 ohms and thus the voltage is 80 mV to 176 mV. Enabling the x8 PGA will multiply these values by 8, giving 640 mV minimum to 1.408 volts maximum.

The voltage is then converted by the 16 bit ADC with 2.048v reference. This gives

0.64 / 2.048 * 2^16 = 20480 LSB for -50 Celsius


1.408 / 2.048 * 2^16 = 45056 LSB for +200 Celsius

This is 24576 LSB over 250 degrees, or about 98 LSB per degree. Or (about) 0.01 degrees per bit. This is completely neglecting linearization issues. I’m just showing you the dynamic range of the signal path.

This design is not ideal for three wire PT100 sensors, but it does work just fine if you don’t have long lead wires. You could use the second ADC channel as the wire compensation channel. Just subtract the wire voltage drop from the primary channel reading.

If you don’t care about the static offset due to one of the PT100 sensor wires, you can use this board as a two-channel device. Just hook up the single red wire to both the EX+ and SENSE+ lines and hook up one blue wire to EX- and the other blue wire to SENSE-.

(The colors could be anything, but there will be one of color ‘A’ and two of color ‘B’)

I made the decision to leave the terminals independent so that you can easily attach a different type of sensor to the ADC.

As usual, I had OSH Park make the boards and I’m sharing the project so that anyone can order boards for themselves. Here’s a link to the OSH Park page for this project.

pt100_bot pt100_top

Bill of materials:


Finished board! Sorry it’s a bit messy.



Mooshimeter – a bluetooth multimeter

I just received my Mooshimeter from a kickstarter that I backed a while ago.

2015-01-28 11.42.182015-01-28 11.43.262015-01-28 11.43.35

The Mooshimeter is a small battery powered multimeter that talks to your smartphone or iPad over Bluetooth LE. Not all devices have BLE so you should check before jumping to buy this.

The bluetooth IC is the CC2540 which is an integrated MCU + bluetooth system. The analog front-end is the ADS1292 dual 24-bit delta-sigma converter. As far as delta-sigma goes, it seems to be a very nice part with a maximum sample rate of 8kHz.

I wanted to try out my new Mooshimeter so I clamped a beam-type load cell to my workbench:

2015-01-28 11.34.52

The load cell is a super inexpensive (cheap) beam cell that I bought on Amazon for about $25. A load cell uses a resistive bridge strain gauge to measure the small amount of deflection in a calibrated beam. The deflection follows the strain linearly. Using this relationship you can use a load cell to measure force such as gravity.

2015-01-28 11.35.24

Load cells are rated in (volts full scale) per (volt input)

This means if the input is 10 volts (typical maximum) the output of this particular load cell will be 20 millivolts when a force of 5kg (49 Newtons) is applied. This is a difficult value to measure with a multimeter. The Mooshimeter claims 24 bit resolution which should give us plenty of bits even with this small maximum scale of 20 mV.

I hooked up the strain gauge and measured 1.43 mV. This value is a combination of the gravity pulling on the load cell (aka the weight of the load cell) and mismatch in the strain gauge. I didn’t pay much for this load cell so I suppose I can’t expect great performance.

2015-01-28 16.32.21

I put a roll of solder on the load cell and measured 2.65 volts. In case you’re unsure: the polarity of the voltage is relative to whether you are pushing or pulling on the load cell. Many are bidirectional (but not all.)

2015-01-28 16.32.12

If we subtract the values, the solder weighs 1.22 millivolts. Previously we calculated that the full scale of 5 kg (49 Newtons) is 20 millivolts. So according to my load cell and Mooshimeter, my roll of solder weighs 1.22mV/20mV * 49 N = 2.99 N. This is 0.67 pounds. That sounds pretty good to me. My cheap OXO food scale says 0.675 pounds which corresponds surprisingly well!

The Mooshimeter app will show a graph vs. time of voltage (and current) I made a short video of me pushing on the load cell with my finger to demonstrate this.

2015-01-28 12.11.58I haven’t had a lot of time to play with the Mooshimeter but I think it will definitely show it’s usefulness as time goes by. Of particular interest to me will be long-term data logging which at the time of this writing is a feature that has not been finished.


Temperature compensated MOSFET biasing

A class AB MOSFET amplifier circuit is shown below:


The MOSFET, in class-AB operation has a positive DC bias provided by voltage source V1. The purpose of the bias is to bring the transistor into it’s linear operating region, as shown by a datasheet graph of drain current vs. gate voltage:

IRF540 forward transconductance

The graph here begins at about 4 volts. The threshold voltage of the IRF540 (which I’m just using as an example) is somewhere around 4 volts.

Once you get beyond 4 volts, you can see that the drain current increases in a nice sweeping (exponential) arc.

Now imagine you are building a high power class-AB amplifier with V2 = 48v and quiescent current = 60mA. The power dissipated by the transistor is 2.88 Watts.

2.88 Watts will heat the transistor up a bit, depending on how nice your heatsink is. The transistor gate threshold voltage temperature coefficient is between -2 and -4 mV / C (millivolts per degree celsius)

So if the transistor heats up by 10C, the threshold voltage drops by about 30 mV. This could have a significant effect on the quiescent current, causing the transistor to get even hotter!

One way of dealing with this issue is to use a temperature compensated bias circuit:

rf_amp TL431 ckt
MOSFET bias temperature compensation circuit. The output voltage is on the cathode of U4 (pin 1) and for these values results in about 3.7 volts at room temperature.

The device I built this for is an RF power amplifier that uses the MRF6V2010 N channel MOSFET. The threshold voltage is around 2.3v for this device.

The output of the above circuit is fed to a potentiometer that sets the gate bias voltage:

MOSFET AB bias control

The TL431 is a dirt cheap ($0.14 US) shunt voltage regulator that has a built-in voltage reference, error amplifier, and pass transistor. I used an NTC (negative temperature coefficient) resistor, R38, which increases the feedback voltage on the TL431 as the temperature increases. This causes the output voltage to decrease, following a similar temperature coefficient as the MOSFET threshold.

Because the MOSFET gate passes no current the gate bias voltage supply is only capable of around a milliamp of DC current. The bias voltage leaves the potentiometer (R18, above) where it passes through a few RC networks to filter out RF energy that would add noise to the amplifier (or radiate power.)


I’ve made a few calculations to show how this works in a real design. The threshold voltage of a MOSFET varies by -2 to -4 mV/C as I mentioned above. This depends on the doping level of the device.

Let’s say we’re using this circuit for generating MOSFET bias (click for larger view):



[I lost this image. It is basically the same as the above schematic with TL431, however, the part designators have changed]


Specifically I’m looking at the three resistors on the feedback of the TL431 (R1, R2, R3)

The voltage reference of the TL431 is 2.50v. This fixes the cathode voltage of the TL431 to be:

Vout = 2.5 * (R1+R2+R3)/R3

Looking at the datasheet for a common NTC thermistor with B=~3900 we see a chart of the resistance change vs. temperature. Of course another method would be to use the actual mathematical model in our calculation. The chart is fine for me though. I’m going to be making an estimate which will end up being near the ideal value.

NTC thermistor chart

Thermistors are commonly rated by their 25C value. If you buy a 1K NTC thermistor, it should measure about 1K ohms at 25 celsius. This chart shows that for a thermistor with a B value of about 4000, the resistance at 40C for example will be close to 80% of what it is at 25C.

So we can use this knowledge to figure out the temperature coefficient of our bias circuit:

Tempco(PPM) = (V1 – V0) / (T1 – T0) * 10^6

T1 is the higher temperature (pick a value)

T0 is the lower value (use 25C)

V1 = 2.5 * (R1+R2+R3)/R3
Where R2 is the thermistor value at T1

V0 = 2.5 * (R1+R2+R3)/R3
Where R2 is the thermistor value at T0


As an example

T1 = 40c

T0 = 25c

R1 = 3.3k

R2 = 1k NTC thermistor, varies with temperature (40C = ~ 800 ohms, 25C = ~ 1000 ohms)

R3 = 10k

V0 = 2.5 * (3.3k + 1k + 10k)/(10k) = 3.575v

V1 = 2.5 * (3.3k + 800 + 10k)/(10k) = 3.525v

Tempco(PPM) = (3.575 – 3.525)/(40 – 25) *10^6 = -3333

The value -3333 means that for each degree celsius, the voltage will go down by 3.3 mV. This is near the middle of the range defined by the physics of the MOSFET (-2 to -4 mV / K)

How good does it need to be?

One item I’ve neglected so far is the temperature coefficient of the internal TL431 voltage reference. According to the datasheet for the Fairchild TL431, the temperature coefficient is 4.5 mV over 110 degrees C (the temperature range of the device.) This is a tempco of +41 PPM

Using -4mV/K as an upper limit of our MOSFET threshold voltage and using -3.3mV/K from the last example, adding 41 PPM gives us (close enough to) -3.2mV/K. We subtract these together to get the resulting rate of 0.8mV/K.

We can figure out the bias current change between two temperatures given the transconductance of the MOSFET. The IRF510 has a transconductance of about 1.2 Siemens (amps per volt.)

Using the same example temperatures of 25C and 40C, we can see that the gate bias voltage will change by:

Vdelta = 0.8mV/K * (40C-25C) = 12 mV

The bias will change by about:

12mV * 1.2 A/V = 14mA

That’s not necessarily bad but it’s not great. One way to make this adjustable would be to add a potentiometer in parallel with R2. Decreasing the value of the pot will decrease the bias circuit tempco, increasing the pot value will increase the bias circuit tempco. This is exactly what I did in the above tempco schematic. Pot R37 changes the tempco adjustment slope. Experiments show excellent slope control capability.


MMBT5179 amplifier board

The MMBT5179 is a cheap NPN bipolar junction transistor designed for radio frequency applications. I designed this super simple 1″ square board to test the performance of this transistor.

I personally intend to use this part in the HF range from 10 – 30 MHz. Due to this being a two layer board I was unable to make the trace impedance 50 ohms. The traces would need to be >100 mils wide. However, the traces are extremely short with this being such a small PCB.

As configured, the bias current should be about 11 mA. Intended supply voltage is 5.

Simulation shows gain of +20dB at 20 MHz. We’ll see!

This PCB is shared on OSH Park. It’ll cost about $5 for three copies.

OSH Park 4 layer stackup and impedance data

Note: If you want to use this data for designing your own PCBs, please ensure that my stackup data matches what OSH Park is currently using.

Here’s some data on the OSH Park 4 layer stackup:

osh park 4 layer stackup data from website

If you want a 50 ohm trace on the top layer and the second layer is ground (as it should be) then you want the trace width to be 14.47 thousands of an inch:


I used Agilent LineCalc this time. It performs an actual e-mag simulation to synthesize the correct line width. I am quite confident that this is the correct value given the inputs.


Table completed

I actually completed the table around March 2013 but I neglected to update my blog. Here are a couple pictures:

DSC_0003 DSC_0007I skipped a lot of steps. Leave a comment if you have any questions.


I just found a bunch of pictures of the leg building process, etc:

01-DSC_0001 02-DSC_0002 03-DSC_0003 04-DSC_0004 05-DSC_0005 06-DSC_0006 07-DSC_0007 08-DSC_0008 09-DSC_0009 10-DSC_0010 11-DSC_0011 12-DSC_0012 13-DSC_0013 14-DSC_0018

Wideband RF preamp / GPS Preamplifier board

I started this design 2 years ago using the Hittite HMC474 MMIC. That part has since been discontinued so I redesigned the board.


Originally I wanted a GPS preamplifier. Another project of mine is to build a GPS receiver. But there’s nothing specific about this design that limits it to 1575 MHz. The MMIC and biasing circuitry will allow this to work from VHF to probably around 3 GHz. I haven’t tested the range yet.

This new design uses the Analog Devices ADL5611.

It’s not the cheapest MMIC out there but the features stack up well.

Here’s a schematic. Click the image for a large view:



Parts list:

wideband preamp parts list (spreadsheet)

wideband amp simple bom


I will test this board in the coming weeks. I promise.


I’ve shared this board on OSH Park so you can buy your own copy of the board for a reasonable sum