HJeeter

A friendly reminder in its most subtle form



Created by: Bram den Ouden, 2020-01-22


<WARNING> This project deals with mains voltage. If handled incorrectly, these voltages can kill you. Please always consider both your own safety and the safety of people and animals around you. I am no expert and take no responsibility for your actions. </WARNING>

Roommates, sometimes they are a blessing, at other times a curse. When a new roommate kept forgetting to turn off the minigrill, it was time to make him a subtle reminder.

This project describes the steps of creating the ‘HJeeter’, a feedback system using a 433MHz transmitter and receiver, relay module, ATtiny85 and Arduino pro mini. The goal is to switch on a stroboscope when the minigrill has been on for a specified amount of time. The stroboscope must also be turned off after the minigrill has been turned off.

Components

Transmitter

The transmitter part of this project is responsible for sending a pre-shared key to the receiver when the mini grill is powered. This would preferably be a small device since it will be placed in an already pretty full kitchen. The smallest transmitter I could find which still has a pretty good range is a 433HMz transmitter with a helix antenna. This transmitter uses an On-Off-keying modulation, has a maximum transmitting power of 10mW and accepts 3.5V up to 12V Vcc.

To let this transmitter send anything useful, a microprocessor is required. I chose to use a Digispark attiny85 module with integrated male USB connector. Instructions on how to program this little gem of a microprocessor can be found at https://digistump.com/wiki/digispark/tutorials/connecting.

This Digispark module only has 6 general purpose in/outputs (GPIO) so the number of external components that require GPIO’s is limited. Luckily the chosen 433MHz transmitter requires only a single pin to communicate with the Digispark module. The transmitter accepts 3.5V up to 12V supply so the 5V from the USB port can be used as a power supply by soldering the VCC and GND from the transmitter to the VCC and GND connectors of the Digispark module. Since the Digispark and the transmitter module are about the same size, they can be soldered back to back while allowing access to the on-board USB connector. To allow some sensors to be added later on, I also added headers to pin P2 up to P4.

The result can be seen in figure 1 and is a very compact transmitter for the HJeeter!

Figure 1: Transmitter soldered to ATtiny85 module.

Transmitter firmware

 

#include <VirtualWire.h>

const uint8_t led_pin = 1;
const uint8_t transmit_pin = 0;

struct package
{
  uint16_t alarm = 10; // Pre-shared key
};

typedef struct package Package;
Package data;

void setup()
{
  // Initialise the IO
  vw_set_tx_pin(transmit_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(500);       // Bits per sec
  pinMode(led_pin, OUTPUT);
}



void loop()
{
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)&data, sizeof(data));
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);

  delay(1000);
}

Receiver

To switch on the stroboscope, we must receive the key send by the transmitter and, if the key matches our key, turn on the stroboscope. To fulfill these functions the receiver consists of multiple parts:

  • Interaction with the 220V mains voltage to switch the stroboscope on or off
  • Generation of the 5V power line required by the microprocessor and receiver
  • The microprocessor and receiver used to translate the transmitted signal into a logical operation

 

220V

When switching high voltages using a low voltage microprocessor, a relay is required. There are many different types of relays each excelling in different applications. For the purposes of the HJeeter we had the following requirements:

Specification Requirement
Switching voltage ± 220 Volt AC
Minimum switching current < 1 Ampere
Switching frequency ± once per 10 minutes

The relay used in this project is a JQC-3FF-S-Z which can be found for under a dollar at most online retailers. By applying 5V to the signal pin, the common (COM) output is connected to the normally open (NO) output. Without this signal the COM is connected to the normally closed (NC) output. It can handle up to 10 Amperes at 250VAC and switches well within a second.  

Since I wanted to create this HJeeter as a module where not only a stroboscope but other electrical devices could be plugged into as well, I connected the relay inline with an extension cord. Since the extension cord used stranded wiring, Ferrule crimp connectors had to be added.

What are ferrules you might ask?

An electrical wiring ferrule is a soft metal tube that is crimped onto the end of a stranded wire to improve the wire’s connection characteristics.

hackaday.com

Hackaday wrote an article on when ferrules might be useful for your projects. According to their measurements, the resistance of a connection with ferrule added to the wire is much lower than the resistance of connections without such a ferrule. Apart from this lower connector resistance, a ferrule makes a connection to the screw terminal much sturdier. Images of this step will be shown in the ‘Results’ section.

5V

The 5V power line required by the microprocessor and the receiver can be generated using a store bought power supply like this one from aliexpress, which is advisable for safety reasons. Unfortunately, I didn’t have one of those on hands and didn’t have the time to wait for one to arrive from china so decided to modify a spare USB charger. An important feature lacking a modified charger is a cover to protect it from any metal pieces getting into the supply, which is why I repurposed the original case to make a protective shield around the high voltage part. My charger contained a built-in thermal fuse to prevent short circuits, if this is not present in yours, consider adding a fuse to the 220V line going into your power supply.

