Tag Archives: WIFI


#106 AJ-SR04M ultrasonic distance sensor for water

looks like a STM8S003F3 MCU, unmarked crystal and unmarked TTL IC
Underside has a 2 pin socket and is quite dirty…

Recently I have had an old mildly annoying problem snowball into a new serious problem…

Every few months the clean water supply from uThukela Water (Pty) Ltd has been switched off for multiple reasons… striking, damaged electric motors due to Eskom, sabotage and other issues to name a few very serious reasons.

So two large 2500L water tanks were installed in series as a backup which worked well for small water issues that would last maybe a week or two.

However recently There has been no water from uThukela for over a month, and this is very serious.

This event triggered me to investigate water related problems and solutions specifically for my use case.

Order of importance:

  1. I need readily available clean drinking water
  2. Store this water for longer (get extra tanks)
  3. Keep water safely in the tank (no contaminates)
  4. Add sensors to monitor (water level sensor in this case)

For this article will be focusing on the 4th order of importance since this is a tutorial website mainly about electronics.

Therefore I will start by saying I searched for a suitable water level sensor and came across the JSN-SR04T and clones.

This sensor looks very promising and easy to use with 6 available sensor modes (adding increased diversity).

N.B the copy does not have 6 extra modes which was disappointing considering their price point…

2.2m wire with the sensor at the end.

The copy has 3 modes and is similar to the JSN-SR04T-2.0

Now my goal is to use the JSN-SR04T with an ESP8266 connected via WiFi to send readings to my server every 30s, this unit will be completely powered by solar.

The ESP8266 will also have a LAN dashboard to view the readings in real time connected to WiFi but with a connection to the internet not needed, just in case the internet goes down I can still read the water level values.

unfortunately finding a commonly available original JSN-SR04T Ultrasonic Distance Sensor has been quite difficult in South Africa.

I have only been able to find the AJ-SR04M (functions like the JSN-SR04T-2.0) which is a clone but works just like the original, however I see the price is equivalent and sometimes even more than the original which is quite strange. An of course the extra modes are missing…

The waterproof sensor
The sensor is epoxied and completely sealed looks easy enough to install

Mode 1: R27 = is open.

The sensor returns an analogue signal. The formula to calculate the distance from the data is:

Test distance = (high time * speed of sound (340M / s)) / 2;

Mode 2: R27 = A 47K resistor is soldered.

Every 100ms serial data will be sent in mm.

Serial baud rate: 9600, n, 8,1.

The frame format is: 0XFF + H_DATA + L_DATA + SUM
1.0XFF: for a frame to start the data, used to judge;
2.H_DATA: the upper 8 bits of the distance data;
3.L_DATA: the lower 8 bits of the distance data;
4.SUM: data and, for the effect of its 0XFF + H_DATA + L_DATA = SUM (only low 8)

Mode 3: R27 = A 120K resistor is soldered.

Good for low power applications.

After the module is powered on, the module enters standby mode.

If the module receives 0X55 it will send data over serial.

Serial baud rate: 9600, n, 8,1.

Datasheet for the stm8s003f3


#91 A WiFi battery powered firework igniter

Since I used low voltage with nichrome wire using LAN (RJ45) cable was not an issue. However with the next version I will solder a female RJ45 socket to avoid the hot glue tsunami… 🙂

Creating a WiFi fireworks igniter with a backup LiPo battery.

With December just around the corner I wanted to design a remote fireworks igniter working on WiFi and battery power.

The board will use mosfets as switches to nichrome wire which will heat up and ignite fireworks from a safe distance.

Before completing the PCB

The idea is to have the system self contained with the ability of remote control via a WiFi AP using an ESP8266 12F

The link to my GitHub repository (containing the design, parts list and other files) can be found here.

Nichrome wire
Vape coils containing nichrome wire


#88 A DIY battery + WiFi relay solution

With the ever growing pains of load-shedding looming over South Africans people have been desperately looking for viable alternative energy and battery powered devices. In my case I needed my remote pepper spray devices to be operational in my laboratory even during extended load-shedding times 4h off with 2h charge times.

I could have purchased added a battery and charging circuit to my existing factory made Sonoff board however that could make the PCB larger and I wanted to build a custom solution instead.

My requirements were WiFi capability, at least 4 relays, li-ion battery powered, battery charger with all the standard protection features and for the device to be powered by 5v from a standard phone charger.

The device must be plugged into the 5v phone charger 24/7, when the electricity goes off the device must continue to operate uninterrupted, when the power comes back on the device must change to the charge state uninterrupted.

The device does not have to send a notification when using battery but it must protect from overcurrent and over-discharge.

While looking for components I came across the ESP8266 PSB 04 module which is basically just the MCU WiFi controller used to switch 4 channels by itself

This was perfect for my application because I am already very familiar with Sonoff devices and in this case I do not mind using the firmware on the esp8266 and the Sonoff application + API software for my automation tasks.

Building around the module was a breeze all I needed was the appropriate relay circuits and a decent charging module.

I ended up creating two prototypes because hey there’s always improvements to be made…

Drill holes for terminals and relays
ESP8266 board with buttons, led and 3.3v regulator
Headers to mount LiPo and ESP8266 boards

