Garden environmental telemetry project – part 5

Garden environmental telemetry project – part 1 laid out plans for a simple maker / DIY IoT garden environmental telemetry system.

This article documents a change to the sensor configuration and payload formatter adding another temperature and humidity sensor for the greenhouse.

The sensors are now:

  • ID=1 air temperature and humidity;
  • ID=2 soil temperature and humidity.
  • ID=3 greenhouse temperature and humidity.

The payload contains an 8bit payload version number then six 16bit values for the six sensors. This is parsed by the TTN uplink formatter.

RS485-LN firmware has been upgraded to v1.4.

Uplink formatter

function decodeUplink(input) {
  ab=new ArrayBuffer(input.bytes.length);
  const abv=new DataView(ab,0,ab.byteLength);
  for(var i=0;i<ab.byteLength;i++)abv.setUint8(i,input.bytes[i]);
  var payver=abv.getUint8(0);
  switch(payver){
    case 1:
      if(ab.byteLength<13){return {errors:["Bad payload length"]};}
      result={
        data:{
            field1:abv.getInt16(3)/10,
            field2:abv.getInt16(1)/10,
            field3:abv.getInt16(7)/10,
            field4:abv.getInt16(5)/10,
            field5:abv.getInt16(11)/10,
            field6:abv.getInt16(9)/10
        },
      warnings:[], // optional
      errors:[] // optional (if set, the decoding failed)
      };
      if(result.data.field2===-1){result.data.field1=null;result.data.field2=null}
      if(result.data.field4===-1){result.data.field3=null;result.data.field4=null}
      if(result.data.field6===-1){result.data.field5=null;result.data.field6=null}
      return result;
    default:
      return {errors:["Unknown payver"]};
    }
  }

Above, is the Custom Javascript formatter which writes the measured values into variables fields1-field6 of the data object.

This formatter is for firmware v1.4 which simply returns all ones in fields for MODBUS devices that do not respond with valid data. In this case, the humidity fields should never be -1, so they are used as a test for data valid.

This is not a good general solution. I suggested the following to Dragino:

A possible solution is to add a 16 bit field to the payload with a bit for each AT+COMMANDn to indicate that a valid response was received to that command (ie did not time out waiting for response, good CRC decoded). I could test those bits in the javascript uplink formatter, and supply null if the data was not valid.

This approach would be backwards compatible with v1.03 as it is an additional 16 bit field at the end of the payload, code reading v1.03 payloads would simply ignore the extra two bytes.

RS485-LN configuration

See the earlier articles in the series for details of the serial port client and configuration.

123456
AT+DEBUG
AT+BAUDR=4800
AT+DATAUP=0
AT+PAYVER=1
AT+DATACUT1=0,0,0
AT+DATACUT2=0,0,0
AT+DATACUT3=0,0,0 
AT+MBFUN=1
AT+COMMAND1=01 04 00 00 00 02,1
AT+COMMAND2=02 04 00 00 00 02,1
AT+COMMAND3=03 04 00 00 00 02,1
AT+CMDDL1=200
AT+CMDDL2=200
AT+CMDDL3=200

Above, the script sends the password (which if already unlocked will cause an error which can be ignored) and commands to configure sampling of the two sensors, and packaging of the results in the payload.

Configure Thingspeak channel for the six data fields

The six data fields were displayed in a new channel on Thingspeak.

Write and test Thingspeak webhook

This task is simply collecting the URL and access credentials for write access to the Thingspeak channel.

Above is a capture over some days. The zero glitch in the greenhouse sensor has been addressed by increasing timeout, and revision of the uplink formatter to discard invalid data.

Air time

At this time, the gateway is very close to the RS485-LN, and DR5 (SF7 BW125kHz) is selected by ADR.

Above is a calculation using Semtech’s calculator.

