User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jul 28, 2018 7:07 am

Mortimer wrote:
Fri Jul 27, 2018 3:54 pm
Ah but all of that relates to the accuracy of the real time clock circuit.
1. "+/-2ppm from 0 to 40degC" RTC is better than 2ppm.
It says nothing about the accuracy of the temperature sensor.

2. +/-2degC temperature accuracy is more like it. Your temperature readings covered a range of 4degC, which tallies with the claimed accuracy doesn't it?

3. temperature sensor to measure the internal temperature of the RTC chip
not to measure ambient air temperature.

4. To be fair it won't be far out, need to compensate for the internal chip temp.

Thanks for the clarification. I have not been bothering much about the difference between RTC's time output and temperature sensor temperature output.

Of course time and temperature are completely different things. I casually mixed them altogether and therefore made a big confusion.

So I needed to do some measurements to clarify my mind. I first collected 6 digital thermometers and read them at steady room temperature, with air conditioner switched on for about 1 hr, and no electric fan air flowing around. The readings are show below.

I will from now on use the first 2 meters as bench mark (actually I am not sure if I can use this term) standards for the following RTC experiments. They differ between themselves by about 0.2 Centigrade degrees, and from the average of 6 meters by 0.3 C degrees max. With this rough idea of accuracy tolerances, I think can now move on.

Ah, I think I also mixed the terms accuracy and tolerance. The meters should have an accuracy of 1 decimal place or 0.1 Centigrade degree, and a tolerance of about 3 Centigrade degrees max.
Attachments
n5gqd3i[1].jpg
n5gqd3i[1].jpg (69.91 KiB) Viewed 1686 times
Last edited by tlfong01 on Sun Jul 29, 2018 6:01 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jul 28, 2018 9:03 am

tlfong01 wrote:
Sat Jul 28, 2018 7:07 am
I will from now on use the first 2 meters as bench mark standards for the following RTC experiments. They differ between themselves by about 0.2 Centigrade degrees, and from the average of 6 meters by 0.3 C degrees max. With this rough idea of accuracy tolerances, I think can now move on.

Program V1.7

I have refactored program V1.6 to V1.7. I only list the main test function below. The remaining of the program is almost the same, so not listed here.

Hot air gun test results

I also used the hot air gun to heat up the RTC module and check if the temperature readings goes up. I blew hot air for a couple of minutes, the LCD meter screens got crazy and turned blank, after going up to about 33 degrees C. But the RTC temperature readings went up to well above 100+ degrees. I stopped hot air and let RTC cooled down. After 5 minutes, RTC still gave 90+ degrees. So RTC cools down very slowly, once heated up.

This is the first basic test. I don't have conclusion.

By the way, in Version 1.7 I used the python technique of defining functions inside a function. This is to do information hiding or ADT (Abstract Data Type).

The test function then becomes very readable, only 5 function calls:

printTimeTitleBegin()
msByteLsByteArray = getMsByteLsByteArray()
integerFractionArray = getIntegerFractionArray(msByteLsByteArray)
printTempString(integerFractionArray)

printTimeTitleEnd()

I guess the C++ guys shall feel jealous, because they can never do that, or anything similar. :lol:

Code: Select all

def test17():
    def printTimeTitleBegin():
        print('\n*** TimeNow = ', timeNowStr, '*********************************\n')
        print('+++', programTitle, 'V1.7', 'Begin +++')
        return

    def printTimeTitleEnd():
        print('+++', programTitle, 'V1.7', 'End   +++\n')
        return
    
    def getMsByteLsByteArray():
        msByteRegAddr = 0x11
        lsByteRegAddr = 0x12
        msByte = readDvRegOneByte(i2cCh1, dvAddrByte, msByteRegAddr)
        temperatureConversionDelay()    
        lsByte = readDvRegOneByte(i2cCh1, dvAddrByte, lsByteRegAddr)
        temperatureConversionDelay()
        msByteLsByteArray = [msByte, lsByte]
        return msByteLsByteArray
    
    def getIntegerFractionArray(msByteLsByteArray):
        msByte = msByteLsByteArray[0]
        lsByte = msByteLsByteArray[1]  
        tempInteger  = msByte   
        tempFraction = (lsByte >> 6) * 25
        integerFractionArray = [tempInteger, tempFraction]
        return integerFractionArray

    def printTempString(integerFractionArray):
        tempString = integerFractionArray[0] + integerFractionArray[1]
        print('\nRTC Chip Temperature =', tempString, 'degrees C\n')
        return
    
    printTimeTitleBegin()
    msByteLsByteArray = getMsByteLsByteArray()    
    integerFractionArray = getIntegerFractionArray(msByteLsByteArray)
    printTempString(integerFractionArray)
    printTimeTitleEnd()
    return

