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

Re: Reading old weight scale

Wed Dec 05, 2018 2:01 am

tlfong01 wrote:
Tue Dec 04, 2018 2:02 pm
MCP23017 Troubleshooting notes - setting up another RPi
Raspbian Stretch Version:November 2018 Release date:2018-11-13 Kernel version:4.14
Part B - Create Boot SD Card
D:/rpi_stretch_2018dec04/work2/2018-11-13-raspbian-stretch-full.img
Win10 quick format SD card, SDFormatter V4.0 quick format SD card
Win32DiskImager - 1.0 to copy image to SD card
Copy image to SD card Master copy, Copy 0 (speed 6MB/s to 15 MB/s, Total time about 7.5 min) , ...

Rpi SD Card Copying Newbie Mistakes

I am making more SD card copies because I often made newbie mistakes which ordinary linux users will not make, and I don't have enough knowledge to understand what goes wrong. For example, I don't know what is alias, why use “./” in front of file names, what is environment etc. When I tried to update software, for example, last time from Lua 5.1 to 5.3, I found one update method did not work, then tried another one, and yet another one, ending a big mess and could not recover. So I needed to use a new SD card, and needed to install all the tools again, wasting hours, ... :(

So the lesson learnt is to make more copies of SD card at the end of a development stage, or so called a milestone, so in case I made a mistake and messed up the raspbian os, I can fall back to a previous version SD card, ...

Part B - Create Boot SD Card continued, ...

Note: I tried 32GB card but found only 16GB detected. I am not sure if I can expand it later expand it. So for now it is better to use 8GB or 16GB cards.

/ to continue, ...


...
Attachments
rpi_sd_card_copy_problem_2018dec0501.jpg
rpi_sd_card_copy_problem_2018dec0501.jpg (142.87 KiB) Viewed 1758 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: Reading old weight scale

Wed Dec 05, 2018 3:26 am

tlfong01 wrote:
Wed Dec 05, 2018 2:01 am
So the lesson learnt is to make more copies of SD card at the end of a development stage, or so called a milestone, so in case I made a mistake and messed up the raspbian os, I can fall back to a previous version SD card, ...
Note: I tried 32GB card but foundonly 16GB detected I am not sure if I can expand it later expand it. So for now it is better to use 8GB or 16GB cards.

8GB SD card good for newbies

I am trying 8/16/32 GB cards. I found the most popular SanDisk 8GB (HD video, microSDHC) best for newbies. It is cheap, format and transfer data quick. So far I have no problems.

The steps are:

1. Use Win10 quick format, using all default options.
2. Use Win10 SDFormatter 4.0 qucik format, using all default options.
3. Use Win10 DiskImager 1.0 to copy image to SD card.

4. Use Win10 remove USB card command before physically remove SD card, or Win10 will be confused and show ghost disks already removed.

...
Attachments
rpi_sd_card_8gb_ok_2018dec0502.jpg
rpi_sd_card_8gb_ok_2018dec0502.jpg (174.7 KiB) Viewed 1751 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: Reading old weight scale

Wed Dec 05, 2018 4:10 am

tlfong01 wrote:
Wed Dec 05, 2018 3:26 am
So the lesson learnt is to make more copies of SD card at the end of a development stage, or so called a milestone, so in case I made a mistake and messed up the raspbian os, I can fall back to a previous version SD card, ...
8GB SD card good for newbies

Made 7 SD boot cards, ready to boot Rpi and config Raspbian stretch

Now I have copied 7 SD cards and put them in my high class plastic SD card safe. The time has time to check out if these cards can boot Rpi. :mrgreen:

...
Attachments
sd_card_safe_2018dec0501.jpg
sd_card_safe_2018dec0501.jpg (181.57 KiB) Viewed 1743 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: Reading old weight scale

Wed Dec 05, 2018 5:41 am

tlfong01 wrote:
Wed Dec 05, 2018 4:10 am
Made 7 SD boot cards, ready to boot Rpi and config Raspbian stretch
Now I have copied 7 SD cards and put them in my high class plastic SD card safe. The time has time to check out if these cards can boot Rpi.

Newbie notes on setting up Rpi Raspbian Version 2018Nov Desktop

Raspbian version 2018nov is more newbie friendly than before, no more confusions on UK/US English and keyboard settings, all GUI, no scary terminal sudo commands, :mrgreen:

My settings are summarized below:

Part C - Rpi Desktop Setup Notes V0.1 2018dec05hkt1246

C.0.01 Boot rpi with 8GB Raspbian Stretch Version November 2018 (release date 2018-11-13) Kernal 4.4 SD card.
C.0.02 Setup Rpi Desktop.
C.0.03 Set country - Hong Kong SAR China, Cantonese, TimeZone Hong Kong, Use US Keyboard.
C.0.04 Change password from default 'raspberry' to '**', donot hide characters.
C.0.05 Select WiFi Network - 'tlfong01'from list of seven displayed wifi network.
C.0.06 Enter wifi password '*********', do not hide characters.
C.0.07 Update software start 12:50 finish 13:03 Total 13 min.
C.0.8 Reboot (for new setting to take effect).
C.0.9 Preferences > Keyboard and Mouse > use all defaults, no new settings for Logitec wireless keyboard and mouse.
C.0.10 Preferences > Rpi Configuration >
System - use all defaults.
Interfaces - Enable SPI. I2C, Serial Port, 1-Wire, (4) DISABLE Camera, SERIAL CONSOLE, SSH, VNC, Remote GPIO (5).
Performance - use defaults, no change.
Localization - Language = yue(Cantonese)default, character = UTF-8 (default), timezone = Asia Hong Kong (default).
Keyboard = Generic 105-key (Intl)PC, Layout = English (US), Variant = US (all default).
Wifi country = Hong Kong (default).
C.0.11 Reboot for settings to take effect (less than 1 min).
C.0.12 Programming displays Geany, mu, Node-Red, Python 3 (IDLE) (Python 2 no show! :mrgreen: ), Thonny.
C.0.13 Python 3 = 3.5.3 (default, Sep 27, 2018), print('hello world') OK

Old config methods

I am not too sure if I still need to do some fine settings, using terminal commands. So I list the old 2015-2017 methods below, just in case I need to fall back to the old methods, fiddling the scary things like device trees, config files, etc, using the ugly editing program call 'nano', ... :(

Raspbian Desktop > Assessory > SD Card Copier to make copies

Now I am using the SD card copier to duplicate SD cards, between 8/16/32GB cards. Each 8GB to 8GB copy takes about 15 minutes.

...

Code: Select all

*** stretch version 2018nov setup notes - 2018dec05hkt1421

Part A - Download 2018nov stretch to Win10 hard disk directory

Raspbian Stretch with desktop and recommended software - 2018dec04hkt2104
https://www.raspberrypi.org/downloads/raspbian/

Image with desktop and recommended software based on Debian Stretch
Version:November 2018
Release date:2018-11-13
Kernel version:4.14
Release notes:Link
Download TorrentDownload ZIP
SHA-256: 0ca644539fdaf4e19ec7cebf9e61c049b82ba45b1a21cdec91fa54bd59d660d2

Start 2018dec04hkt21:05 Finish 21:59 TotaL download time = 54 min

29b88e98b94aca1dde6bbf5bce3f3a382f7f89f2b166b570587369ddd6109832

Part B - Create Boot SD Card

1.0 Extract image from downloaded zip file.
1.1 D:/rpi_stretch_2018dec04/work2/2018-11-13-raspbian-stretch-full.img
1.2 Win10 quick format SD card
1.3 SDFormatter V4.0 quick format SD card (must!)
1.4 Win32DiskImager - 1.0 to copy image to SD card
1.5 Generate SHA256 hash = 29b88e98b94aca1dde6bbf5bce3f3a382f7f89f2b166b570587369ddd6109832
1.6 Copy image to SD card Master copy, Copy 0 (speed 6MB/s to 15 MB/s, Total time about 7.5 min)
1.7 Copy more SD cards Copy 1, 2, 3, ...


Part C - Rpi Desktop Setup Notes V0.1 2018dec05hkt1246

C.0.01 Boot rpi with 8GB Raspbian Stretch Version November 2018 (release date 2018-11-13) Kernal 4.4 SD card.
C.0.02 Setup Rpi Desktop.
C.0.03 Set country - Hong Kong SAR China, Cantonese, TimeZone Hong Kong, Use US Keyboard.
C.0.04 Change password from default 'raspberry' to '**', donot hide characters.
C.0.05 Select WiFi Network - 'tlfong01'from list of seven displayed wifi network.
C.0.06 Enter wifi password '*********', do not hide characters.
C.0.07 Update software start 12:50 finish 13:03 Total 13 min.
C.0.8 Reboot (for new setting to take effect).
C.0.9 Preferences > Keyboard and Mouse > use all defualts, no new setting for Logitec wireless keyboard and mouse.
C.0.10 Preferences > Rpi Configuration > 
        System - use all defaults.
        Interfaces - Enable SPI. I2C, Serial Port, 1-Wire, (4) DISABLE Camera, SERIAL CONSOLE, SSH, VNC, Remote GPIO (5).
        Performance - use defaults, no change.
        Localization - Language = yue(Cantonese)default, character = UTF-8 (default), timezone = Asia Hong Kong (default).
                       Keyboard = Generic 105-key (Intl)PC, Layout = English (US), Variant = US (all default).
                       Wifi country = Hong Kong (default).
C.0.11 Reboot for settings to take effect (less than 1 min). 
C.0.12 Programming displays Geany, mu, Node-Red, Python 3 (IDLE) (Python 2 not shown!), Thonny.
C.0.13 Python 3 = 3.5.3 (default, Sep 27, 2018), print('hello world') OK      


*** rpi stretch version 2018apr setup notes - 2018 apr22hkt2231 ***

*** Config 1, Basic ***

01. boot with the rpi image
02. gui menu > rpi configuration >
03. > system = no change, all default
04. > interface = enable spi, i2c, serial
05. > performance = no change
06. > localization >
07. > Locale =language - en(English), country - country - HK (Hong Kong SAR China), Character set - no change (UTF-8)
08. > Timezone = Hong Kong
09. > Keyboard = Country - United States, Variant - English (US) [top of menu], [type symbols hatch, tilter, single/double, to check]
10. > Wifi Country Code - HK Hong Kong
11. > reboot rpi

*** Config 2, Wifi, Python ***

01 Turn on Wifi [top left menu bar] select "tlfong01", enter Pre Shared Key - "s*******1", [wifi icon blinking!]
02 Use wb browser Chomium to visit tlfong01.com, showing simplified Chinese characters
03 Bluetooth = no bluetooth adapter found
04 Python = 3.5.3 [default 2017jan19]

*** Backup SD card image ***

01  Copy Stage 1 master to work 1 [Application menu > Accessories > 
      > SD Card Copier [copy from SD16G (/dev/mmcblk0) ToTS-RDF5 Transcend (/dev/sda) 27 minutes 
02 Boot from Work 1, Copy work 1 to work2 [error: could not mount partition]
03 Copy from Work 1 to Work 2, 21 minutes, 16 minutes


*** Old config notes 2018apr23 ***

*** rpi stretch version 2017nov29 setup notes - 2017dec02hkt1316 ***

1. Download Raspbian stretch version 2017nov29  zip file to PC Win10 directory.

    1.1 SHA-256:64c4103316efe2a85fd2814f2af16313abac7d4ad68e3d95ae6709e2e894cc1b

2.  Extract image to Win10 directory D:/rpi_stretch_2017nvo29/image/work/2017-11-29-raspbian-stretch.img

3.  SD formatter to format 8G SD card (F: boot 41MB)

4. Win32 Disk Manager to copy image file to SD 

    4.1 Generate SHA256 = 1fc5a29c33b0fa31a98c2aee188a257cafa037aea61115b8d2191214be77765a

    4.2 Write to SD card (8GB HC1 4, about 5MB/s, start 1314 finish 1512 = 2 minutes)

   4.3  Verify = failute at sector 8192 ???

    4.4 Write second copy (8GB Ultra HC I 10, 38MB/s, 2.03 minutes) 

    4.5 Write third copy (16GB Ultra HC I 10, 38MB/s, 2.03 minutes)

    4.6 Write fourth copy (same as above, 2.03 minutes)

3. Use DiskManager to copy to 8GB micro SD card (MD5 hash = 2fe69d3610f541ee5f656cef50147a0f, 2fe69d3610f541ee5f656cef50147a0f).  
    speed 4, start 17:08, 5MB/s, end 17:24, (named it s0c0, verify failed at sector 8192, but booted ok)

4. Make 2nd copy, named it S0C1 speed 10, start17:34, 28MB/s, end 17:37, 3 minutes.

5. Make 3rd copy S0C3, speed 10, start 1742, end 1745, 3 minutes.  Copy 4 10Mb/s start 20:17 end 20:24 7 minutes (all booted OK)

*** 2017aug19 backup Jessie stg4 2017aug19 ***

1. read 8GB stg4 sd to PC Win10 D:/work/rpi3b/raspbian_jessie/jessie_stg4_2017aug1901.img

2.  Win32 Disk Manager generate MD5 

3. Format new 16GB sd card by Win10, then SD Formatter.

4. Generate MD5 hash = 859aadd40b85d88645252c3304c043b9

4.  Write to 16GB sd card (11MB/s, 11 min)

*** 2017-08-16 rpi3B raspbian-stretch setup notes v1.0 2017aug18hkt1630 ***

Part 1 - Create boot image

1. Download Raspbian stretch 2017-08-16  zip file (1.8GB) extract image (4.8GB), 

2. Use DiskManager to copy to 8GB micro SD card (MD5 hash = 2fe69d3610f541ee5f656cef50147a0f, 2fe69d3610f541ee5f656cef50147a0f).  
    speed 4, start 17:08, 5MB/s, end 17:24, (named it s0c0, verify failed at sector 8192, but booted ok)

3. Make 2nd copy, named it S0C1 speed 10, start17:34, 28MB/s, end 17:37, 3 minutes.

4. Make 3rd copy S0C3, speed 10, start 1742, end 1745, 3 minutes.  Copy 4 10Mb/s start 20:17 end 20:24 7 minutes (all booted OK)

Part 2 - Config rpi stretch

1. Back up home directory pi folders to usb flash memory stick

2. Boot RPi3 with the following connected: HDMI wireless keyboard, mouse, Ethernet cable, USB hub with 2 16GB USB fingers.

3. Use Chromium to visit tlfong01.com, does not display Chinese characters.  

4. Connect to WiFi tlfong01, with password *******, tried Chromium and set it as default browser.

5. Preferences > Raspberry Pi Configuration > System > no change, keep all defaults

6. Interface > enable 4 interfaces: SSH, SPI, I2C, Serial

7. Performace > no change

8. Loalization > Set Locale > Language: en(English), Country: HK Hong Kong SAR (China), Character: UTF-8 (no change)

9. > Set Time Zone > Area: Asia, Location: Hong Kong

10. > Set Keyboard ?? no response???

11. > Set WiFi Country

12. Reboot now

13. After reboot, Preferences > Set Mouse and Keyboard > Mouse: no change, Keyboard > Keyboard Layout > Country:United States, Variant: English (US) (top of pull dow menu) (type characters Dollar, at sign, tildre etc) 

14. Terminal mode
      $ groups to find i2c, spi
      $ ls -l  /dev/spi* to find /dev/spidev0.0, /dev/spidev0.1
      $ ls -l  /dev/i2c* to find /dev/i2c-1 
      $ ls -l /dev/ttyA* to /dev/ttyAMA0

15. Check Python 3
$ sudo python3
Python 3.5.3
>>> print('hello world')
ctrl-z to exit python

16. $ sudo apt-get update (< 2 min)
      $ sudo apt-get -y upgrade (< 2 min)  
      $ sudo shutdown now

17. This is the end of stage 1 configuration.  2017aug18hkt2110

*** Part 3 - Use Win32 Disk Manager to back up stretch stage 1 image from 8G microSD to 16GG microSD ***

1. Use Win32 Disk Manager to read 8GB image to file .../stretch_stg1_2017aug1801.img (35Mb/s, < 5 minutes, USB3 hub. Aspire core i5  Win10 64 bit

2. Generate MD5 hash 60f2f52b16d7ffcacff392e2837c1d05 and write to 16GB microSD (speed 1, 12 MB/s 10 minutes) start 21:26

3. Make 2nd copy of stretch stage 1 on 16GB microSD (12 MB/s, 11 minutes) 60f2f52b16d7ffcacff392e2837c1d05 13MB/s 10 min

*** Part 4 - Use rpi-clone to back pu 16GB sd to 8GB sd ***

4. Install rpi-clone
    $ https://github.com/billw2/rpi-clone and download the zip file:
    $ unzip rpi-clone-master.zip
    $ cd rpi-clone-master
    $ sudo cp rpi-clone /usr/local/sbin

5. Clone Stage1 16GB sd to 8GB sd (name it stg1c1gb8
    $ sudo rpi-clone -f sda  (14 minutes)

6. Boot with stg1c1gb8 and clone stg1c2gb8

2017aug19hkt1223 .END

e GUI web browser to check Ethernet connected.

3. Click GUI WiFi icon to find list of Wifi networks to connect, select network and enter password to connect.

4. Click GUI Bluetooth icon to set Raspberry Pi discoverable. Use Samsung Android phone to make phone visable to all nearby devices. Try pair and unpair Raspberry Pi. 

5. GUI > Menu > preferences > Mouse and Keyboard setting > Keyboard layout >  Country United States, Variant English (US) check "hatch" and "at".

6. GUI > Menu > preferences > RPI config > system > File system expand file system

7. RPI config > system > host name and password no change (hostname = raspberrypi and user = pi)

8. RPi config > interfaces Enable SPI, I2C, Serial

9. RPi config > Locale - Language = en (English), Country = HK (Hong Kong), Character Set = UTF-8, Time zone Hong Kong, WiFi country code HK (Hong Kong)

10. Reboot and check SPI,  I2C, and serial
$ groups to find i2c, spi
$ ls -l  /dev/spi* to find /dev/spidev0.0, /dev/spidev0.1
$ ls -l  /dev/i2c* to find /dev/i2c-1 
$ ls -l /dev/ttyA* to /dev/ttyAMA0

11. Check Python 3
$ sudo python3
Python 3.5.3
>>> print('hello world')

*** RPi 3 serial setup notes - 2016jul03hkt2202 ***

Ref - https://www.abelectronics.co.uk/kb/article/1035/raspberry-pi-3-serial-port-usage

1.  Disable built in Bluttooth modem

Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth.
sudo nano /boot/config.txt
Add at the end of the file
dtoverlay=pi3-miniuart-bt
Exit the editor saving your changes and then:
sudo reboot

2. To enable the serial console, you need to edit the /boot/cmdline.txt file

sudo nano /boot/cmdline.txt
Change the file to the following:
dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Exit and save your changes

3. To  check serial loopback using minicom (WANING !!! do not use cutecom !!!)
* $ sudo apt-get install minicom 
* short Tx to Rx for testing loopback
* $ minicom -b 9600 -o -D /dev/ttyAMA0
* type any text to loop back
* ctrl-A Z for help, ctrl-A X to exit

*** Raspberry Pi 3 Serial Port Usage - AB Electronics UK 19/03/2016 *** 

https://www.abelectronics.co.uk/kb/article/1035/raspberry-pi-3-serial-port-usage

How to use the serial port on your Raspberry Pi 3 with a Serial Pi from AB Electronics UK

You can use the Serial Pi Plus with your Raspberry Pi 3 if you disable the built in Bluetooth modem as this is maped to the hardware UART by default and the "mini uart" on the Raspberry Pi 3 GPIO pins is not stable when the processor is under load and the baud rate changes.

For Raspbian Jessie releases after 18th March 2016

There is now a device tree file called pi3-miniuart-bt which makes the Raspberry Pi 3 disable the Bluetooth and map pl011 UART on pins 14 and 15 as before.

Step 1 - Install Raspbian Jessie onto a SD card and boot the Pi when connected to a network

Login via terminal or desktop and shell

Configure the system with:

sudo raspi-config

Expand filesystem and enable serial on advanced page, exit and reboot. <<<<<<<<<<

Update the system with:

sudo apt-get update
sudo apt-get upgrade

Step 2:  Device Tree settings as below:

Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth. <<<<<<<<<<

sudo nano /boot/config.txt
Add at the end of the file

dtoverlay=pi3-miniuart-bt
Exit the editor saving your changes and then:

sudo reboot
Enabling the Serial Console Rasbian Jessie after 18th March 2016 release

To enable the serial console, you need to edit the /boot/cmdline.txt file

sudo nano /boot/cmdline.txt
Change the file to the following:

dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Exit and save your changes

With the serial console enabled you should now have the boot commands and login prompt when connected at 115200 baud.

***

$ Check /dev/ttyAMA0
* $ ls -l /dev/ttyA* (to find /dev/ttyAMA0)

$ Serial loopback using minicom (WANING !!! do not use cutecom !!!)
* $ sudo apt-get install minicom 
* short Tx to Rx for testing loopback
* $ minicom -b 9600 -o -D /dev/ttyAMA0
* type any text to loop back
* ctrl-A Z for help, ctrl-A X to exit

---

Setup notes 2016jun03hkt1528 

1. Download Raspbian Jessi version May2016 zip file (1.3GB) extract image (3.74GB), use DiskManager to copy to 16GB SD card.

2. Boot RPi3 with the following connected: HDMI wireless keyboard, mouse, Ethernet cable, USB hub with 2 16GB USB fingers.

3. Use GUI web browser to check Ethernet connected.

3. Click GUI WiFi icon to find list of Wifi networks to connect, select network and enter password to connect.

4. Click GUI Bluetooth icon to set Raspberry Pi discoverable. Use Samsung Android phone to make phone visable to all nearby devices. Try pair and unpair Raspberry Pi. 

5. GUI > Menu > preferences > Mouse and Keyboard setting > Keyboard layout >  Country United States, Variant English (US) check "hatch" and "at".

6. GUI > Menu > preferences > RPI config > system > File system expand file system

7. RPI config > system > host name and password no change (hostname = raspberrypi and user = pi)

8. RPi config > interfaces Enable SPI, I2C, Serial

9. RPi config > Locale - Language = en (English), Country = HK (Hong Kong), Character Set = UTF-8, Time zone Hong Kong, WiFi country code HK (Hong Kong)

10. Reboot and check SPI,  I2C, and serial
$ groups to find i2c, spi
$ ls -l  /dev/spi* to find /dev/spidev0.0, /dev/spidev0.1
$ ls -l  /dev/i2c* to find /dev/i2c-1 
$ ls -l /dev/ttyA* to /dev/ttyAMA0

11. Check Python 3
$ sudo python3
>>> print('hello world')

********** old setup notes 2016jun03 **********

Setup notes 2016jun03hkt1505

1. Download Raspbian Jessi version May2016 zip file (1.3GB) and extracted the image (3.74GB), and use DiskManager to copy to 16GB SD card.

2. Boot with the following connected: HDMI wireless keyboard, mouse, Ethernet cable, USB hub with 2 16GB USB fingers.

3. Use web browser to make sure wired Ethernet connected.

3. Click GUI WiFi icon to find Wifi network to connect to, enter password and check if connected (gui wifi icon to check connected to tlfong01 network.

4. Click GUI Bluetooth icon to make Raspberry Pi discoverable. Use Samsung Android phone setting to make phone visable to all nearby devices. Try pairing and unpairing Raspberry Pi. 

*** Setup notes 2016jun02hkt2116 ***

1. Download Raspbian Jessi version May2016 zip file (1.3GB)

https://www.raspberrypi.org/downloads/raspbian/

2. Extract image for zip file (3.74GB)

3. Use Windows Disk Manager to copy image file to 16GB SD card

Before copying, no need to erase SD card first, but generate MD5 hash first.

Copying speed about 9MB per second.

From Linux guide - In Windows, the SD card will appear only to have a fairly small size once written - about 55 to 75 MB. This is because most of the card has a partition that is formatted for the Linux operating system that the Raspberry Pi uses which is not visible in Windows. If you don't see this small directory with files such as kernel.img then the copy may not have worked correctly.

.END

---

Raspbian jessie v4.1 installation notes - tlfong01 2016feb

Stage 1 Installation 2016feb10 

$$$ Prepard jessie image $$$
* Download raspbian jessie zip file (2016-02-09 v4.1).
* Extract jessie image to Win7 PC.
* Format 8G SD card (Sandisk Ultra)
* Copy image to 8G SD card (8~10MB/s)

$$$ Update/upgrade jessie
* Boot RPi USB connected to Logitech keyboard, mouse wireless adapters, WiFi apapter, Cat5 Ethernet LAN cable
* Boot with keypad, mouse, ethernet cable, usb hub, no wifi dongle, all connected
* Desktop GUI mode > screen top main menu > Terminal mode
* $ sudo apt-get update (< 2 min)
* $ sudo apt-get -y upgrade (< 2 min)  
* $ sudo shutdown now

$$$ Install Wifi adapter $$$
* Remove LAN cable, press reset button to reboot (no need to hardware power off/on)
* $ lsusb to find RALink Tech (TP Link TL WN727n 150Mbps adapter)
* $ sudo iwlist wlan0 scan to find ESSID: "tlfong01" ...
* $ sudo reboot
* Use Epiphany web browser to find google.com

$$$ Config jessie $$$
$ Desktop > Raspberry Pi Config 
* Interfaces = enable SSH, SPI, I2C, Serial (warning - must also need to modify /boot/config.txt
* Localization 
* - Locale - Language = en (English), Country = HK (Hong Kong), Character Set = UTF-8
* - Timezone = Asia > Hong Kong
* - Keyboard - Country = United States, Variant = English (US) (type hatch = hatch, not Pound)
* Sudo shutdown now
$ Stage 1 installation complete
$ Notes 
* - Do not expand file system, otherwise might have SD card cannot write back problem
* - No need to config Logitech keyboard using terminal mode Raspi Config

$$$ Backup jessie 4.1 stage 1 image file $$$
* Read sd card jessie v4.1 stage 1 image installation to WinPC (~ 8 min)
* Keep SD card as backup
* Write stage 1 image to second 8GBSD card as working copy  (2016-02-10)

$$$ Stage 2 Installation 2016feb11 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

$$$ config Serial $$$
$ Check /dev/ttyAMA0
* $ ls -l /dev/ttyA* (to find /dev/ttyAMA0)
$ Disable boot serial log in
* $ sudo systemctl mask serial-getty@ttyAMA0.service
* $ sudo reboot

$ Test serial loopback using minicom 
* $ sudo apt-get -y install minicom 
* short Tx to Rx to test loopback
* $ minicom -b 9600 -o -D /dev/ttyAMA0
* type any text to loop back
$ Notes - ctrl-A Z for help, ctrl-A X to exit
$ Warning - do NOT cutecom which give strange errors!!!)

$$$ Install pyserial-3.0.1 (not sure if the installed default works for python3)
* Google "python pyserial" to navigate to pyserial 3.0.1 Python Package Index
* Download pyserial-3.0.1.tar.gz (should be downloaded to pi/downloads)
* Copy the downloaded file from pi/downloads to pi/) 
* gunzip -c pyserial-3.0.1.tar.gz | tar xf -  (hyphen at the end of line is NECESSARY. will be unzipped to pi/pyserial-3.0.1)
* cd pyserial-3.0.1
* sudo python3 setup.py install 
* sudo reboot
* sudo python3 
* >>> import serial (no error message)

$$$ Enable I2C and SPI in /boot/config.txt $$$
* cd /boot
* sudo nano config.txt
* uncomment the following 3 statements (somewhere near end of file).
    dtparam=i2c_arm=on
    dtparam=i2s=on
    deparam=spi=on
* sudo reboot
* $ ls -l /dev/spi*
* $ ls -l /dev/i2c*

$$$ Check I2C SPI $$$

$ Check SPI and I2C
* Check groups - $ groups [... gpio, i2c, spi]
* Check SPI - $ ls -l /dev/spi* [/dev/spidev0.0, /dev/spidev0.1]
* Check I2c - $ ls -l /dev/i2c* [/dev/i2c-1]

$ Install SPI (spidev-3.1)
* Google "python spidev" > python package index > spidev3.1
* Download spidev-3.1.tar.gz (by default to pi/downloads) 
* Note - can also download by wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
$ Note - Appears unnecessary to unzip and install, seems automatically installed 
$ Copy spidev-3.1.tar.gz from pi/download to pi/
$ gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
* cd spidev-3.1 [spidev will be installed in home/spidev-3.1]
* sudo python3 setup.py install [message = ... writing to /usr/local/lib/python3.4/dist-packages/spidev-3.1.egg-info]
* sudo reboot
$ Check python3 can import spidev
* sudo python3
* import spidev (should import OK, ctrl-d to exit python)

$ Install i2c-tools
* $ sudo apt-get -y update
* $ sudo apt-get -y install i2c-tools
* $ i2cdetect -y 1 (to find i2c device table, with no devices listed)

$ Install Python3-smbus
* sudo apt-get -y install python3-smbus.
* sudo python3
* >>> import smbus [should return no error message]

$ Backup stage 2 image

$$$ Stage 2 installation end 2016feb11hkt1432 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

.END

setting i2c speed to 32k 2016feb08hkt1142 - not successful!!!

https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=77584

$ /etc/modules: kernel modules to load at boot time.
$
$ This file contains the names of kernel modules that should be loaded
$ at boot time, one per line. Lines beginning with "$" are ignored.
$ Parameters can be specified after the module name.

$snd-bcm2835
i2c-bcm2708 baudrate=400000 ??? or bcm2835???
i2c-dev

both bcm2708 and bcm2835 refers to the cpu.  Technically 2708 is the family, and 2835 is a specific implementation.

$$$ Jessie 2015-11-21 setup notes v3.5 2016jan19hkt1456 $$$

$$$ Download jessie image 2016jan17 $$$

* Download zip file 2015-11-21-raspbian-jessie.zip (1,392,601 KB)
* Extract jessie image file 2015-11-21-raspbian-jessie.img (3,842,048 KB)

$$$ SD card preparation 2016jan18 $$$

* SDFormatter V4.0 to quick format (logic size disabled) 8GB SD card (appears as Windows 7 Drive P:, size 114MB, Volume Label   RECOVERY).   Takes a few seconds (File system FAT32, Total space 7.41 GB (7,960,788,992 Bytes) Cluster size = 32768 Bytes
* Win32 Disk Manager V0.9.5 to copy 2015-11-21-raspbian-jessie.img to SD card (Generate MD5 Hash before copying)

$$$ Stage 1 installation begin $$$

$$$ jessie update and upgrade 2016jan18 $$$

* Boot with keypad, mouse, ethernet cable, usb hub, no wifi dongle, all connected
* Desktop GUI mode > screen top main menu > Terminal mode
* $ sudo apt-get update (less than 5 minutes)
* $ sudo apt-get -y upgrade (-y = no need to say Yes to queston on freeing memory")  (around 30 minutes)  
* $ sudo shutdown now

$$$ Install WiFi dongle (TP Link TL WN727n 150Mbps) $$$
*  Remove Ethernet cable, replace with wifi dongle 
*  Boot
*  $ lsusb to find WLAN adapter [Standard Microsystems ... SMSC9512/9514 Fast Ethernet Adapter]
*  old $ lsusb to find WLAN adapter [Realtek RTL8192CU ... WLAN Adapter ...]
*  $ sudo iwlist wlan0 scan to scan WiFi network [ESSID: "tlfong01" ... 2.417G ... IEEE 802.11i/WAP2 ... encription key on]
*  Edit the wpa config file - $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
*  add the following network/password lines at the bottom of the 2 line file. 
*  Note - UK keyboard at (@) key = US keyboard double quote key.
*  network={
   ssid="tlfong01" 
   psk="my_wifi_password"
   }
* Note - no space allowed above.
* sudo reboot
* Desktop > Ephiant > google.com > tlfong01.com

$$$ Stage 1 installation end $$$

$$$ Stage 2 installation begin $$$

$$$ config Serial $$$
 
$ Disable boot serial log in
* $ sudo systemctl mask serial-getty@ttyAMA0.service
* $ sudo reboot

$ Check /dev/ttyAMA0
* $ ls -l /dev/ttyA* (to find /dev/ttyAMA0)

$ Serial loopback using minicom (WANING !!! do not use cutecom !!!)
* $ sudo apt-get install minicom 
* short Tx to Rx for testing loopback
* $ minicom -b 9600 -o -D /dev/ttyAMA0
* type any text to loop back
* ctrl-A Z for help, ctrl-A X to exit

$$$ Enable I2C and SPI in /boot/config.txt $$$
* cd /boot
* sudo nano config.txt
* uncomment the following 3 statements (somewhere near end of file).
    dtparam=i2c_arm=on
    dtparam=i2s=on
    deparam=spi=on
* sudo reboot
* $ ls -l /dev/spi*
* $ ls -l /dev/i2c*

$$$ Config RPi $$$
* Desktop > Raspberry Pi Config 
* Interfaces = enable SPI, I2C, Serial (warning - must also need to modify /boot/config.txt
* Localization 
* Set Locale - Language = en (English), Country = HK (Hong Kong), Character Set = UTF-8
* Set Timezone = Asia Hong Kong
* Set Keyboard - Country = United States, Variant = English (US) (type hatch = hatch, not Pound)
* Reboot

$$$ Check I2C SPI $$$

* Check I2c - $ ls -l /dev/i2c* [/dev/i2c-1]
* Check SPI - $ ls -l /dev/spi* [/dev/spidev0.0, /dev/spidev0.1]
* Check groups - $ groups [... gpio, i2c, spi]
* Check i2c-1 - $ i2cdetect -l [i2c1, i2c, ... I2C adapter]

* Install i2c-tools
* $ sudo apt-get update
* $ sudo apt-get install i2c-tools
* $ i2cdetect -y 1

* Install I2C (Python3-smbus)
* sudo apt-get install python3-smbus.
* sudo python3
* >>> import smbus [should return no error message]

* Install SPI (spidev-3.1)
* Google "python spidev" > python package index > spidev3.1
* Download spidev-3.1.tar.gz (by default to pi/downloads) 
* Note - can also download by wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
* Copy spidev-3.1.tar.gz from pi/download to pi/
* gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
* cd spidev-3.1 [spidev will be installed in home/spidev-3.1]
* sudo python3 setup.py install [message = ... writing to /usr/local/lib/python3.4/dist-packages/spidev-3.1.egg-info]
* sudo reboot
* sudo python3
* import spidev 

$$$ Install pyserial-3.0.1 (not sure if the installed default works for python3)
* Google "python pyserial" to navigate to pyserial 3.0.1 Python Package Index
* Download pyserial-3.0.1.tar.gz (should be downloaded to pi/downloads)
* Copy the downloaded file from pi/downloads to pi/) 
* gunzip -c pyserial-3.0.1.tar.gz | tar xf -  (will be unzipped to pi/pyserial-3.0.1)
* cd pyserial-3.0.1
* sudo python3 setup.py install 
* sudo reboot
* sudo python3 
* >>> import serial (no error message)

$$$ Stage 2 installation end 2016jan19hkt1453 $$$

*** Rpi setup notes 3.1 2015dec25hkt1701

$$$ Prepare SD card
* Extract 2915-09-24-raspbian-jessie.img (4,325,376,000) from downloaded zip file (2015-09-24-raspbian-jessie.zip, 1,332,985,407)
* Use SDFormatter to format 8GB sd card (FAT32, 7.41GB (7,960,788,992 Bytes), cluster size 32768 Bytes)
* Use Win32 Disk Imager to copy image to SD card (firt generate MD5 Hash) (speed 16MB/sec)

$$$ Install Jessie
* Boot with keypad, mouse, usb hub, wifi usb adapter, ethernet cable connected.

$$$ Config RPi
* Desktop > Raspberry Pi Config 
* Interfaces = enable SPI, I2C, Serial (warning - must also need to modify /boot/config.txt
* Locale - Language = en (English), Country = HK (Hong Kong), Character Set = UTF-8
* Timezone = Asia Hong Kong
* Keyboard - Country = United States, Variant = English (US) (type hatch = hatch, not Pound)
* Reboot

$$$$ Update jessie
* sudo apt-get update (otherwise python3 smbus won't work!)

$$$ Install WiFi dongle (TP Link)
*  Remove Ethernet cable (WiFi dongle already plugged in previously)
*  $ lsusb to find WLAN adapter [Realtek RTL8192CU ... WLAN Adapter ...]
*  $ sudo iwlist wlan0 scan to scan WiFi network [ESSID: "tlfong01" ... 2.4G ... IEEE 802.11i/WAP2 version 1 ...]
*  Edit the wpa config file - $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
*  add the following network/password lines at the bottom of the 2 line file.
*  network={
   ssid="tlfong01" 
   psk="my_wifi_password"
   }

$$$ Enable I2C and SPI in /boot/config.txt
* cd /boot
* sudo nano config.txt
* uncomment the following 3 statements (somewhere in the middel of the file).
* dtparam=i2c_arm=on
* dtparam=i2s=on
* deparam=spi=on
* sudo reboot

$$$ Install Serial (pyserial-2/7)  

* Install cutecom - sudo apt-get install cutecom (optional)
* $ cutecom 
* Enter device name /dev/ttyAMA0
* Open (error message - could not open /dev/ttyAMA0)
* $ ls -l /dev/ttyA* (to find /dev/ttyAMA0)
* Disable serial console login service permantly by the following.
  $ sudo systemctl mask serial-getty@ttyAMA0.service
 [return message: Creat symlink from ... to /dev/null] 
  $ sudo reboot

* Install cutecom - sudo apt-get install cutecom (optional)

* Search "pyserial", download pyserial-2.7.tar.gz
* Copy the downloaded file from pi/downloads to pi/
* gunzip -c pyserial-2.7.tar.gz | tar xf -  
* cd pyserial-2.7
* sudo python3 setup.py install [message = ... writing to .../egg.info]
* sudo reboot
* ls -l /dev/ttyAM* [found /dev/ttyAMA0]
* sudo python3 >>> import serial 

* $ sudo systemctl mask serial-getty@ttyAMA0.service
 [return message: Creat symlink from ... to /dev/null]
* $ sudo reboot

* $ cutecom (no need sudo), * enter devicename /dev/ttyAMA0

$$$ Install I2C (Python3-smbus)
* sudo apt-get install python3-smbus.
* sudo python3
* import smbus [must first update jessie, should return no error message]

$$$ Install SPI (spidev-3.1)
* ls -l /dev/spi* to find spi 0.0, 0.1
* Copy spidev-3.1.tar.gz from pi/download to pi/
* gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
* Install spidev
* cd spidev-3.1 [spidev will be installed in home/spidev-3.1]

*** RPi setup notes 3.0 2015dec25hkt1425 ***

1. Use SD Formatter 4.0 to formst 16GB SD card.

2. Copy installed NOOBS Jessie image, dated 2015nov17, from master 8GB SD card to Win7 PC, as a working image.

3. Copy the above working image from PC to 16GB SD card.

3. Boot RPi with the following connected: Keyboard, Mouse wireless adaptor, HDMI, Ethernet cable (WiFi usb adapter can be
   plugged in at the same time, but not working yet, because no password provided)

4. Check debian version - $ lsb_release -da [found Raspbian linux8.0 (jessie)]

5. Check host name - $ hostnamectl [found hostname: raspberrypi, os: Raspbian GNU/Linux 8 (jessie),
   Kernel: Linux 8 (jessie) Architecture: arm

6. Update jessie - $ sudo apt-get update

7. Upgrade jessie - $ sudo apt-get upgrade (takes more than one hour!)

8. Check browser - google.com very slow (takes a couple of minutes!)

9. Install WiFi dongle
9.1  Remove Ethernet cable (WiFi dongle already plugged in previously)
9.2  $ lsusb to find WLAN adapter [Realtek RTL8192CU ... WLAN Adapter ...]
9.3  $ sudo iwlist wlan0 scan to scan WiFi network [ESSID: "tlfong01" ... 2.4G ... IEEE 802.11i/WAP2 version 1 ...]
9.4  Edit the wpa config file - $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
9.5 add the following network/password lines at the bottom of the 2 line file.
9.6 network={
    ssid="tlfong01" 
    psk="my_wifi_password"
    }
9.7 Save file and sudo reboot.
9.8 Check Wifi adpator red LED blinking, and web browser working.

10. Config Rpi Localization
10.1 Desktop > Preferences > RaspberryPi Config > Localization
10.2 Set Locale - Language = en (English), Country = US (USA), Character = UTF-8
10.3 Set Timezone - Hongkong
10.4 Set Keyboard - Country = United States, Variant = English (US) [type "$" to test keyboard] 

11. Enable SPI, I2C, Serial, SSH
11.1 Desktop > Preferences > RaspberriPi Config > Interfaces - enable SPI, I2C, Serial
11.2 Reboot
11.3 Check I2c - $ ls -l /dev/i2c* [/dev/i2c-1]
11.4 Check SPI - $ ls -l /dev/spi* [/dev/spidev0.0, /dev/spidev0.1]
11.4 Check Serial - $ ls -l /dev/ttyAMA* [/dev/ttyAMA0]
11.5 Check groups - $ groups [... gpio, i2c, spi]
11.6 Check i2c-1 - $ i2cdetect -l [i2c1, i2c, ... I2C adapter]

12. Install I2C (Python3-smbus)
12.1 sudo apt-get install python3-smbus.
12.2 sudo python3
12.4 >>> import smbus [should return no error message]

13. Install SPI
13.1  Use browser to search "python spidev" > python package index > spidev3.1
13.2. Download spidev-3.1.tar.gz (by default to pi/downloads) 
13.3  Note - can also download by wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
13.4  Copy spidev-3.1.tar.gz from pi/download to pi/
13.5. gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
13.6. Install spidev
13.6.1 cd spidev-3.1 [spidev will be installed in home/spidev-3.1]
13.6.2 sudo python3 setup.py install [message = ... writing to /usr/local/lib/python3.4/dist-packages/spidev-3.1.egg-info]
13.6.3 sudo reboot
13.6.4 sudo python3
13.6.5 >>> import spidev 

14. Install pyserial-2.7 (not sure if the installed default works for python3)
14.1. Use browser to search "python pyserial" to navigate to pyserial 2.7 Python Package Index
14.2. Dwnload pyserial-2.7.tar.gz (should be downloaded to pi/downloads)
14.3. Copy the downloaded file from pi/downloads to pi/) 
14.4 gunzip -c pyserial-2.7.tar.gz | tar xf -  (will be unzipped to pi/pyserial-2.7)
14.5 cd pyserial-2.7
14.6 sudo python3 setup.py install [message = ... writing to .../egg.info
14.7  Disable serial console login service permantly by the following.
14.8. $ sudo systemctl mask serial-getty@ttyAMA0.service
 [return message: Creat symlink from ... to /dev/null]
14.9. $ sudo reboot
14.10 ls -l /dev/ttyAM* [found /dev/ttyAMA0]
14.11 sudo python3 >>> import serial (no error message)
14.12 sudo apt-get install cutecom (optional)
14.13. cutecom (no need sudo)
14.14. enter devicename /dev/ttyAMA0

.END

*** Rpi setup notes 2.9 2015nov18hkt1215 ***

A. Setting up SD card  (2015nov17hkt1715)

1. Use SD Formatter 4.0 to format 8GB (Kingston SDC10/8GB mad in Ta iWan) SD card with name UDISK5
2. Copy Jessie v1.1.4 NOOBS files (10 files, dated 2015feb18) to SD card
3. Boot RPi with the following connected: Keyboard, Mouse wireless adaptor, HDMI, Ethernet, USB hub
4. NOOBS v1.4 Built Feb18 2015 initializes.
5. Choose Language English (UK), Keyboard (US)
6. Setting up SD card for Raspbian Jessie v1.1.4 NOOBS (needed 3660MB, available 7448 MB) 
7. Setting up SD took 2 hours. Started 57% 74min, 100% 118 min (2996MB of 2996MB written, 0.4MB/sec) 
8. Downloading and extracting file systems (OS installed successfully, press OK to reboot) - 2 hours 7 minutes.
9. Reboot to GUI desktop OK - can read USB drive (/media/pi/UDISK2), Epihany web browser tested OK (duckduckgo search 
   very slow!!!)    
10. Win32DiskManager to read SD card image to Win7 harddisk file about 18MB/sec (with MD5 hash). about 8 minutes.
11. Win32DiskManager generateMD5 hash OK, to 16GB SD card at 13MB/sec, about 12 minutes. 
12. Boot up with 16GB SD card OK 20nov17hkt1546

B. Jessie update and upgrade )no need to do sudo rpi-date)

1. sudo apt-get update 2 minutes
2. sudo apt-get upgrade (25 minutes)

C. GUI Raspi-Config

1. Appearance - no change, use default
2. Audio device - no change
3. Main menu editor - no change
4. Mouse and keyboard setting
5. Mouse - no change (acceleration 2.0, sensititivty 10)
6. Keyboard layout (country United States, variant English(US), check pound/hatch, OR (vertical bard) keys OK
7. RPi configuration
8. System - no change (username, password etc)
9. Interface - enable SSH, SPI, I2C, serial, disable camera
10. Performance - no change (no overclock, GPU memory 64)
11. Localizatin (locale Language = en(English), Country = HK(Hong Kong), Character = UTF-8, Time zone = Asia, Hongkong
12. Keyboard - Country United States, Variant English (US)
13. Note - don't know how to set keyboard to Logitec generic, peraps in terminal mode, need to check later
18. Shutdown > reboot (2015nov17hkt1715)
    
D. Python3 SPI installation (2015nov17hkt1733)

1. Use browser to search "python spidev" > python package index > spidev3.1
2. Download spidev-3.1.tar.gz (by default to pi/downloads) 
3. Note - can also download by wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
4. Copy spidev-3.1.tar.gz from pi/download to pi/
5. gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
6. cd spidev-3.1 (spidev will be installed in home/spidev-3.1)
7. sudo python3 setup.py install (message = ... writing to /usr/local/lib/python3.4/dist-packages/spidev-3.1.egg-info)
8. Note - no need to install python3 pydev tools, 
9. sudo reboot
10. Enable I2C and SPI in /boot/config.txt
11. cd /boot
12. sudo nano config.txt
13. uncomment the following 3 statements (somewhere in the middel of the file).
14. dtparam=i2c_arm=on
15. dtparam=i2s=on
16. deparam=spi=on
17. ctrl-x, Y, Enter to save and exit Nano
18. ls -l /dev/spi* (to find /dev/spidev0.0, spidev0.1)
19. sudo python3 >>> import spidev  (shoud display no error message, Ctrl-D to exit Python)
20. sudo reboot (2015nov17hkt1733)

E. Python3 I2C installation (2015nov17hkt2217)

1. sudo apt-get install python3-smbus
2. ls -l /dev/i2c* (find /dev/i2c-1)
3. groups (pi ... i2c spi)
4. i2cdetect 1 (scans i2c addresses, nothing found)
5. sudo python3 >>> import smbus (no error message, ctrl-d to exit)
6. Note - no need to install i2c-tools
7. no need to check etc/modprobe.d/blacklist.conf [empty file => nothing to blacklist]
8. no need to check etc/module-load.d/modules.conf contains the following two lines: snd-bcm2835, i2c-dev  
9. no need to reboot (2015nov17hkt2217)

F. Python3 install pyserial-2.7 (2015nov15hkt1602)

1. Use browser to search "python pyserial" to navigate to pyserial 2.7 Python Package Index
2. Dwnload pyserial-2.7.tar.gz (should be downloaded to pi/downloads)
3. Copy the downloaded file from pi/downloads to pi/) 
4. sudo python3 setup.py install (should install to directory pyserial-2.7)
5. ls -l /dev/ttyAMA0 (found it)
6. sudo reboot (must reboot to import serial to python3)
7. sudo python3 >>> import serial (no error message)
8. sudo apt-get install cutecom
9. disable serial console login service permantly by the following.
10. sudo systemctl mask serial-getty@ttyAMA0.service
 [jessie message: creat symlink ... to /dev/null]
11. sudo reboot
12. cutecom (no need sudo)
13. enter devicename /dev/ttyAMA0
14. open device (should have no error message)
15. input any string at the lowest box, string should echo in second lowest box (2015nov17hkt2236).
16. Install spi, i2c, serial all OK - (2015nov15hkt1602)

G. Install Wifi dongle  (2015nov18hkt1230) 

1. lsusb to check if wifi dongle eleduino RTL8188 (RPi2 plug and play, no driver needed) detected 
2. found logitech unifying receiver x 2 (keyboard and mouse), Realtek RTL8192CU 802.11n WLAN Adapter
3. sudo iwlist wlano scan (found .. ESSID "tlfong01" WPA version 1, authentication PSK ...
4. sudo nano /etc/wpa_supplicant/wpa_supplicant.conf.
5.  Go to the bottom of the (only 2 lines) file and add the following:
network={
    ssid="tlfong01" 
    psk="my_wifi_password"
}
6. Save file (ctrl+x, y, <enter>)
7. sudo reboot
8. ifconfig wlano to check if connected (found address inet addr:192.168.128) (2015nov18hkt1230)
9. Check if web browser OK (duckduckgo searching "apple daily" very slow.

H. Install node RED (2015dec04)

1. sudo apt-get update
2. sudo apt-get install nodered
3. notes - http://nodered.org/docs/hardware/raspberrypi.html

I. Install node.JS (not tried)

1. curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
2. sudo apt-get install -y build-essential python-dev python-rpi.gpio nodejs
3. notes - http://nodered.org/docs/hardware/raspberrypi.html

.END

*** Rpi setup notes v2.6 2015nov16hkt2046 (config wifi adaptor) ***************************************************

8.0  Check if wifi dongle eleduino RTL8188 (RPi2 plug and play, no driver needed) detected - lsusb
8.0.1 Bus 0001 Device 0004: ID .... RTL8192CU 802.11n WLAN adaptor
8.1  Getting Wifi network details - sudo iwlist wlan0 scan.
8.2  Look out for - ESSID:"tlfong01", IE:IEEE 803.11i/WAP2 version 1 
8.3  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
8.4  Go to the bottom of the file and add the following:
network={
    ssid="tlfong01" 
    psk="my_wifi_password"
}
8.5 save file by ctrl+x, y, <enter>
8.6 sudo reboot
8.7 To check if connected - ifconfig wlan0 (inet addr:192.168.1.23)

.END

*** Rpi setup notes v2.6- 2015nov16hkt2046 ***

1. Download Raspian (Jessie) Noobs zip 961 MB (takes about 40 minutes) 
1.2 Download SD Formatter 4.0 to format 16G SD card (14.8 GB rename it from RECOVERY to UDISK 3)
1.3 Unzip NOONBS SD card image (NOONS_v1_4_2(1).zip to say jessie_noobs_image folder)
1.4 Copy all (11 files, 984 MB)  unzipped noobs files to formattted 14.8GB SD card (13.8GB remains)

[WinDiskManager method - Download Jessie and WinDiskManager32 Use WinDiskMan to write Jessie image to 16G SD card]

2 Boot RPi with the following connected: ethernet, keyboard, mouse, usb, 3.5mm audio

2.1 Desktop > install Raspian (at bottom of screen, choose language English UK, keyboard US) (need 3660 MB, available 14.8GB) (approx 1 hr)

2. Upadte and 
Terminal mode: sudo apt-get update, sudo apt-get upgrade [no need to do sudo rpi-update]

3. Desktop mode: Raspi-Config > Preferences
3.1 Appearance Setting = no change, just use default
3.2 Audio device seeting = no change
3.3 Main menu editor = no change
3.4 Mouse and keyboard setting
3.4.1 Mouse motion acceleration = 2.0 sensitivity = 10
3.4.2 Keyboard character repeat = no change, just use default
3.4.2 Keyboard layout Country = United States, Variant = English (US) [ check: pound/hatch, OR (vertical bar) keys
3.4.5 RPi configuration 
3.4.5.1 System no change (user name, password etc)
3.4.5.2 Interface = SSH, SPI, I2C, Serial all enables (Camera disabled)
3.4.5.3 Performance = no change (overclodk = none, GPU memory  = 64
3.4.5.4 Localization Locale = Language = en(English), Country = HK(Hong Kong), Character = UTF-8, Time Zone = Zsia, Hong Kong
3.4.5.5 Keyboard = Country = United States, Variant = English(US)
3.4.5.6 Note - no where to set Logtec generic keyboard (perhaps in terminal mode, would try later)
3.5 Shutdown > Reboot

4. Install SPI (Python 3 SPI spidev-3.1) 
5.1 Use browser to search "python spidev" > python package index > spidev3.1
5.2 download spidev-3.1.tar.gz (by default to pi/downloads)
5.2.1 Note 1 can also download by wget https://pypi.python.org/packages/source/s/spidev/spidev-3.1.tar.gz
5.2 copy spidev-3.1.tar.gz to pi
5.3 gunzip -c spidev-3.1.tar.gz | tar xf -  (will be unzipped to pi/spidev-3.1)
5.3 cd spidev-3.1 (spidev will be installed in home/spidev-3.1)
5.4 sudo python3 setup.py install 
5.4.1 Note 1 - no need to install python3 version of pydev tools, message = OK writing to /usr/local/lib/python3.4/dist-packages/spidev-3.1.egg-info]
5.5 sudo reboot
5.6 Enable I2C and SPI in /boot/config.txt
5.6.1 cd /boot
5.6.2 sudo nano config.txt
5.6.3 uncomment the following 3 statemenst.
5.6.4 dtparam=i2c_arm=on
5.6.5 dtparam=i2s=on
5.6.6 deparam=spi=on
5.6.7 ctrl-x, Y, Enter to save and exit Nano
5.7 ls -l /dev/spi* (to find /dev/spidev0.0, spidev0.1sudo python3
5.6 sudo python3 >>> import spidev (Ctrl-D to exit Python)

6. Install I2C (Python3-smbus)
6.1 sudo apt-get install python3-smbus, 
6.1 sudo apt-get install i2c-tools (actually not necessary, already installed)
6.2 ls -l /dev/i2c*
6.3 groups  
6.4 sudo reboot
6.5 $ls -l /dev/ (found /dev/i2c-1)
6.6 sudo python3 >>> import smbus (no error message, ctrl-d to exit python)
6.7 Note: No need to check the following.
6.7.1 /etc/modprobe.d/modules.conf contains the following two lines: snd-bcm2835, i2c-dev  
6.7.2 /modprobe.d/blacklist.conf [empty file => nothing to blacklist]
6.7.3 /module.load.d/modules.conf [snd-bcm2835, i2c-dev]

7. Install Serial (pyserial-2.7)
7.1 Use browser to search "python pyserial" to navigate to pyserial 2.7 Python Package Index
7.2 download pyserial-2.7.tar.gz (should be downloaded to pi/downloads, copy this file to pi)
7.3 gunzip -c pyserial-2.7.tar.gz | tar xf -
7.4 cd to pyserial-2.7
7.5 sudo python3 setup.py install (should install to directory pyserial-2.7)
7.6 sudo reboot
7.7 $ls -al /dev/ttyAMA0 (should find /dev/ttyAMA0, no need to first sudo reboot)
7.8 sudo python3 >>> import serial
7.9 sudo apt-get install cutecom
7.10 disable serial console login service permantly7.11 sudo systemctl mask serial-getty@ttyAMA0.service
 [jessie message: creat symlink ... to /dev/null]
7.10 sudo reboot
7.11 sudo cutecom, open '/dev/ttyAMA0' (may need to enter device name yourself)

.END - install spi, i2c, serial all OK - 2015nov15hkt1602

Attachments
sd_card_copier_2018dec0501.jpg
sd_card_copier_2018dec0501.jpg (178.7 KiB) Viewed 1718 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: Reading old weight scale

Wed Dec 05, 2018 12:21 pm

tlfong01 wrote:
Wed Dec 05, 2018 5:41 am
Newbie notes on setting up Rpi Raspbian Version 2018Nov Desktop

MCP23017 Programming - Memory Refreshing Old Posts

DS3231 32kHz HC14
viewtopic.php?f=37&t=77158&p=1332230&hi ... 1#p1332019

DS3231 TSX0104E HC14 CD4040
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1332019

DS3231 Generating square wave of 8, 16, 32, 64 Hz
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1340962

MCP23017 Intro
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1341737

MCP23017 Why using it
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1342143
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1342167
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1354825

MCP23017 Planning
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1343205

DS3231
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1343394

DS3231 + MCP23017
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1343507

MCP23017 Study
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1343725
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1343814
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1343824

I2C SMbus
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344027
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344180
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1355343

MCP23017 Interrupt pins
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344493

MCP23017 MCVE program
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344502
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344520
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344605
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344605
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1344605

MCP23017 x 2
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1344934

DS3231 Program
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345103

DS3231 Reading temperature
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345375
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345488
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345818
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345871
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1345947
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1346166
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1346190
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1346263
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1346274

DS3231 Rpi Ddriver
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1347008
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1347276

MCP23017 controlling DHT22
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1348064

I2C Frequency setting
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1349002

DS3231 Functions - write read register, read temperature
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1349014

MCP23017 and DHT22
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1349307

DS3231 Design Notes
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1349933

DS3231 Interrupts
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1350076

DHT22
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1350085

DHT22 and I2C Timing
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1350362
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1350437

I2C References
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1351223
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1352201
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1352292
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1355575

I2C Block Write
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1351268
viewtopic.php?f=37&t=77158&hilit=DS3231 ... #p1351394/
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1351680

I2C Bus Extender P82B715
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1351545

I2C Baud rate setting
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1351737

I2C Cabling - UTP
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1351758

Max I2C bus length
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1351929

HDC1080
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1353204
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1353982

MCP23017 Finally a 200uS pulse!
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1355683
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1355771


I2C Extender Testing
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1356156
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 5#p1357003
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: Reading old weight scale

Wed Dec 05, 2018 2:10 pm

tlfong01 wrote:
Wed Dec 05, 2018 5:41 am
Newbie notes on setting up Rpi Raspbian Version 2018Nov Desktop

I2C Triple TXS0104E 3V3 to 5V0 Level Converter Tested OK

Next step is testing RTC 3231
...
Attachments
i2c_test_setup_2018dec0502.jpg
i2c_test_setup_2018dec0502.jpg (204.04 KiB) Viewed 1703 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: Reading old weight scale

Wed Dec 05, 2018 2:53 pm

tlfong01 wrote:
Wed Dec 05, 2018 2:10 pm
I2C Triple TXS0104E 3V3 to 5V0 Level Converter Tested OK
Next step is testing RTC 3231

I2C Bad Guy Found! :mrgreen:

I connected three more I2C MCP23017 (addresses 0x21 + 0x32, 0x22). Together with the RTC + EEPROM addresses 0x57, 0x68, I repeatedly swapped I2C channels and devices and finally found the trouble maker, the MCP23017 with address 0x22.

If the 0x22 mcp23017 is not connected, the other 3 devices behave very well, using i2cdetect -y 1 can 99% of times detect the correct addresses.

However, when the bad guy joins the party, then the annoying intermittent addresses not detected happen almost 90% of the times.

So my conclusion is the following:

Any bad I2C device could corrupt all the I2C channels.

If I have discovered this situation two months ago, I would not have to wasted perhaps two hobbyist weeks troubleshooting intermittent weird MCP23017 events! :(


...
Attachments
i2c_trouble_maker_2018dec0501.jpg
i2c_trouble_maker_2018dec0501.jpg (181.5 KiB) Viewed 1699 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: Reading old weight scale

Thu Dec 06, 2018 4:55 am

tlfong01 wrote:
Wed Dec 05, 2018 2:53 pm
I2C Triple TXS0104E 3V3 to 5V0 Level Converter Tested OK
I2C Bad Guy Found!
So my conclusion is the following:
Any bad I2C device could corrupt all the I2C channels.

Tidying up tri level converter and rtc wiring notes

Programming reading Notes

Raspberry Pi's Eben Upton On Closing The Tech Skills Gap - Nicholas Fearn, Forbes, 2018
https://www.forbes.com/sites/nicholasfe ... cbb455104c

Rpi, ... shipped over 22 million units, ... all profits are invested in digital learning initiatives globally.

Upton has been working to transform STEM education and inspire the next generation of technology talent.

“A device that was originally conceived as a toy for kids is now finding its way into a wide range of industrial applications.

Last year, more than half of our 6 million unit sales were into industrial or commercial applications,” he says.

“We're not going to stop until everyone in the world has access to a low-cost, high-performance PC, and every child has a chance to understand how their PC works, and to use that knowledge to secure a better life for themselves."

Eradicating the tech skills shortage

In 2018, the technology skills gap is still a major challenge. Research claims there’ll be 800,000 unfilled IT roles in the UK alone by 2020, and the British Computer Society has suggested that the number of students taking computing courses will halve over the coming years.

“We're in a much better place than we were a decade ago. We’ve gone from having an ICT curriculum which focused on office skills to an extremely rigorous computing curriculum.

At the same time, Upton believes that the general public is becoming more aware of the importance of STEM learning.

Tackling diversity in tech

To Upton, the real challenge is making the tech industry more inclusive - particularly when it comes to gender diversity. According to industry body Tech Nation, women in tech are outnumbered by men 4:1.

“The challenges we think about now are around diversity and inclusivity, and about how we make computing relevant and provide an opportunity for steady progression that keeps young people engaged,” he explains.

“We've felt for a while that one of our pieces of unfinished business is to ensure that the resurgence in interest in computing among young people is more balanced than the surge in the 1980s that I was part of: heavily male and middle-class.”

“We have some promising leading indicators: of attendees at Code Club (a program for 9-13 year olds), 41% are female, and a school in a disadvantaged area (as measured by the proportion of students on free school meals) is somewhat more likely to have a Code Club than one is a more affluent area.”

Although this is beginning to improve, Upton admits that more needs to be done. “There are specific techniques which have been established in the literature to improve girls' level of engagement.

“One example would be pair programming, an established software engineering technique whereby pairs of people sit together at a single machine and work to tackle a problem.

...
Attachments
tri_txs0102_ds3231_coupling_2018dec0601.jpg
tri_txs0102_ds3231_coupling_2018dec0601.jpg (197.62 KiB) Viewed 1664 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: Reading old weight scale

Thu Dec 06, 2018 9:13 am

tlfong01 wrote:
Thu Dec 06, 2018 4:55 am
Any bad I2C device could corrupt all the I2C channels.[/i][/color]
Tidying up tri level converter and rtc wiring notes

MCP23017 Evaluation Board Newbie Version 0.1

In the earlier projects, I found MCP23017 not reliable, often causing intermittent (remote IO errors) I2C errors. I have been using both through hole and SMD components from a couple of reputable TaoBao shops. So I quickly concluded that MCP23017 itself is not that reliable, comparing to other I2C devices I tested, such as RTC, which I found more stable. That is one reason I always use a manual/software reset button in case MCP20317 hangs.

I usually placed two MCP23017s on a single board, with all connecting wires as duPoint female to female cables, 15cm or 30cm long, but not longer, unless very necessary.
This way I can easily swap any MCP23017 on board, or other boards. And for each MCP23017, every connection is jumper selectable, so it is easy to swap any connecting wire or port pins etc.

I also placed a huge, 470uF electrolyte capacitor, and a 10uF tantalum cap very near to the on the 5V power connector, and 10uF and 0.1uF tantalum very near to the MCP23017 power pins.

I also found RTC DS3231 much more stable than MCP23017. So in case of unknown MCP23017 errors, I usually check if RTC DS3231 is OK. In other words, DS3231 is a canary in the coal mine, ... :mrgreen:

/ to continue, ...

...
Attachments
dual_mcp23017_brd_2018dec0601.jpg
dual_mcp23017_brd_2018dec0601.jpg (192.24 KiB) Viewed 1652 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: Reading old weight scale

Fri Dec 07, 2018 6:34 am

tlfong01 wrote:
Thu Dec 06, 2018 9:13 am
tlfong01 wrote:
Thu Dec 06, 2018 4:55 am
Any bad I2C device could corrupt all the I2C channels.
MCP23017 Evaluation Board Newbie Version 0.1
I also found RTC DS3231 much more stable than MCP23017.

Effect of very long I2C connecting wires

I also compared the effect of using long, 90 cm wires, with short 30 cm wires. I surprisingly found that there is not any noticable effects, when using i2cdetect -y 1 to detect 4 iox I2C address.

My conclusion is that length of I2C wires less than 1m should not have any bad effect on I2C operation. On the other hand bad I2C devices would have a fatal effect. I guess because bad I2C devices increase total capacitance more than long wires.


I also read that Rpi I2C data pin already has a very strong 1k8 pullup, so there no use making it stronger resulting larger current, with a risk of overloading Rpi. See discussion below.

I2C PULL UP RESISTORS - goodney 2012jun07
viewtopic.php?t=7664
...
Attachments
i2c_long_wire_effect_2018dec0702.jpg
i2c_long_wire_effect_2018dec0702.jpg (191.62 KiB) Viewed 1632 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: Reading old weight scale

Fri Dec 07, 2018 7:26 am

tlfong01 wrote:
Fri Dec 07, 2018 6:34 am

Lua Blink 2.0 programming notes

Earlier I wrote a ESP8266 NodeMCU Lua 5.1 blink program but found it not able to blink faster than 1kHz, therefore useless to control HX711 which requires control pulses of period less than (50uS x 2) = 1S/100uS = 1,000,000uS / 100uS = 10,000 = 10kHz.

Now I am thinking of forgetting about ESP8266 NodeMCU and try my luck again on Rpi stretch Lua. I need to first find if there is any usable Lua GPIO packages.


First thing is to convert the Rpi 3V3 GPIO signals to 5V0.

Update 2018dec07hkt1545

I googled Lua related forums but could not find any GPIO package for Rpi3. I also
used the command $ apt-cache search '^lua-.*' and neither find anything useful. So I guess I have to give up ESP8266 Lua GPIO. My original plan was to use ESP8266 GPIO to directly control HX711. Now I need to use perhaps python to use Rpi to directly control HX711. But if I use Rpi python, I can as well use Rpi to control MCP23017 which in turn controls HX711.

...
Attachments
rpi_.呎_勺久豈_2018皮0701.jpg
rpi_.呎_勺久豈_2018皮0701.jpg (191.69 KiB) Viewed 1622 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: Reading old weight scale

Fri Dec 07, 2018 7:59 am

tlfong01 wrote:
Fri Dec 07, 2018 7:26 am
... use Rpi python, Rpi to control MCP23017 which in turn controls HX711

HX711 programming design notes

I read my old post to refresh my memory of the HX711 writing timing limit of 10kHz:

(HX711 Control Signal Timing) RE: READING OLD WEIGHT SCALE - tlfong01 2018dec01
viewtopic.php?f=37&t=227137&start=50#p1398970

I also read a couple other old posts about MCP23017 generating 200uS pulses for DHT22. My conclusion is that MCP23017 GPIO based 200uS is the narrowest pulse I can generate using I2C blocks write.

(DHT22 200uS narrow pulse requirement) RE: RELAY MODULE KY-019 5V Postby tlfong01
viewtopic.php?f=37&t=77158&hilit=DS3231&start=325

(Rpi generating 200uS pulse) RE: RELAY MODULE KY-019 5V Postby tlfong01 » 2018-Aug-21
viewtopic.php?f=37&t=77158&hilit=DS3231 ... 0#p1355771

In other words, Rpi I2C's speed of 100kHz is too slow for MCP23017 to generte short pulses for HX711. I also read that Rpi I2C speed is fixed at 100kHz and cannot be changed.

So I have to also give up and do the following:

Use Rpi3B+ stretch python 3.5 to generate GPIO 10kHz pulses.

...
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: Reading old weight scale

Fri Dec 07, 2018 2:06 pm

tlfong01 wrote:
Fri Dec 07, 2018 7:59 am

Replacing I2C MCP2307 by SPI MCP23S17

I have been thinking of using Rpi software I2C, but found the speed limitation problem and instability problem might not likely to go away.

So I have decided to give up I2C MCP23017, and divert to SPI MCP23S17


SPI References


SPI Wikipedia

https://en.wikipedia.org/wiki/Serial_Pe ... _Interface

python spidev 3.2
https://pypi.org/project/spidev/

python spidev github
https://github.com/doceme/py-spidev

SPI - Raspberry Pi
https://www.raspberrypi.org/documentati ... /README.md

Raspberry Pi SPI and I2C Tutorial - SparkFun
https://learn.sparkfun.com/tutorials/ra ... torial/all


Software I2C References

Configuring Software I2C on the Raspberry Pi - Brian Cooke, fivdi 2018
https://github.com/fivdi/i2c-bus/blob/m ... are-i2c.md

Raspbian has a software I2C driver that can be enabled by adding the following line to /boot/config.txt:
dtoverlay=i2c-gpio,bus=3

This will create an I2C bus called /dev/i2c-3. SDA will be on GPIO23 and SCL will be on GPIO24 which are pins 16 and 18 on the GPIO header respectively.

For further information about i2c-gpio and the parameters it supports see /boot/overlays/README on the Raspberry Pi.


Rpi /boot/overlays/README

Introduction

This directory contains Device Tree overlays. Device Tree makes it possible to support many hardware configurations with a single kernel and without the need to explicitly load or blacklist kernel modules.

On Raspberry Pi, Device Tree usage is controlled from /boot/config.txt.

In /boot you will find a .dtb for each base platform. This describes the hardware that is part of the Raspberry Pi board. The loader (start.elf and its siblings) selects the .dtb file appropriate for the platform by name, and reads it into memory. At this point, all of the optional interfaces (i2c, i2s, spi) are disabled, but they can be enabled using Device Tree parameters:

dtparam=i2c=on,i2s=on,spi=on

Configuring additional, optional hardware is done using Device Tree overlays

Name: i2c-gpio
Info: Adds support for software i2c controller on gpio pins
Load: dtoverlay=i2c-gpio,<param>=<val>
Params: i2c_gpio_sda GPIO used for I2C data (default "23")

i2c_gpio_scl GPIO used for I2C clock (default "24")

i2c_gpio_delay_us Clock delay in microseconds
(default "2" = ~100kHz)

bus Set to a unique, non-zero value if wanting multiple i2c-gpio busses.
If set, will be used as the preferred bus number (/dev/i2c-<n>). If
not set, the default value is 0, but the bus number will be
dynamically assigned - probably 3.
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: Reading old weight scale

Sat Dec 08, 2018 4:06 am

tlfong01 wrote:
Fri Dec 07, 2018 2:06 pm
Replacing I2C MCP2307 by SPI MCP23S17[/b]
I have been thinking of using Rpi software I2C, but found the speed limitation problem and instability problem might not likely to go away.
So I have decided to give up I2C MCP23017, and divert to SPI MCP23S17
[/color]

Final testing of 8 MCP23017 modules

Before packing and putting on the shelf my 8 miserable MCP23017s, I am doing some final checking up and making a record, in case I am coming back.

I first checked 4 reliable modules, deliberately using 90cm long I2C cables and 75cm long 5V power cables, and found i2cdetect command working OK for a row of 50 times.
...
Attachments
quad_mcp23017_detect_2018dec0801.jpg
quad_mcp23017_detect_2018dec0801.jpg (161.69 KiB) Viewed 1576 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: Reading old weight scale

Sat Dec 08, 2018 8:45 am

tlfong01 wrote:
Sat Dec 08, 2018 4:06 am
Replacing I2C MCP2307 by SPI MCP23S17
I have been thinking of using Rpi software I2C, but found the speed limitation problem and instability problem might not likely to go away.
So I have decided to give up I2C MCP23017, and divert to SPI MCP23S17

SPI Wiring Plan V0.1

...
Attachments
spi_wiring_2018dec0801.jpg
spi_wiring_2018dec0801.jpg (181.43 KiB) Viewed 1561 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: Reading old weight scale

Sat Dec 08, 2018 2:58 pm

tlfong01 wrote:
Sat Dec 08, 2018 4:06 am
So I have decided to give up I2C MCP23017, and divert to SPI MCP23S17[/i][/color]

Quad SPI Mux Level Converter Board assembly notes

TXS0104E 4-Bit Bidirectional Voltage-Level Translator for Open-Drain and Push-Pull Applications
http://www.ti.com/lit/ds/symlink/txs0104e.pdf

Max Data Rates - 24 Mbps (Push Pull), 2 Mbps (Open Drain)

When the output-enable (OE) input is low, all outputs are placed in the high-impedance state.
The TXS0104E is designed so that the OE input circuit is supplied by VCCA.

OE = 3-state output-mode enable. Pull OE low to place all outputs in 3-state mode. Referenced to VCCA.
OE input max = 5.5V (Datasheet ss6.3 Recommended Operating Conditions)

To ensure the high-impedance state during power up or power down, OE should be tied to GND through a pulldown resistor;
...
Attachments
mux_spi_lvl_shifter_2018dec0802.jpg
mux_spi_lvl_shifter_2018dec0802.jpg (162.72 KiB) Viewed 1545 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: Reading old weight scale

Sun Dec 09, 2018 1:28 pm

tlfong01 wrote:
Sat Dec 08, 2018 2:58 pm
Quad SPI Mux Level Converter Board assembly notes
TXS0104E 4-Bit Bidirectional Voltage-Level Translator for Open-Drain and Push-Pull Applications
http://www.ti.com/lit/ds/symlink/txs0104e.pdf
Max Data Rates - 24 Mbps (Push Pull), 2 Mbps (Open Drain)
When the output-enable (OE) input is low, all outputs are placed in the high-impedance state.
The TXS0104E is designed so that the OE input circuit is supplied by VCCA.
OE = 3-state output-mode enable. Pull OE low to place all outputs in 3-state mode. Referenced to VCCA.
OE input max = 5.5V (Datasheet ss6.3 Recommended Operating Conditions)
To ensure the high-impedance state during power up or power down, OE should be tied to GND through a pulldown resistor;

MCP23S17 Testing Notes

StackOverflow/StackExchange mcp23017/mcp23s17 search results
StackOverflow search results found containing mcp23017 - 55 results
StackOverflow search results found containing mcp23s017 - 5 results
StackExchange Rpi Forum results found containing mcp23017 - 81 results
StackExchange Rpi Forum results found containing mcp23S17 - 7 results


...
Attachments
mcp23s17_test_2018dec0902.jpg
mcp23s17_test_2018dec0902.jpg (179.78 KiB) Viewed 1520 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: Reading old weight scale

Mon Dec 10, 2018 6:39 am

tlfong01 wrote:
Sun Dec 09, 2018 1:28 pm
MCP23S17 Testing Notes

SPI Driver Installation Checking Notes

Python Module - Petrockblog
https://github.com/petrockblog/RPi-MCP23S17

This Python module abstracts the GPIO expander MCP23S17 for usage on the Raspberry Pi.

SPI Class - Piface
http://piface.github.io/pifacecommon/re ... common.spi
pifacecommon.spi.SPIDevice(bus=0, chip_select=0, spi_callback=None)

RE: SPI MCP23S17 - karrika 2016-Mar-09
viewtopic.php?t=139310

I found out the hard way that in order to set up multiple MCP23S17 chips you need to set up all the chip modes in a strange way at startup. There is some bug in the errata and if you have multiple chips wired for different addresses A0,A1,A2 then recognizing these addresses does not work out of the box. You need to run "setChipModes()" to make them work.
...
Attachments
spi_driver_test_2018dec1001.jpg
spi_driver_test_2018dec1001.jpg (185.36 KiB) Viewed 1500 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: Reading old weight scale

Mon Dec 10, 2018 8:56 am

tlfong01 wrote:
Mon Dec 10, 2018 6:39 am
tlfong01 wrote:
Sun Dec 09, 2018 1:28 pm
MCP23S17 Testing Notes
SPI Driver Installation Checking Notes

SPI Wiring Checking Notes
...
Attachments
spi_wiring_check_2018dec1001.jpg
spi_wiring_check_2018dec1001.jpg (168.12 KiB) Viewed 1491 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: Reading old weight scale

Mon Dec 10, 2018 9:17 am

tlfong01 wrote:
Mon Dec 10, 2018 8:56 am
MCP23S17 Testing Notes
SPI Driver Installation Checking Notes
SPI Wiring Checking Notes

Rpi SPI Repeat Send One Character Waveform Checking Notes

...
Attachments
spi_waveform_2018dec1002.jpg
spi_waveform_2018dec1002.jpg (167.59 KiB) Viewed 1485 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: Reading old weight scale

Tue Dec 11, 2018 8:29 am

SPI Detect Program Example 1
...
Now I have debugged a minimal, compete, verifiable example (MCVE) program to repeatedly send single byte on a SPI port, and used a scope to display the waveform.
The program is only about 50 lines long, as displayed below.

...

Code: Select all

# *** spidetect02ok.py 2018dec11hkt1521 ***
#
# Program Description:
# This program repeats 200, 000 times sending the byte 0x55, pausing 0.0005 second after each byte.
# The SPI port is set a frequency 100kHz, therefore each bit time = 1 sec / 100k = 1000k uS / 100k
# = 10uS, and each char of default 8N1 (8 bits + no parity + 1 stop bit = 9 bits) = 10uS x 9 = 90uS
# pause after sending each byte = 0.00005 sec = 1,000,000 x 0.0005uS = 500 uS
# oscilloscope should display 90uS long 9 bit pattern separated by 500uS
#
# Hardware/Software Descritptio:
# Raspberry 3B+, Raspbian Version 2018 November, python 3.5.3

# Import Python Modules

import spidev
from time import sleep

# Open and Config SPI Port

spiPort = spidev.SpiDev()
spiPort.open(0,0) 
spiPort.max_speed_hz = 100000

# TestFunction

def repeatSendByte(spiPort, sendByte, pauseTimeBetweenByte, repeatCount):

    def spiSendRecvOneByte(spiPort, sendByte):
        sendByteArray = [sendByte]
        recvByteArray = spiPort.xfer2(sendByteArray)    
        return recvByteArray
    
    print('Begin repeatSendChar(),....')
    for i in range(repeatCount):
        spiSendRecvOneByte(spiPort, sendByte)
        sleep(pauseTimeBetweenByte)
    print('End   repeatSendChar().')
    return

# Initialization

sendByte    = 0x55
pauseTime   = 0.0005
repeatCount = 20000

# Main

repeatSendByte(spiPort, sendByte, pauseTime, repeatCount)

# End
...
Attachments
spi_detect_2018dec1101.jpg
spi_detect_2018dec1101.jpg (180.88 KiB) Viewed 1455 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: Reading old weight scale

Tue Dec 11, 2018 8:58 am

tlfong01 wrote:
Tue Dec 11, 2018 8:29 am
Now I have debugged a minimal, compete, verifiable example (MCVE) program to repeatedly send single byte on a SPI port, and used a scope to display the waveform.


Testing Rpi3B+ SPI at frequency 1MHz OK

Last couple of months I played with Rpi I2C MCP23017 and found Rpi's 100kHz limit is too slow for DHT22 and HX711. Therefore I gave up I2C and MCP23017.

This time I am anxious to check if SPI can do 100MHz properly. I used the same program and set frequency to 1MHz. The scope show that the SPI at 1MHz still looks OK, expect the square waves have round corners. I am not sure if it is because my old scope of 100MHz, 1GSa/s is not that HiFi, or the wave form is indeed not that like a square wave.

Anyway, next step is to check SPI loop back, to see if MISO pin can read MOSI's output, at 100kHz and also 1MHz.


To do
I noticed that 1 byte sent only takes 8 clock pulses, not 9 pulses (8N1). I need to check if I misunderstood something.
...
Attachments
spi_1mhz_test_2018dec1101.jpg
spi_1mhz_test_2018dec1101.jpg (163.62 KiB) Viewed 1454 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: Reading old weight scale

Tue Dec 11, 2018 12:57 pm

tlfong01 wrote:
Tue Dec 11, 2018 8:58 am
Testing Rpi3B+ SPI at frequency 1MHz OK
This time I am anxious to check if SPI can do 100MHz Errata - I meant 1MHz properly. I used the same program and set frequency to 1MHz. The scope show that the SPI at 1MHz still looks OK, expect the square waves have round corners. I am not sure if it is because my old scope of 100MHz, 1GSa/s is not that HiFi, or the wave form is indeed not that like a square wave.
Anyway, next step is to check SPI loop back, to see if MISO pin can read MOSI's output, at 100kHz and also 1MHz.[/i][/color]

4 Analog Channel Scope to display SPI Clk, Mosi, Miso, CE0/1

Today I received a weekly newsletter from Element14 eMarketing, recommending their goodies, including the following scope:

Everything You Need for Your Bench - PicoScope 5000D Series PC Based Oscilloscopes - Element 14 2018dec11
https://hk.element14.com/c/test-measure ... illoscopes

I read that their cheapest 4 analog channels scope is HK$14k, and as usual, four or five times than me, a poor hobbyist can afford!

The scope I have been using for the last 5 years is Atten ADS1102CAL which I bought for 2013 price of CN¥2,200.

ATTEN ADS1102CAL+ 100MHz 1GSa/s 2013Jun CN¥1,500
https://item.taobao.com/item.htm?spm=a2 ... t=9#detail

I am now thinking of getting the following.

RIGOL DS1054Z 50MHz 4channel ¥2,320
https://detail.tmall.com/item.htm?_u=b3 ... 6224248671

Youtubes of RIGOL DS1054Z 50MHz 4channel Scope
https://www.youtube.com/watch?reload=9&v=ETCOhzU1O5A
https://www.youtube.com/watch?v=sQwYFNf2HNc
https://www.youtube.com/watch?v=W2qdtQkBKhc


Update 2018dec12hkt0917

The 28 Best Gifts for Boyfriends and Husbands, According to Boyfriends and Husbands By David Notis 2018dec12
http://nymag.com/strategist/article/bes ... bands.html

CanaKit Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply $55 at Amazon

It looks strange, but techies love the Raspberry Pi, a customizable, open-source computer system designed to help people learn and practice basic computer coding. “I feel like it does the same thing for me that Legos do for my nephew,” says Dan Sterba, a data analyst whose wife, Nina, bought him a Raspberry Pi a few years ago. He likes that it lets him build something from scratch and figure out how it works. “The first thing I made was a Super Nintendo emulator. Then I set something up to turn the lights on and off ... Now I’m getting into smart-home stuff ...”

Super NES Classic Edition $80 at Amazon
ChefSteps Joule Sous Vide Circulator $144 at Amazon
Baking Steel $79 at Amazon
Presto 6-Quart Stainless Steel Pressure Cooker $40 at Amazon
Chemex Classic Pour-Over Glass Coffeemaker, 6-Cup $40 at Amazon
Matchaeologist Matcha Brewing Kit $69 at Sur La Table
Feather SS Japanese Straight Razor $59 at Amazon
Philips Norelco 7200 Vacuum Beard Trimmer $50 at Amazon
Zeus Deluxe Beard Grooming Kit $53 at Amazon
Proraso Gift Set, Refreshing and Toning Formula $32 at Amazon
Maison Margiela, Replica Jazz Club Fragrance $126 at Nordstrom
Le Labo Discovery Set $85 at Nordstrom
Kiehl’s Mens Essentials Set $48 at Nordstrom
Club Monaco Slim Flannel Shirt $69 at Club Monaco
Everlane ReNew Fleece Zip, Dark Navy $80 at Everlane
Todd Snyder+Champion Slim Jogger Sweatpant $118 at Todd Snyder
Wigwam Merino Wool Hiker Sock, 2-Pack $29 at Amazon
Red Wing Heritage 6” Moc Toe $280 at Zappos
Cos Cashmere Scarf, Black $115 at Cos
Tanner Goods Utility Bifold $100 at Tanner Goods
Makr Canvas and Leather Fold Weekender Revised $230 at Makr
Peruvian Apple Cactus in White Rounded Fiberglass Planter $224 at Water and Light
ZZ Plant in Grey Concrete Planter $50 at Water and Light
Haws Copper Watering Can $98 at Amazon


7 Programming Languages Your Developers Need to Know - Costi Teleman 2018dec11
https://www.business2community.com/tech ... w-02150282

Java ...
Python ...
JavaScript ...
C Programming (C, C#, and C++) ...
PHP ...
Scala ...
Perl ...

Python
The growth of software demand in the fields of artificial intelligence and data science is a good opportunity for devs to branch out into new-generation technologies. Specifically, programmers with knowledge in using Python can transfer their skills in machine learning as well as web or software development.

Python’s popularity has spiked over recent years. In fact, Reddit, DropBox, and NASA are only some of the most popular organizations that are using Python to run their website, projects, or services.

Python also plays nice with Raspberry Pi, which is a line of single-board computers that are used to teach basic computer science skills among children in developing countries.

Scala
Some programmers describe Scala as a better alternative to Java because it offers a way for developers to write better codes and improve how a particular program performs. Developers who support Scala say this particular programming language has less restrictions and is less tedious to use, potentially reducing your developers’ frustrations when working on dev projects. Scala is also said to be the programming language of choice among several tech companies, including Apple, LinkedIn, Netflix, and Twitter.

...
Attachments
rigol_ds1054z_2018dec1101.jpg
rigol_ds1054z_2018dec1101.jpg (192.31 KiB) Viewed 1434 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: Reading old weight scale

Wed Dec 12, 2018 1:57 am

tlfong01 wrote:
Tue Dec 11, 2018 12:57 pm
The scope show that the SPI at 1MHz still looks OK, expect the square waves have round corners. I am not sure if it is because my old scope of 100MHz, 1GSa/s is not that HiFi, or the wave form is indeed not that like a square wave.
4 Analog Channel Scope to display SPI Clk, Mosi, Miso, CE0/1
I read that their [element14's] cheapest 4 analog channels scope is HK$14k, and as usual, four or five times than me, a poor hobbyist can afford!
The scope I have been using for the last 5 years is Atten ADS1102CAL which I bought at the 2013 price of CN¥2,200.
ATTEN ADS1102CAL+ 100MHz 1GSa/s 2013Jun CN¥1,500
https://item.taobao.com/item.htm?spm=a2 ... t=9#detail
I am now thinking of getting the following.
RIGOL DS1054Z 50MHz 4channel ¥2,320
https://detail.tmall.com/item.htm?_u=b3 ... 6224248671
The 28 Best [Xmas] Gifts for Boyfriends and Husbands, According to Boyfriends and Husbands
CanaKit Raspberry Pi 3 B+ (B Plus) with Premium Clear Case and 2.5A Power Supply $55 at Amazon

Santa Claus Is Coming To Town

Andrea Bocelli - Santa Claus Is Coming To Town 5,917,129 views
https://www.youtube.com/watch?v=bMvFqy9_RUo

/ to continue, ...
...
Attachments
xmas_gift_2018_2018dec1201.jpg
xmas_gift_2018_2018dec1201.jpg (109.12 KiB) Viewed 1419 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: Reading old weight scale

Wed Dec 12, 2018 5:00 am

tlfong01 wrote:
Wed Dec 12, 2018 1:57 am

Ridiculously Tiny Washing Machine Top Electronics Bench Assembly Notes - Part 1

We girls in the Ridiculously tiny flat in Hong Kong - 486,639 views
https://www.youtube.com/watch?v=979a8b0lP2M


/ to continue, ...
...
Attachments
machine_top_electronics_bench_2018dec1201.jpg
machine_top_electronics_bench_2018dec1201.jpg (159.71 KiB) Viewed 1408 times
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”