Above is a screenshot from Airtime calculator for LoRaWAN. In checking the Radiocommunications (Low Interference Potential Devices) Class Licence 2015 as ammended 05/03/2022 (latest at time of writing), there is no limitation on dwell time in Australia under that licence. That said, the downloaded MAC data for the device includes “uplink_dwell_time”: true.

To be continued…

Links / references

Another small efficient matching transformer for an EFHW – 2643251002 – #5 – improved Simsmith model (v1.03)

This article applies the improved model: An improved simple Simsmith model for exploration of a common EFHW transformer designs (v1.03) to the design at Another small efficient matching transformer for an EFHW – 2643251002 – #1 – design workup.

Above is the prototype transformer wound with 14t of 0.71mm ECW tapped at 2t. The mm rule gives some scale. The turns are close wound, touching on the inner diameter of the core. Continue reading Another small efficient matching transformer for an EFHW – 2643251002 – #5 – improved Simsmith model (v1.03)

A Simsmith model of a Ruthroff 1:4 voltage balun – 2843009902 (BN43-7051)

A correspondent asked whether I had a tool similar to An improved simple Simsmith model for exploration of a common EFHW transformer designs (v1.03) to assist in the design of a ferrite cored Ruthroff 1:4 balun for HF.

In fact, the problem is the same as the one discussed in the article above, and the model is suited to application to the ferrite cored HF Ruthroff 1:4 balun case.

This analysis applies to a Fair-rite 2843009902 but may not apply to other manufacturer’s BN43-7051.

Above is a screenshot of the model calibrated against measurement. The magenta curve is the prediction and the blue curve is the measurement. Note that very small differences in measured value result in apparently large changes in InsertionVSWR, these two curves reconcile very well, especially considering the tolerances of ferrite material. Continue reading A Simsmith model of a Ruthroff 1:4 voltage balun – 2843009902 (BN43-7051)

Another small efficient matching transformer for an EFHW – 2 x 5943000601 (FT82-43) – VK4JJ build and measurement

The transformer is an autotransformer of 3+21 turns single layer close wound on a ‘stack’ of two Fair-rite 5943000601 cores (FT82-43?). Note that these were genuine Fair-rite stock, other #43 mix products in the market place may be significantly different (see Ferrite cored RF chokes in Class-E RF power amplifiers – core material issues for more discussion).

There are a plethora of designs using FT82-43 published on the ‘net, most of them have appalling loss.

Above is a Simsmith model and measurement of the transformer for reconciliation. The blue VSWR curve is the measurement and the magenta curve is the calibrated model, they agree well considering the tolerance of ferrite materials. Continue reading Another small efficient matching transformer for an EFHW – 2 x 5943000601 (FT82-43) – VK4JJ build and measurement

Another small efficient matching transformer for an EFHW – LO1238 – VK3PY, VK3TU build and measurement

This article documents the process of design, prototyping, measurement and final build of a 1:49 impedance ratio (1:7 turns ratio) EFHW transformer, exploring some alternative designs along the way, a collaboration between VK3PY and VK3TU with a little guidance.

The transformer is wound on a Jaycar LO1238 35x21x13mm toroid of L15 material (L15 appears to be a NiZn ferrite based on its very high resistivity), they sell at $7 for a pack of two.

2:14 winding

The first test was of a 2:14 turn winding terminated in a 2450Ω load. The transformer is an autotransformer of 2+12t with 91pF compensation capacitor installed in shunt with the 2t winding.

As expected, |s11| is pretty poor at the low end, corresponding to an InsertionVSWR=1.7 @ 3.5MHz.

Design rejected due to high InsertionLoss, magnetising admittance too high.

3:21 turn windings

The transformer is an autotransformer of 3+18t with 91pF compensation capacitor installed in shunt with the 3t winding. Continue reading Another small efficient matching transformer for an EFHW – LO1238 – VK3PY, VK3TU build and measurement

An improved simple Simsmith model for exploration of a common EFHW transformer designs (v1.03)

The article A simple Simsmith model for exploration of a common EFHW transformer design – 2t:14t proposed a simple model.