# *** Main ***

# test15()
# test16()
test17()


# *** Sample Output ***

'''
========== RESTART: /home/pi/python_programs/test1074/rtc01.007.py ==========

*** TimeNow =  2018-07-28 16:31 *********************************

+++ DS3231 RTC Example Test Program V1.7 Begin +++

RTC Chip Temperature = 106 degrees C

*** TimeNow =  2018-07-28 16:31 *********************************

RTC Chip Temperature = 61 degrees C

*** TimeNow =  2018-07-28 16:32 *********************************

RTC Chip Temperature = 61 degrees C

*** TimeNow =  2018-07-28 16:33 *********************************

RTC Chip Temperature = 105 degrees C

*** TimeNow =  2018-07-28 16:36 *********************************

+++ DS3231 RTC Example Test Program V1.7 Begin +++

RTC Chip Temperature = 95 degrees C

'''
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jul 28, 2018 2:32 pm

tlfong01 wrote:
Sat Jul 28, 2018 7:07 am
I will from now on use the first 2 meters as bench mark (actually I am not sure if I can use this term) standards for the following RTC experiments. They differ between themselves by about 0.2 Centigrade degrees, and from the average of 6 meters by 0.3 C degrees max. With this rough idea of accuracy tolerances, I think can now move on.
I have updated the test program to V1.8, and used it to test all 15 modules I found in my toy box. The results are more or less within spec.

My quick conclusion is that these modules I got from TaoBao (I forgot where I bought them, should be from 2 or 3 different shops.) for around HK$10 each are good, no defective items found.

Very roughly, the readings are accurate to within 2 Centigrade degrees, good enough for home automation electric fan or heater control.
Attachments
O3IEVSl[1].jpg
O3IEVSl[1].jpg (86.61 KiB) Viewed 1656 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sat Jul 28, 2018 3:10 pm

tlfong01 wrote:
Sat Jul 28, 2018 2:32 pm
Very roughly, the readings are accurate to within 2 Centigrade degrees, good enough for home automation electric fan or heater control.

Now I am thinking of writing a short python test program to switch on a water pump to water my plant every Monday to Friday morning 8am for 3 minutes. For Saturday and Sunday, Rpi will take a rest, because I will do the watering myself.

I need first sync RTC to Internet standard time, then set alarm every Mon to Fri 8am.

I googled and found the setup notes by WaveShare.

WaveShare RTC DS3231 Setup Notes
https://www.waveshare.com/wiki/Raspberr ... eries:_RTC

The 3 setup steps is summarized below.

  • 1. Add RTC DS3231 driver to Raspbian device tree (edit /boot/config.txt).
  • 2. Set RTC DS3231 from Internet (sudo commands)
  • 3. Set Raspbian system time from RTC DS3231(sudo commands)
WaveShare also gives a python example.

Code: Select all

Raspberry Pi Tutorial Series: RTC - waveshare, 
last modified 2016aug23, 
page accessed 3,080 times

https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_RTC

Raspberry Pi doesn't have RTC function so it cannot get the 
correct time without network. This problem can be solved by 
external RTC module and a DS3231 RTC module may be very helpful. ...

Setup

...

2. Edit the configuration file to add a new device.

sudo vi /boot/config.txt

Add a new RTC device DS3231 to the device tree

dtoverlay=i2c-rtc,ds3231

Reboot to take effect. About Device Tree, 
see: /boot/overlay/README

3. Read the Hardware Clock.

sudo hwclock –r

Read the system time:

date

4. Set the Hardware Clock to the time given by the --date option.

sudo hwclock --set --date="Aug-22-2016 18:00:00"

Here the date string can accept different date formats.

5. Set the System Time from the Hardware Clock.

sudo hwclock -s

6. Read the RTC and system times.

sudo hwclock -r;date

Programming Python

#!/usr/bin/python
# -*- coding: utf-8 -*-
import smbus
import time
 
address = 0x68
register = 0x00

#sec min hour week day month year

NowTime = [0x00, 0x00, 0x18, 0x04, 0x12, 0x08, 0x15]

w  = ["SUN","Mon","Tues","Wed","Thur","Fri","Sat"];

#/dev/i2c-1

bus = smbus.SMBus(1)

def ds3231SetTime():
    bus.write_i2c_block_data(address, register, NowTime)
 
def ds3231ReadTime():
    return bus.read_i2c_block_data(address, register, 7);
 
ds3231SetTime()