All pieces used to generate the 5V and its protective case can be seen in figure 2. I cant emphasize this enough but please,

DO NOT MESS WITH MAINS VOLTAGE If you have ANY doubt about what you’re doing or if it’s safe, don’t do it.

Figure 2: Store-bought fly-back converter cut out of its enclosure.

Microprocessor

The receiver uses an Arduino pro mini to interpret the output signal from the 433MHz receiver and control the relay. If the transmitted key matches the key it has locally stored, the stroboscope will be turned on using the relay. If the time between messages exceeds the max_delay value, the stroboscope will be switched off.

Receiver firmware

 

#include <VirtualWire.h>

const uint8_t receive_pin = 11;
const uint8_t relay_pin = 12;

int max_delay = 3000; // max delay without receiving messages before turning relay off
uint32_t last_msg = 0;

struct package
{
  uint16_t alarm = 10;
};


typedef struct package Package;
Package data;


void setup()
{
  Serial.begin(9600);
  pinMode(relay_pin, OUTPUT);
  digitalWrite(relay_pin, HIGH);
  vw_set_rx_pin(receive_pin);
  vw_setup(500);     // Bits per sec
  vw_rx_start();       // Start the receiver PLL running
  Serial.println("booted");
}

void loop()
{
  uint8_t buf[sizeof(data)];
  uint8_t buflen = sizeof(data);

  if (vw_have_message())  // Is there a packet for us?
  {
    vw_get_message(buf, &buflen);
    memcpy(&data, &buf, buflen);
    Serial.println(data.alarm);
    if (data.alarm == 10) {
      last_msg = millis();
    }
    Serial.println(millis());
    Serial.println(last_msg);
  }
  if (millis() - last_msg >= max_delay || millis() < max_delay) {
    digitalWrite(relay_pin, HIGH); // turn relay off

  } else {
    digitalWrite(relay_pin, LOW); // turn relay on

  }

}

 

Results

Since this project uses lethal voltage levels, the whole thing has to be put into an enclosure as can be seen in figure 3. This figure will act as a reference figure when walking through the assembly steps:

  • The white wires through the grey connectors on the left of figure 3 show the mains wiring coming in and leaving the enclosure through water-proof connectors. These connectors are also tight enough to act as strain relief to prevent accidentally pulling the 220V wires out of the enclosure.
  • The small terminal block connected to the green/yellow wire ensures the ground connection of the extension cord is maintained.
  • The bigger terminal blocks connect the 220V live and neutral wire to the relay and the 5V power supply.
  • The black wiring is the switch wire: This wire can be either live or neutral, depending on the state of the relay. Whilst writing this I spotted a small mistake: I should have put the relay inline with the brown wire instead of the blue wire. Although this has no impact on how the system will function it’s always nice to adhere to the wiring convention. Note this wire does not have any ferrule crimp connectors; This is because it’s a solid core wire.
  • The small blue box at the bottom of the enclosure is the relay. Since I wanted the stroboscope to be off by default, the black wires are connected to the normally open (NO) and common (COM) terminals.
  • The black box at the top-center is the earlier described 5V power supply. The blue and red wires coming out of it at the right side are the reference voltage and +5V respectively.
  • The green PCB at the right-bottom is the 433MHz receiver paired to the 433MHz transmitter. The orange wire is its antenna which has been trimmed to a length of about 17.3cm to match a quarter wave length of the transmitting frequency.
  • The blue board at the right-middle of the enclosure is the microprocessor which is connected to the 5V power supply, relay and 433MHz receiver.

Every component has been hot-glued to the enclosure to prevent it from moving around and possibly shorting out other components. Solder connections have been covered with heath-shrink.

Figure 3: Final assembly of the HJeeter, lid removed

Conclusion

As Adam savage used to say:

Do as I say, not as I do.

During the course of this project we’ve worked with mains wiring, modified existing products to use them in scenarios they were not necessarily intended for and hot-glued it all together in a plastic case all to get my roommate to switch off the mini grill.

If you decide to create this project as well, please use screws to fix the components in their enclosure. The heat generated during operation can be enough to soften the glue enough to make parts come loose, which could be dangerous.

This project was created using components I had laying around the house and might not be the optimal solution in terms of power efficiency or space. For more off-the-shelf solutions you could have a look at systems like SONOFF or other home-automation systems. Most of these solutions require an existing infrastructure to connect to which is something to keep in mind.

On a final note: The project was a success! The stroboscope turns on when the mini grill does and turns off after the timeout period is exceeded.

My roommate won’t know what hit him next time he leaves the minigrill on