The components I used on my final version 1.1 are as follows:

  • 4x Songle 10A relays here
  • 4x BC547 transistors here
  • 4x screw terminals here
  • 4x 1N4148 diodes here
  • 4x red led 3mm here
  • 1x yellow led 5mm here
  • 1x LiPo charger MH-CD42 (IP5306 chip on mine) here
  • 1x USB-A male cable here
  • 1x ESP8266 PSB-B04-CN Module 4-Channel Switch here
  • 1x AMS1117 3.3 800mA regulator here
  • 2x 10uf 25v caps here
  • 2x 100nf 25v caps here
  • 1x 18650 battery holder here
  • 1x old laptop battery 18650 (LGABD11865)
  • 9x 1k resistors here
  • 2x small cable ties
  • Various male and female headers

I tried to make the design as modular as practically possible

There are 3 main parts in the design consisting of a main PCB which contains the battery and relays = complementary components then the WiFi module with buttons and 3.3v regulator is located on a small green PCB and finally the LiPo MH-CD42 module can be secured on the main board via headers.

While constructing I had to use a 1.6mm drill bit for the battery holes and a 1.5mm drill bit for the relay holes. I soldered the SMD AMS1117 reg onto 3 a pin male header for easy through hole placement. The relays and the screw terminals required more attention during drilling and placement of the holes due to their pin layout. I also coated all exposed wires with nail varnish as a make shift solder mask.

I had to add an extra 1000uF capacitor between GND and 5v out of the LiPo module because it would briefly lose power when transferring from USB to battery power

Version 1.0 with lots of hot glue and test points
Version 1.1 board layout


#76 ESP32 that is Arduino & MicroPython Compatible

ESP-WROOM-32 32-bit 240 MHz microprocessor

The ESP32 has already integrated an antenna and RF balun, power amplifier, low-noise amplifiers, filters, and power management module. The entire solution takes up the least amount of printed circuit board area. This board is used with 2.4 GHz dual-mode Wi-Fi and Bluetooth chips by TSMC 40nm low power technology, power and RF properties best, which is safe, reliable, and scale-able to a variety of applications.




This is an ESP8266 equipped with 32M of flash memory. It is compatible for NodeMCU board (Lua based ESP8266). The additional memory this unit has allows for bigger projects with complicated and large libraries. It features an onboard USB-TTL Serial converter (CH340G chip) and a Micro-USB female connector. It comes with two sets of 15 pins headers to give you the freedom of choosing whether soldering directly onto the pin holes for a more compact approach.

  • Capable of WIFI networking (IOT): Access-Point, station or Web Server etc.
  • Uses simple LUA based programming language
  • Supports Arduino IDE
  • Event-driven API for network applications
  • 9 GPIO pins D0 – D8 featuring PWM functionality, I2C and SPI communication
  • Operating Voltage: 4.9 – 9 VDC
  • Dimensions: 49 x 26 x 5mm
  • Weight: 10g
Pin out.
Useful links can be found here



Wemos D1 mini

The Wemos D1 mini is a small WiFi based development board. The board is based off of the ESP-8266EX MCU developed by Espressif . The dimensions are 34.2*25.6 mm which allows this small package to be used effortlessly in large scale applications. Shields are also widely available and add to the ease of use for this board.


  • 11 digital IO, interrupt/pwm/I2C/one-wire supported(except D0)
  • 1 analog input(3.2V max input)
  • a Micro USB connection
  • Compatible with MicroPython, Arduino, nodemcu

Technical specs

  • Operating Voltage 3.3V
  • Digital I/O Pins 11
  • Analog Input Pins 1(3.2V Max)
  • Clock Speed 80/160MHz
  • Flash 4M Bytes
  • Size 34.2*25.6mm
  • Weight 3g

My specific board comes from a company called Farylink. It looks like they make small boards with wifi capabilitys.

According to there website:

Shenzhen Huayulian technology co., LTD is an IOT company that integrates rd, production and sales and is technology-oriented and service-oriented. With a rich background in the IOT industry, it focuses on the research, development and production of IOT communications.

Size fingers for scale.
Looks like someone rubbed of the programming IC’s serial markings. Or perhaps it was manufactured without any markings? Either way the fact remains its 100% a Chinese copy.

The link to the CH340 driver (which is required to program the Wemos D1 mini over USB) can be found here.


#47 150M Wireless Lite-N USB Module (2015)

The 150M Wireless Lite-N USB Module PW-MN427 is designed to provide a high-speed and unrivaled wireless performance for your devices, with a faster wireless connection, you can get a better WLAN/Internet experience. The PW-MN427 150M Wireless Lite-N USB Module complies with IEEE 802.11b, 802.11g and 802.11n standards. It can perfectly interoperate with all of the 802.11b/g/n devices.

The PW-MN427´s auto-sensing capability allows high packet transfer rate of up to 150Mbps for maximum throughput. Additionally, it supports WPS (Wi-Fi Protected Setup) function, which can help you create a wireless connection with effortless security setup, to prevent outside intrusion and protect your personal information from being exposed.


  • 150Mbps wireless transmission rate
  • Specific PIN for Radio On/Off, LED, and WPS (Wi-Fi Protected Setup)
  • Supports 64/128-bit WEP, complies with 128 bit WPA standard(TKIP/AES), supports MIC, IV Expansion, Shared Key Authentication, IEEE 802.1X
  • Compatible with 11b/g/n equipments
  • Onboard LED is optional
  • Supports 3.3V or 5V power supply
  • Supports Windows 2000/XP/Vista/7, Linux OS