while 1:
    t = ds3231ReadTime()
    t[0] = t[0]&0x7F  #sec
    t[1] = t[1]&0x7F  #min
    t[2] = t[2]&0x3F  #hour
    t[3] = t[3]&0x07  #week
    t[4] = t[4]&0x3F  #day
    t[5] = t[5]&0x1F  #month
    print("20%x/%x/%x %x:%x:%x  %s" 
	%(t[6], t[5], t[4], t[2], t[1], t[0], w[t[3]-1]))

time.sleep(1)

Save the file as "ds3231.py" and run with:

sudo python ds3231.py

.END
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sun Jul 29, 2018 3:50 am

Mortimer wrote:
Fri Jul 27, 2018 3:54 pm
1. the +/-2degC temperature accuracy is more like it. Your temperature readings covered a range of 4degC, which tallies with the claimed accuracy doesn't it?

2. temperature sensor. It is there to measure the internal temperature of the RTC chip
not to measure ambient air temperature.

Yes, I agree < 3 degrees meets DS3231 spec. I agree it is not perfect to measure ambient air temperature. So I googled and ordered the DHT22 module which measures both temperature and humidity with much higher accuracy.

DHT22/AM2302 Capacitive Humidity Sensing Digital Temperature and Humidity Module
https://akizukidenshi.com/download/ds/aosong/AM2302.pdf

I looked at the results of the 16 modules and found that No 16 is the module I checked first in the very beginning. It was bad luck (or good luck) that it happened to be the module with the worst accuracy, otherwise I would not have noticed that the temperature reading was strange, and did the subsequent investigations.
Attachments
ii7iOai[1].jpg
ii7iOai[1].jpg (71.37 KiB) Viewed 1623 times
Last edited by tlfong01 on Sun Jul 29, 2018 12:40 pm, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Sun Jul 29, 2018 4:34 am

tlfong01 wrote:
Sat Jul 28, 2018 3:10 pm
I googled and found the setup notes by WaveShare.

WaveShare RTC DS3231 Setup Notes
https://www.waveshare.com/wiki/Raspberr ... eries:_RTC

The 3 setup steps is summarized below.
  • 1. Add RTC DS3231 driver to Raspbian device tree (edit /boot/config.txt).
  • 2. Set RTC DS3231 from Internet (sudo commands)
  • 3. Set Raspbian system time from RTC DS3231(sudo commands)
WaveShare also gives a python example.

WaveShare instructs to use the unix editor vi to edit the /boot/config.txt file. I don't know vi, and I don't want to use the ugly editor nano, because it is stupid. I always forgot to hit the Control X or Z button to save file, or forgot to say Yes or No for a new file name etc. The worst thing is that Nano is not WYSIWYG GUI. I am a hopelessly heavy addict of the Great Microsoft/Intel Windows GUI. I will show mouse withdrawal symptoms less than 5 minutes after switching into any no-mouse-black-and-white-text-terminal, ...

Luckily Rpi recently provides the Geany IDE for python. I sometimes use Geany in Windows 10 to play python 3.5, and sometimes use it to edit Rpi text files, such as the /boot/config.txt.
Attachments
2GfBooP[1].jpg
2GfBooP[1].jpg (51.3 KiB) Viewed 1617 times
I am an electronics and smart home hobbyist.

User avatar
Mortimer
Posts: 923
Joined: Sun Jun 10, 2012 3:57 pm

Re: Relay Module KY-019 5V

Sun Jul 29, 2018 12:39 pm

tlfong01 wrote:
Sun Jul 29, 2018 4:34 am
The worst thing is that Nano is not WYSIWYG GUI.
WYSIWYG is pointless and unnecessary for pure text files as they retain no visual formatting information, and line wrapping can cause confusion in my opinion.

tlfong01 wrote:
Sun Jul 29, 2018 4:34 am
Luckily Rpi recently provides the Geany IDE for python. I sometimes use Geany in Windows 10 to play python 3.5, and sometimes use it to edit Rpi text files, such as the /boot/config.txt.
Yup Geany is OK, as it is not WYSIWYG, its just a GUI based text editor. The coloured syntax highlighting is useful.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

User avatar
DougieLawson
Posts: 36161
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Relay Module KY-019 5V

Sun Jul 29, 2018 1:09 pm

Man up and learn vi (or emacs). It does syntax highlighting and auto tabs.

[EsC]:wq to save & [ESC]:q! to quit without saving are the only things you need with vi to get started.

The big touchstone for Raspbian is sudo apt install vim to get rid of the brain-dead vim-tiny stuff.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Mon Jul 30, 2018 6:54 am