The previous proposal

Above is the equivalent circuit used to model the transformer. The transformer is replaced with an ideal 1:n transformer, and all secondary side values are referred to the primary side.

The model works quite well for low leakage inductance / low ratio transformers but falls down for the higher leakage inductance / higher ratio transformers.

An improved model

The improved model is similar, but Cse in the model above is distributed to the outer sides of the lumped constant model.

Above is the equivalent circuit used to model the transformer. The transformer is replaced with an ideal 1:n transformer, and all secondary side values are referred to the primary side. Continue reading An improved simple Simsmith model for exploration of a common EFHW transformer designs (v1.03)

Modelling an antenna as a simple two terminal resistance is often naive

in the article A simple transformer model of the Guanella 1:4 balun – some further observations I stated:

Note that a two terminal impedance is a naive representation of many if not most antennas, popular, but a naive over simplification that does not facilitate evaluation of current balance.

An example was a recent posting above that used the model to make assertions about the behaviour of a Guanella 1:4 balun.

This article reports results of two experiments with NEC to model an ‘imperfect’ half wave dipole. It is not exactly resonant, but the main issue is that it is tilted from one end to the other, it is not parallel to the ground surface. Continue reading Modelling an antenna as a simple two terminal resistance is often naive

Garden environmental telemetry project – part 4

Garden environmental telemetry project – part 1 laid out plans for a simple maker / DIY IoT garden environmental telemetry system.

This article documents a change to the sensor configuration and payload formatter in preparation for another RS485-LN.

The sensors are now:

  • ID=1 air temperature and humidity;
  • ID=2 soil temperature and humidity.

The payload  contains a 8bit payload version number then four 16bit values for the four sensors. This is parsed by the TNN uplink formatter.

function decodeUplink(input) {
  var payver=input.bytes[0];
  switch(payver){
    case 1:
      return {
        data: {
          field3: ((input.bytes[3]<< 8)|input.bytes[4])/10,
          field4: ((input.bytes[1]<< 8)|input.bytes[2])/10,
          field5: ((input.bytes[7]<< 8)|input.bytes[8])/10,
          field6: ((input.bytes[5]<< 8)|input.bytes[6])/10
        },
      warnings: [], // optional
      errors: [] // optional (if set, the decoding failed)
      };
    case 2:
      break;
    }
  }

Above, is the Custom Javascript formatter which writes the measured values into variables fields3-field6 of the data object.

To be continued…

A simple transformer model of the Guanella 1:4 balun – some further observations

A simple transformer model of the Guanella 1:4 balun discussed a simple model for the operation of the device, but a model that is too simple for most RF baluns. Notwithstanding that, it does expose some interesting issues that are not only valid at lower frequencies, but will also be manifest in an RF balun.

Isolated load

Consider the effect of breaking the connection at the red X, so that we now have  what is often referred to as an “isolated load”. Continue reading A simple transformer model of the Guanella 1:4 balun – some further observations

A simple transformer model of the Guanella 1:4 balun

(Guanella 1944) described a 1:4 balun, of a type often known as a current balun.

From Definition: Current Balun, Voltage Balun:

An ideal current balun delivers currents that are equal in magnitude and opposite in phase.

A good current balun will approach the ideal condition. It will deliver approximately equal currents with approximately opposite phase, irrespective of the load impedance (including symmetry).

Common mode current will be small.

If the load impedance is not symmetric, then the voltages at each output terminal will not be equal in magnitude and opposite in phase. (Note that for a truly ‘isolated’ load, one well represented as a two terminal load, the currents MUST be equal in magnitude and opposite in phase, but the voltages may not be equal in magnitude and opposite in phase.)

A simplified model

 

Above is a schematic of the Guanella 1:4 balun as often presented, this is an edited graphic from the ARRL manual, so may be familiar to readers. Continue reading A simple transformer model of the Guanella 1:4 balun