DougieLawson wrote:
Sun Jul 29, 2018 1:09 pm
1. Man up and learn vi (or emacs). It does syntax highlighting and auto tabs.
2. [EsC]:wq to save & [ESC]:q! to quit without saving are the only things you need with vi to get started.
3. The big touchstone for Raspbian is sudo apt install vim to get rid of the brain-dead vim-tiny stuff.

3. I didn't catch you, perhaps because I never heard of vim and vim-tiny. I googled and wikied a couple of times before I can guess what you mean:

There are three kinds of vi: (a) vi, (b) vim, (c) vim-tiny.

(a) vi is the old guy nobody cares any longer.

(b) vim is the good guy, and,

(c) vim-tiny is the bad guy, but is hidden inside the raspberry pi stretch (my version of os).

So if I type vi or vim, the bad guy vim-tiny will jump out.

And to separate the good guy from the bad guy, you need to use a touchstone (I needed to google to know that it means in my native language "a stone used to check whether a golden looking metal is real or fake ". But why say ’sudo apt install‘, ... and not ‘sudo checkBadGuy something'?

Anyway, so I typed 'vi', expecting the bad guy vim-tiny comes out and I must immediately kill it. But what appeared was the good guy vim. I began typing characters, but nothing happened. Perhaps vim is the devil vim-tiny in disguise.

I found the Esc character not working, perhaps my keyboard layout is wrongly set to Great American. I also saw little snakes (tilde) in the beginning of every line. I would think it friendly to show the line numbers instead. The very first line of the help menu is to type 'help Sponsor'. I don't know why should a poor and needy python newbie like me should care about the sponsor.

I always remember my grandmother telling me about the sponsor's trumpet:

“... Thus, when you give to the needy, sound no trumpet before you, as the hypocrites do in the synagogues and in the streets, that they may be praised by others. Truly, I say to you, they have received their reward. Matthew 6:2
Attachments
SIW7vmK[1].jpg
SIW7vmK[1].jpg (64.53 KiB) Viewed 1553 times
Last edited by tlfong01 on Mon Jul 30, 2018 7:41 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Mon Jul 30, 2018 7:31 am

tlfong01 wrote:
Mon Jul 30, 2018 6:54 am
My first impression is that vim is uglier than nano!

Thonny IDE for Python

I discovered that Rpi stretch os also has the new Thonny IDE for python. I tried it and found it very newbie friendly.
Attachments
m27W2NU[1].jpg
m27W2NU[1].jpg (64.43 KiB) Viewed 1534 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Mon Jul 30, 2018 9:37 am

DougieLawson wrote:
Sun Jul 22, 2018 7:49 am
1. The MCP23017 in basic, simple GPIO mode is the simplest I2C device of them all.
2. You do nothing more than poke bits into IODIRA/IODIRB and OLATA/OLAB registers.
So that's four registers that need bytes written to them and two that you read.
3.Stop over thinking it. Sharpen your coding pencil and give it a go, you can't break the thing (unless you exceed 5V on a GPIO).

I am setting up my second Rpi, this time a Zero V1.3 2015 (not Zero V 1.1, 2017).

I have also tried OK poking and peeking IODIRA, and also done enough preventative hardware debugging, securing all wiring and connections, checking Rpi power is around 5.25V etc.

When I was small, I never wanted to go to bed to sleep, even it was very late. My grandmother always told me what the crazy sky electricity collecting scientist Franklin says:

Early to bed and early to rise makes a man healthy, wealthy and wise.

Many years later, I worked in an electronics factory's maintenance section, and learnt to do regular preventive maintenance, which is:

'If it ain't broke, don't fix it, but do preventative maintenance‘.

It is also many years later I learnt that sleeping is not a waste of time, but sort of neural net maintenance, reordering brain memory partitions, moving things from short memory section of long memory section, repairing broken neuron links etc, etc, ... It is this sort of preventive maintenance that makes your brain healthy, and age slower. As my grandmother says,

An ounce of prevention is worth a pound of cure.
Attachments
jzgUrWV[1].jpg
jzgUrWV[1].jpg (70.49 KiB) Viewed 1517 times
Last edited by tlfong01 on Tue Jul 31, 2018 11:42 pm, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Mon Jul 30, 2018 3:16 pm

DougieLawson wrote:
Wed Jul 25, 2018 9:18 pm
1. With a DS3231 you're much better off using the built-in linux kernel driver which is activated by adding a simple line to /boot/config.txt

Code: Select all

dtoverlay=i2c-rtc,ds3231
2. Doing your own thing with a python program is a waste of time (excuse the pun).

WaveShare's DS3231 setup guide consist of the 6 steps.

  • 1. Adding a line to /boot/config.txt to add the built in DS3231 driver to kernel, then reboot.
  • 2. Read hardware clock:
    sudo hwclock –r
  • 3. Read system time:
    date
  • 4. Set the Hardware Clock to the time given by the --date option.
    sudo hwclock --set --date="Aug-22-2016 18:00:00"
  • 5. Set the System Time from the Hardware Clock.
    sudo hwclock -s
  • 6. Read the RTC and system times.
    sudo hwclock -r;date
It appears that I need to use sudo hwclock commands to manually read hardware clock, read system (internet?) time, set hardware clock (from system time?), set system time from hardware clock?

All above 5 steps are done by hand. It is a bit confusing. I need to check out how to do it by python.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jul 31, 2018 3:00 am

tlfong01 wrote:
Mon Jul 30, 2018 3:16 pm
WaveShare's DS3231 setup guide consist of the 6 steps.
  • 4. Set the Hardware Clock to the time given by the --date option.
    sudo hwclock --set --date="Aug-22-2016 18:00:00"
  • 5. Set the System Time from the Hardware Clock.
    sudo hwclock -s
  • 6. Read the RTC and system times.
    sudo hwclock -r;date
It appears that I need to use sudo hwclock commands to manually read hardware clock, read system (internet?) time, set hardware clock (from system time?), set system time from hardware clock?
All above 5 steps are done by hand. It is a bit confusing.

I googled and found that I actually did not have enough knowledge to understand the WaveShare's instructions. I don't even know what is 'hardware clock', what is 'system clock'. How can I understand how to use the 'hwclock' thing which I don't know is it all about, to operate other things I also know nothing? So I googled on until I read the following article from archLinux. I don't know what is archLinux, but I think it should be good, becasue even the contents of the article gives me a good impression. And the section interested me most is the last section 'fake hardware clock', because I always enjoy reading fake news, tearing down fake things, etc.

hwclock (Time) - archLinux
https://wiki.archlinux.org/index.php/Time

In an operating system, the time (clock) is determined by four parts:

  • time value, time standard, time zone, and Daylight Saving Time (DST) if applicable.

This article explains what they are and how to read/set them.

Two clocks are present on systems:

  • a hardware clock and a system clock
which are also detailed in this article.

Standard behavior of most operating systems is:

  • Set the system clock from the hardware clock on boot.

  • Keep accurate time of the system clock...

  • Set the hardware clock from the system clock on shutdown.
Contents
1 Hardware clock
1.1 Read hardware clock
1.2 Set hardware clock from system clock
2 System clock
2.1 Read clock
2.2 Set system clock
3 Time standard
3.1 UTC in Windows
3.2 UTC in Ubuntu
4 Time zone
5 Time skew
6 Time synchronization
7 Per-user/session or temporary settings
8 Troubleshooting
8.1 Clock shows a value that is neither UTC nor local time
9 Tips and tricks
9.1 fake-hwclock
10 See also
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jul 31, 2018 5:24 am

tlfong01 wrote:
Mon Jul 30, 2018 9:37 am
I am setting up my second Rpi, this time a Zero V1.3 2015 (not Zero V 1.1, 2017).
I am making work copies of SD for my second RpiZ.

I am using Rpi stretch LXPanel 0.93 desktop panel GUI, not the ugly black and white text only terminal. The SD copier in the Accessory option is very user friendly. It reminds the ugly older versions - backup SDs must be the same or larger in size, and need to go back to Microsoft Windows and use Win32 Disk Manager to do the read and write to SD. There were sudo instructions using some advanced software tools like DD, which is very hard for linux newbies.

Now the new SD copier is a one stop shop, a couple of clicks takes care of everything.

One mistake I made in the backing up is the following.

When the SD Copier started to copy, the progress bar's blue portion grew very slowly, and almost did not change for 15 minutes, I thought the system hang up, so I clicked the cancel key, but then before the job was cancelled, the short portion of the progress bar suddenly changed to almost 50%, meaning that almost 50% job done, though the blue part indicated not so. I then realized that the progress bar is much slower, or seem freezing, but the copying in the background still go on. In other words, the progress bar does not reflect the actually progress.

Anyway, I tried again and found everything went well, though the whole copying took as long as 40 minutes (for SanDisk 16GB Ultra HCI speed 10, forgot if it means 10MB/s).
Attachments
txSiaS0[1].jpg
txSiaS0[1].jpg (51.81 KiB) Viewed 1474 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jul 31, 2018 1:33 pm

tlfong01 wrote:
Tue Jul 31, 2018 5:24 am
I am making work copies of SD for my second RpiZ.

Now I have started soldering the 40 pin GPIO connector to the Rpi Zero V1.3 board, then wiring the power and signal routing board. I forgot the pinout thing. So I made the ing link summary in the appendix below.

/ to continue, ...

Appendix - Rpi Zero W pin out

Rpi Zero W pinout V1.0
RE: RELAY MODULE KY-019 5V Postby tlfong01 » 2018-Jul-13 Fri 10:19 pm
viewtopic.php?f=63&t=77158&start=150#p1340473

Rpi Zero W pinout V2.0
RE: RELAY MODULE KY-019 5V Postby tlfong01 » 2018-Jul-18 Wed 7:44 pm
viewtopic.php?f=63&t=77158&start=175#p1342224

Rpi Zero W pinout V3.0
RE: RELAY MODULE KY-019 5V Postby tlfong01 » 2018-Jul-18 Wed 9:35 pm
viewtopic.php?f=63&t=77158&start=175#p1342280
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Tue Jul 31, 2018 2:33 pm

tlfong01 wrote:
Tue Jul 31, 2018 1:33 pm
Rpi Zero W pinout V3.0
RE: RELAY MODULE KY-019 5V Postby tlfong01 » 2018-Jul-18 Wed 9:35 pm
viewtopic.php?f=63&t=77158&start=175#p1342280

The DHT22 temperature and humidity module has arrived. Now I am doing 4 things at the same time: setting up second Rpi Zero, backing up more SD cards, refactoring RTC DS3231 temperature reading programs, and studying DHT22 datasheet.
Attachments
SdS0exQ[1].jpg
SdS0exQ[1].jpg (82.49 KiB) Viewed 1436 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Aug 01, 2018 1:39 am

tlfong01 wrote:
Tue Jul 31, 2018 2:33 pm
Now I am doing 4 things at the same time: setting up second Rpi Zero, backing up more SD cards, ...

This morning while reading online newspapers, I at the same time am making more SD backups. When I stop reading fake news, and the last SD copy is Work copy n, I will use n, and n-1 copy for the 2 Rpi Zeros. In case any SD is corrupted (while dangerously sudo nano editing /boot/config.txt, trying out vim-tiny etc), I will fall back to n-2 and so on. As soon as falling back to red line n = 5, I will make more back ups for risky playing. This way of keeping at least more than 5 backup SD cards in hand let me have sweet dreams every night.

By the way, this morning I am using smaller SanDisk 8BG 10 cards, and copying 16GB to 8GB, or 8 to 8, 8 to 16, etc. I surprisingly found that the backup time is only around 20 minutes.

I don't know why last night's backup always took 40 minutes, perhaps they are old cards and too many corrupted memory cells, so the copy and verify program need to skip bad cells, thus wasting time, ...
Attachments
MlCWwtd[1].jpg
MlCWwtd[1].jpg (50.7 KiB) Viewed 1403 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Aug 01, 2018 2:34 am

tlfong01 wrote:
Wed Aug 01, 2018 1:39 am
Now I am doing 4 things at the same time: setting up second Rpi Zero, backing up more SD cards, ...

Now I have made 8 work SD cards. A new toy also arrived. So my toys play list is getting too long, I need to prune some no longer interesting names.
Attachments
sL1OxJz[1].jpg
sL1OxJz[1].jpg (60.68 KiB) Viewed 1394 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Wed Aug 01, 2018 2:14 pm

tlfong01 wrote:
Wed Aug 01, 2018 2:34 am
tlfong01 wrote:
Wed Aug 01, 2018 1:39 am
Now I am doing 4 things at the same time: setting up second Rpi Zero, backing up more SD cards, ...

Rpi Zero V1.3 2015 very disappointing, will switch to Rpi 3B+

I have setup the Rpi Zero V1.3 2015. The results is very disappointing.

1. Rpi cannot recognize my USB3, switchable USB hub. I need to use a cheap, not so reliable hub instead.

2. The screen resolution is very low. I guess it is TV mode or similar 640 x 480 resolution (Rpi Zero W did not have this problem, and automatically recognizes my high resolution 1280 x 1024 monitor). I googled and found people talking about how to set the resolution. I have the feeling that it is a complicated and time consuming thing to do.

I already found Rpi Zero W V1.1 2017 a bit slow (disappointingly slow when using Geany's GUI commands). This Zero V1.3 2015 seems slower, and more stupid. I think it is not time efficient to use it for hardware/software development. So I decided to give up, and switch to Rpi3B+. I only played with 3B, and never 3B+. I hope 3B+ better that 3B.
Attachments
GeWXIuf[1].jpg
GeWXIuf[1].jpg (70.81 KiB) Viewed 1365 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Aug 02, 2018 3:41 am

tlfong01 wrote:
Wed Aug 01, 2018 2:14 pm
Rpi Zero V1.3 2015 very disappointing, will switch to Rpi 3B+
I have setup the Rpi Zero V1.3 2015. The results is very disappointing.
1. Rpi cannot recognize my USB3, switchable USB hub. I need to use a cheap, not so reliable hub instead.
2. The screen resolution is very low. I guess it is TV mode or similar 640 x 480 resolution (Rpi Zero W did not have this problem, and automatically recognizes my high resolution 1280 x 1024 monitor). I googled and found people talking about how to set the resolution. I have the feeling that it is a complicated and time consuming thing to do.
I already found Rpi Zero W V1.1 2017 a bit slow (disappointingly slow when using Geany's GUI commands). This Zero V1.3 2015 seems slower, and more stupid. I think it is not time efficient to use it for hardware/software development. So I decided to give up, and switch to Rpi3B+. I only played with 3B, and never 3B+. I hope 3B+ better that 3B.

Rpi 3B+ Very Good

This morning I tried Rpi 3B+. It is the first time I play with 3B+. I used the same hardware and wiring I earlier used for testing Rpi Zero V1.3 2015.

The bootup is very fast, compared to the very slow Zero 1.3. Rpi recognizes Logitech USB wireless mouse and keyboard, the USB hub, the USB flash drive.

Everything went well after boot up.

No reconfiguration is required. I am using the same SD card I tested earlier with Zero 1.3. This SD card has been tested good with the Zero W V1.1 2017, and was originally configured with another older Rpi 3B (forgot year, very likely 2016).

In other words, the same SD card can be used for Rpi3B 2016?, Rpi Zero W V1.1 2017, Rpi3B+ 2017.

One problem is that though Rpi recognizes the USB hub, it does recognize the logitech mouse dongle plugged into the hub. Mouse dongle directly plugged into Rpi3B+ socket has no problem. I met this problem before with Rpi3, but not 3B.

To summarize, Rpi3B+ is very good, compared with the very slow, not very compatible Rpi Zero V1.3. Rpi Zero W V1.1 is OK, but a bit slow.

I decided to forget both Rpi Zeros (Zero W V1.1 2017 and Zero 1.3 2015) and will use two identical Rpi3B+ 2017 for paired hardware and software development projects.
Attachments
aRc0x0o[1].jpg
aRc0x0o[1].jpg (83.17 KiB) Viewed 1348 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Aug 02, 2018 4:11 am

tlfong01 wrote:
Thu Aug 02, 2018 3:41 am
Rpi 3B+ Very Good

I decided to forget both Rpi Zeros (Zero W V1.1 2017 and Zero 1.3 2015) and will use two identical Rpi3B+ 2017 for paired hardware and software development projects.

MCP23017 controlling Quad DHT using python

I am watching youtube tutorials on how to use DHT22. The following video is good.

DHT22 Raspberry Pi Humidity Temperature Sensor Tutorial
https://www.youtube.com/watch?v=IHTnU1T8ETk

rdagger's other Rpi videos are also very good.
https://www.youtube.com/channel/UCp2rS5 ... fieAk74bIw

I found most DHT guide uses the adafruit or rgpio libraries. One problem is that they usually use one GPIO pin to talk to DHT22. I am a greedy guy and I want to control at least 4 DHT22s and many many other sensors. So my plan is to use MCP23017 which has 16 GPIOs. I can use say 4 MCP23017s and can therefore control 64 DHT22 or other sensors or relays.

Stackable 8-relay add-on supports up to 64 relays per Raspberry Pi
http://linuxgizmos.com/stackable-8-rela ... pberry-pi/

PiFace Stackable Relay Plus
http://www.piface.org.uk/products/piface_relay_plus/
Attachments
HSPeMKt[1].jpg
HSPeMKt[1].jpg (41.5 KiB) Viewed 1341 times
Last edited by tlfong01 on Fri Aug 03, 2018 1:03 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Aug 02, 2018 4:55 am

tlfong01 wrote:
Thu Aug 02, 2018 3:41 am

Rpi 3B+ Very Good
To summarize, Rpi3B+ is very good, compared with the very slow, not very compatible Rpi Zero and Rpi Zero W.

I decided to forget both Rpi Zeros and will use two identical Rpi3B+ 2017 for paired hardware and software development projects.

Now I am going to replace the slow RpiZW (the big pink dot) by the fast Rpi3B+.
Attachments
RxqZ3hr[1].jpg
RxqZ3hr[1].jpg (82.94 KiB) Viewed 1322 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Aug 02, 2018 6:51 am

tlfong01 wrote:
Thu Aug 02, 2018 4:55 am
Now I am going to replace the slow RpiZW (the big pink dot) by the fast Rpi3B+.

So I have swapped the stupid RpiZW by the smart Rpi3B+, which booted without any problem. I ran the old python program to read the RTC temperature and everything looked good.

The actual Rpi swapping is summarized below:

  • 1. Loosen 4 nuts and remove RpiZW from brass stands.
  • 2. Remove a Dupoint 10 x 2 female (5V/3V, I2C).
  • 3. Remove 5 more plugs: USB power, HDMI, mouse and keyboard adapter, USB hub.
  • 4. Do the above in reverse to swap in the Rpi3B+.
The Rpi swapping takes not that many seconds, not much longer than the Formula One guy Hamilton swaps his mercedes in the middle of a race.

update 2018aug02hkt2214

I backed up another copy of SD card.

Rpi3B+ copies 16G speed 10 to 16GB speed 10 only takes 12 minutes!

I found that progress bar behaves normally, ie, the blue portion no longer in the Rpi Zero W case, misleadingly stays almost no change for almost all the copying time. The blue part moves as the copying progresses.
Attachments
QwQly1Q[1].jpg
QwQly1Q[1].jpg (104.7 KiB) Viewed 1297 times
Last edited by tlfong01 on Thu Aug 02, 2018 2:23 pm, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Thu Aug 02, 2018 1:12 pm

tlfong01 wrote:
Mon Jul 02, 2018 10:13 am
Actually I am not too sure if I can sleep well to night, because I might have a bad dream of KY019 relay testing.

For a peaceful mind, I have bought a digital mains meter which can set over power alarm value. I have summarized the user guide and will test it tomorrow.

Peacefair PZEM-011 Digital Panel Voltameter Power Meter User Guide
https://www.aliexpress.com/store/produc ... 56d3DQmQFd

1. Select back lit on/off mode
1.1 Presss light bulb key to toggle back lit on/off mode. Bak lit on/off mode will be stored at power off.

2. Select Power/Energy diswplay mode
3.1 Sort press the spanner key toggle power/ energy display mode. Display mode will be stored at power off.

3. Reset energy usage
3.1 Long press spanner key for at least 3 seconds until display blinks, then release key.
3.2 Short press key once to exit reset state, with energy usage cleared.
3.3 If no key pressed within 10 seconds, will exit without clearing energy usage.
3.2 If key pressed again within 10 seconds, will exit without clearing energy usage.

4. Set power alarm threshold
4.1 Long press light bulb key for at least 3 seconds until display blinks, then release key.
4.2 Power area current alarm last digit will blink, short press light bulb key to increase digit value.
4.3 Short press spanner key to select digit.
4.4 Long press spanner key for at least 3 seconds, or no operation for at least 10 seconds, alarm value will be stored and exit alarm setting mode.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Relay Module KY-019 5V

Fri Aug 03, 2018 9:22 am

Mortimer wrote:
Wed Jul 25, 2018 8:31 am
tlfong01 wrote:
Mon Jul 23, 2018 7:49 am
Mortimer wrote:
Thu Jul 05, 2018 9:31 am
1. With exposed mains the connector should have been secured, so that you could work safely in the knowledge that connector with dangerous Voltages was not going to move in an unexpected way.

2. Good isn't he, I watch far too much "Big Clive" (and Julian Ilett and John Ward if I'm honest!!).
Lastly, it looks like you're having way too much fun!! :mrgreen:

2. Yes, watching Big Clive is fun, and as I said, his video is educational. BTW, I saw him using a big digital mains meter to check things out. I thought I should also get a digital mains meter and tearing down and checking out things like him.

I googled around and found a cheap mains meter seemingly good for newbies, and I am learning how to use it. The meter has a over power alarm setting. This should be good to limit signal alarm of any over power from the KY019 relay switch box.

1. Yes, when I wired the mains meter, I found that if I secure the whole thing and let no wires moved unexpectedly, then it should be very safe. I also grounded the metal support properly, so no worries of electric shock.

BTW, I always vaguely thought that the mains in my home is 200V. But my new meter says it is 229V, almost 230V! This reminds some years ago I used my digital storage scope to display the mains voltage . But the circuit breaker immediately tripped. I guess my scope's signal ground is somehow connected to the mains ground. I was frightened and never try that again.
Attachments
T9RuDzE[1].jpg
T9RuDzE[1].jpg (41.74 KiB) Viewed 1233 times
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”