Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Avoiding wireless connections - EmonTX serial RPiZero solution

Thanks both.

I ran the three commands @borpin described above on my emonTx / PiZ #2, and something wasn’t right …

[email protected]:~ $ sudo systemctl stop emonhub.service
[email protected]:~ $ wget https://github.com/openenergymonitor/EmonTxV3CM/releases/download/2.0.0/firmware.hex
--2020-10-16 17:17:00--  https://github.com/openenergymonitor/EmonTxV3CM/releases/download/2.0.0/firmware.hex
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/195186265/f65d4980-e155-11ea-9cbb-743aa1ea70da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201016%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201016T161701Z&X-Amz-Expires=300&X-Amz-Signature=38706b3374a36681ff1e5b69102ad0b6b408e8d9facf91dbbd459d476e3d29a3&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=195186265&response-content-disposition=attachment%3B%20filename%3Dfirmware.hex&response-content-type=application%2Foctet-stream [following]
--2020-10-16 17:17:01--  https://github-production-release-asset-2e65be.s3.amazonaws.com/195186265/f65d4980-e155-11ea-9cbb-743aa1ea70da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201016%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201016T161701Z&X-Amz-Expires=300&X-Amz-Signature=38706b3374a36681ff1e5b69102ad0b6b408e8d9facf91dbbd459d476e3d29a3&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=195186265&response-content-disposition=attachment%3B%20filename%3Dfirmware.hex&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.138.35
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.138.35|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 79173 (77K) [application/octet-stream]
Saving to: ‘firmware.hex.1’

firmware.hex.1                    100%[==========================================================>]  77.32K   317KB/s    in 0.2s    

2020-10-16 17:17:02 (317 KB/s) - ‘firmware.hex.1’ saved [79173/79173]

[email protected]:~ $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:firmware.hex

avrdude-original: Version 6.3-20171130
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2014 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe
[email protected]:~ $ 

If I try to stop emonhub again and re-run tty it also comes back with a broken pipe.

[email protected]:~ $ miniterm /dev/ttyAMA0 115200
--- Miniterm on /dev/ttyAMA0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
packet_write_wait: Connection to 192.168.2.53 port 22: Broken pipe
Julians-42-iMac:~ jjb$ 

And for reasons that are probably related, data from this PiZ #2 is no longer arriving within emonCMS on the main emonPi. I must have broken something :cold_face:

Note the file it says it is saving it to.

[edit]
You need to change the reset pin - I’ll find the link.

OK,

edit this file

sudo nano /opt/openenergymonitor/avrdude-rpi/autoreset

and change the Pin from 7 to 12.

#pin = 7
pin = 12

Thanks for the info re: pin 7 > 12, and I have now done that, but the pipe remains broken.

Is it something to do with this bit? This is all so new to me that every moment is a school day!

System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping
[[email protected]:~ $ wget https://github.com/openenergymonitor/EmonTxV3CM/releases/download/2.0.0/firmware.hex
--2020-10-17 11:51:55--  https://github.com/openenergymonitor/EmonTxV3CM/releases/download/2.0.0/firmware.hex
Resolving github.com (github.com)... 140.82.121.4
Connecting to github.com (github.com)|140.82.121.4|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/195186265/f65d4980-e155-11ea-9cbb-743aa1ea70da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201017%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201017T105156Z&X-Amz-Expires=300&X-Amz-Signature=d5d1dc78566464175f5722c041413dc9cf5be8d7196c1cf18c3d4a59902590ec&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=195186265&response-content-disposition=attachment%3B%20filename%3Dfirmware.hex&response-content-type=application%2Foctet-stream [following]
--2020-10-17 11:51:56--  https://github-production-release-asset-2e65be.s3.amazonaws.com/195186265/f65d4980-e155-11ea-9cbb-743aa1ea70da?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201017%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201017T105156Z&X-Amz-Expires=300&X-Amz-Signature=d5d1dc78566464175f5722c041413dc9cf5be8d7196c1cf18c3d4a59902590ec&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=195186265&response-content-disposition=attachment%3B%20filename%3Dfirmware.hex&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.248.148
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.248.148|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 79173 (77K) [application/octet-stream]
Saving to: ‘firmware.hex.3’

firmware.hex.3                100%[=================================================>]  77.32K   353KB/s    in 0.2s    

2020-10-17 11:51:57 (353 KB/s) - ‘firmware.hex.3’ saved [79173/79173]

[email protected]:~ $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:firmware.hex.3

avrdude-original: Version 6.3-20171130
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2014 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 12
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe
[email protected]:~ $ 

Did you stop emonhub?

This is what a successful flash look like (ignore the different file name).

[email protected]:~ $ cd /opt/openenergymonitor/EmonTxV3CM/
[email protected]:/opt/openenergymonitor/EmonTxV3CM $ sudo systemctl stop emonhub.service
[email protected]:/opt/openenergymonitor/EmonTxV3CM $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:output.hex

avrdude-original: Version 6.3-20171130
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2014 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 12
                  AVR Part                      : ATmega328P
                  Chip Erase delay              : 9000 us
                  PAGEL                         : PD7
                  BS2                           : PC2
                  RESET disposition             : dedicated
                  RETRY pulse                   : SCK
                  serial program mode           : yes
                  parallel program mode         : yes
                  Timeout                       : 200
                  StabDelay                     : 100
                  CmdexeDelay                   : 25
                  SyncLoops                     : 32
                  ByteDelay                     : 0
                  PollIndex                     : 3
                  PollValue                     : 0x53
                  Memory Detail                 :

                                           Block Poll               Page                       Polled
                    Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                    ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                    eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
                    flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                    lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                    hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                    efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                    lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                    calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                    signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

                  Programmer Type : Arduino
                  Description     : Arduino
                  Hardware Version: 3
                  Firmware Version: 4.4
                  Vtarget         : 0.3 V
                  Varef           : 0.3 V
                  Oscillator      : 28.800 kHz
                  SCK period      : 3.3 us

avrdude-original: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude-original: Device signature = 0x1e950f (probably m328p)
avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0
avrdude-original: NOTE: "flash" memory has been specified, an erase cycle will be performed
                  To disable this feature, specify the -D option.
avrdude-original: erasing chip
avrdude-original: reading input file "output.hex"
avrdude-original: input file output.hex auto detected as Intel Hex
avrdude-original: writing flash (28968 bytes):

Writing | ################################################## | 100% 4.32s

avrdude-original: 28968 bytes of flash written
avrdude-original: verifying flash memory against output.hex:
avrdude-original: load data flash data from input file output.hex:
avrdude-original: input file output.hex auto detected as Intel Hex
avrdude-original: input file output.hex contains 28968 bytes
avrdude-original: reading on-chip flash data:

Reading | ################################################## | 100% 3.24s

avrdude-original: verifying ...
avrdude-original: 28968 bytes of flash verified

avrdude-original: safemode: lfuse reads as 0
avrdude-original: safemode: hfuse reads as 0
avrdude-original: safemode: efuse reads as 0
avrdude-original: safemode: Fuses OK (E:00, H:00, L:00)
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe
[email protected]:/opt/openenergymonitor/EmonTxV3CM $ sudo systemctl start emonhub.service                                              [email protected]:/opt/openenergymonitor/EmonTxV3CM $ sudo systemctl status emonhub.service
● emonhub.service - emonHub data multiplexer
   Loaded: loaded (/opt/openenergymonitor/emonhub/service/emonhub.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-10-17 12:05:10 BST; 8s ago
  Process: 31380 ExecStartPre=/bin/mkdir -p -m 0775 /var/log/emonhub/ (code=exited, status=0/SUCCESS)
  Process: 31381 ExecStartPre=/bin/chgrp -R emonhub /var/log/emonhub/ (code=exited, status=0/SUCCESS)
 Main PID: 31382 (python3)
   Memory: 11.3M
   CGroup: /system.slice/emonhub.service
           └─31382 python3 /usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonh

[edit]
BTW, no need to keep downloading the firmware hex. Delete the extra ones.

I did stop it (see below); after it failed again, I had a look inside ‘/opt/openenergymonitor’ and I don’t have a folder called EmonTxV3CM (or anything similar) - see end of screen grab below. Should I have?

During this I have not been pressing the Reset button; again, should I have been?

TIA

Last login: Sat Oct 17 11:47:10 on ttys000
Julians-42-iMac:~ jjb$ ssh [email protected]
[email protected]'s password: 
Linux emonpi 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Oct 17 11:47:29 2020 from 192.168.2.30
^[[[email protected]:sudo systemctl stop emonhub.service
[email protected]:~ $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:firmware.hex.2

avrdude-original: Version 6.3-20171130
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2014 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 12
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
strace: |autoreset: Broken pipe
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe
[email protected]:~ $ cd /opt/openenergymonitor/EmonTxV3CM/
-bash: cd: /opt/openenergymonitor/EmonTxV3CM/: No such file or directory
[email protected]:~ $ cd~
-bash: cd~: command not found
[email protected]:~ $ cd ~
[email protected]:~ $ ls
firmware.hex  firmware.hex.1  firmware.hex.2  firmware.hex.3  firmware.hex.4  readme.md
[email protected]:~ $ cd /opt
[email protected]:/opt $ ls
emoncms  openenergymonitor  vc
[email protected]:/opt $ cd /opt/openenergymonitor
[email protected]:/opt/openenergymonitor $ ls
avrdude-rpi  data  emonhub  emonpi  EmonScripts  RFM2Pi
[email protected]:/opt/openenergymonitor $ 

No, I downloaded the repo and compiled it as I was fiddling with the code.

No, but a complete power off/on of the TX won’t go amiss.

That example flash was done from my desk without me touching the hardware.

Thanks. This is strange; having removed the hex.2, hex.3 etc using FileZilla, I shut down the PiZ within the emonCMS Admin section, waited a bit, unplugged and replugged the Tx (which itself powers the pi) then stopped emonhub through ssh - and I could see the log stop within emonCMS / emonHub to confirm this. I then ran the install script.

Pipes are new to me, but I have now googled them; is the “broken” pipe |autoreset something I have caused?

Last login: Sat Oct 17 13:37:01 on ttys000
Julians-42-iMac:~ jjb$ ssh [email protected]
[email protected]'s password: 
Linux emonpi 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Oct 17 13:37:22 2020 from 192.168.2.30
[email protected]:~ $ sudo systemctl stop emonhub.service
[email protected]:~ $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:firmware.hex

avrdude-original: Version 6.3-20171130
                  Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
                  Copyright (c) 2007-2014 Joerg Wunsch

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 12
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe
[email protected]:~ $ 

When you restarted the TX, did you check and see if there was any data flowing?

What do you get if you just try miniterm?

EmonHub is “doing something”, but no data is arriving at emonCMS on the main emonPi (under the #hotwater section).

Re: miniterm - nothing, whether I stop emonHub first or not.

Last login: Sat Oct 17 15:23:00 2020 from 192.168.2.30
[email protected]:~ $ sudo systemctl stop emonhub.service
[email protected]:~ $ miniterm /dev/ttyAMA0 115200
--- Miniterm on /dev/ttyAMA0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---



Does data need to be getting through to the main emonPi for this firmware update to work, or does that not matter?

I don’t understand why it won’t flash. Do you have a programmer?

@Robert.Wall or @TrystanLea can you help, please? Has the bootloader got corrupted? I don’t understand these chips - I can usually just flash them.

[edit]
One other thing, while connected to miniterm, if you hit the TX reset, do you get anything?

I haven’t been following this thread in detail, what is the objective?

I’ve never tried to flash a serial-connected emonTx with a Pi, I only ever flash it with the Arduino IDE and the ‘Shop’ programmer from a Laptop.

I have programmed the emonPi front end (which I guess is similar) from a Laptop via the emonPi - I have a script to do that and I’ve installed the key files so that no passwords are necessary. I’ll write up details of that if it might help - but I don’t want to unnecessarily confuse the issue.

Pardon me for saying, but I think Julian, you don’t understand how all the bits fit together. Would you like me to try to write that up as well? - it requires an answer to “what is the objective” first. :slightly_smiling_face:

I do have an unused programmer purchased from the OEM shop a while ago; perhaps it would allow me to re-flash(?) the emonTx firmware more easily?

When I run miniterm, whether I had previously stopped emonhub.service or not, pressing the Reset button made no change.

Last login: Sat Oct 17 15:25:20 2020 from 192.168.2.30
[email protected]:~ $ sudo systemctl stop emonhub.service
[email protected]:~ $ miniterm /dev/ttyAMA0 115200
--- Miniterm on /dev/ttyAMA0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Connection to 192.168.2.53 closed by remote host.
Connection to 192.168.2.53 closed.
Julians-42-iMac:~ jjb$ ssh [email protected]
[email protected]'s password: 
Linux emonpi 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Oct 17 15:55:55 2020 from 192.168.2.30
[email protected]:~ $ miniterm /dev/ttyAMA0 115200
--- Miniterm on /dev/ttyAMA0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---



@Robert.Wall What I have been trying to achieve is as follows …

  • My main unit is an emonPi, running emonCMS locally.
  • I have four emonTx c/w ESP8266 chips spread about the house, garage, barn & office which have proved not that robust comms-wise (I do have good wi-fi everywhere), and I wanted to swap the ESP8266’s for Pi Zero’s.
  • So far I have done two, but I then discovered that the two emonTx’s had different fw versions and we were in the process of trying to flash a new version (via ssh) to one of them when it began to unravel & “go wrong”. :cold_face:
  • This emonTx is no longer sending data to the main emonPi’s emonCMS / Inputs page. The second one still is, but I have yet to try to change the fw on that one.
    I do have a programmer, but have never used it.

Robert, I will be the first to admit that my knowledge of all things Linux is very limited; I’m 61 and have done very little “programming” since my beloved Sinclair ZX Spectrum in 1984. I do run several other Pi’s, running Node-RED, HomeBridge & Pi-Hole etc, and Docker containers in a Synology NAS, so I have at least started the journey. But until very recently, talk of sketches, Arduino, miniterm and avrdude were all alien to me … :crazy_face:

Does that help?

Hi Robert, Julian is moving to use RPis directly connected. One is working, but the second TX he is using was not loaded with the CM firmware. We tried to do that from the Pi (which should work) but seems to have upset the TX.

Julian has a programmer, just needs some help to programme it from a PC now.

[edit]
@Robert.Wall, could the bootloader be corrupted?

https://wiki.openenergymonitor.org/index.php/EmonTx_V3.4#Uploading_Firmware

I’m beating you on age by a decade, no bleating allowed there :wink:
But I’ve been solidly involved (not as my full-time job, I’m really an electrical engineer) since the early 1970s. I’m not all that up-to-date with the details of Pi’s and modern networking, I defer to Brian and Paul on that.

I believe so. You need, if you don’t have it, the Arduino IDE on your computer (full instructions for getting it and installing the libraries etc you need are in ‘Learn’) and when you’ve done that, connect the computer and programmer with a USB extension cable (optional but advised) and the other end of the programmer to the emonTx - of course disconnecting the Pi and watch which way round you connect it. I don’t, can’t and won’t support platformio. That’s how I work all the time, and it suits me. If you desperately want to use platformio, somebody else will need to help you.

As I wrote earlier, I’d advise you to use the latest “CM” sketch in all your emonTx’s I’d also advise editing the sketch to disable the radio if you’re never going to use it. (And that’s even more important if you have RFM12B radios in some of the emonTx’s.) It’s a lot safer and very easy to disable it when you’re reprogramming it - and you’ll never need to worry about it again.
[Edit] It’s also going to be a good idea to give each its unique NodeID set in the sketch too.

Your first step will be to get the emonTx sending data to your computer via the programmer and the Arduino monitor screen.

When that’s OK, disconnect the programmer and connect your Pi Zero W. That’s running emonCMS? If you check (and change if necessary) the serial baud rate, and change the middle part of the node definition for the emonTx (whichever NodeID it’s using) to

       names = MSG, Vrms, P1, P2, P3, P4, E1, E2, E3, E4, T1, T2, T3, pulse
       datacodes = L,h,h,h,h,h,l,l,l,l,h,h,h,L
       scales = 1,0.01,1,1,1,1,1,1,1,1,0.01,0.01,0.01,1
       units = n,V,W,W,W,W,Wh,Wh,Wh,Wh,C,C,C,p

then the data from the emonTx should appear in the Pi Zero’s emonhub.log

I’d almost suggest that you do a very basic set-up (via a web browser over your LAN) of each of the PiZero’s, just so that you have confidence that the data is coming in.

I’ll stop there for now, because we’re getting into Brian’s networking territory, and there’s plenty there to be getting on with.

Would you like me to post a “non-radio” but otherwise standard “CM” sketch for you, or just a list of changes you need to disable the radio? (The first is easier for you, but you’ll learn more from the second.)

@Robert.Wall, you have missed the point. The emonub part etc is fine, it is just the sketch (hex) will not load.

Could it be the bootloader? (I don’t pretend to understand the inner workings of the ATMEGA chip).

Thanks @Robert.Wall; I have downloaded the Arduino IDE on to my Mac (I don’t have access to Windows).It installed without asking for USB drivers, and I will use a “stock” USB lead as I didn’t get one from the Shop. Presumably I connect (emonTx first, programmer second) RTS > RST, Tx > Rx, Rx > Tx, 5v > 5V, “_” > 3,3 and GND > GND.

I have downloaded and installed the CP210x USB to UART Bridge VCP Drivers from the Silicon Labs website (but didn’t actually “link” the two - not sure if one has to). I have never come across Platformio.

When I connect the programmer to the Tx I am able to select the Port > “/dev/cu/SLAB_USBtoUART”. The blue light is on the programmer, and presume the Tx is powered via the programmer.

At this point I get stuck, and am not sure how to “drive” the Arduino IDE.

I am more than happy to try to edit the sketch to disable the RF when I know how :crazy_face:

I told you I wasn’t following closely.

Me neither. But I’ve never experienced a dead/corrupted bootloader.
What happens is, the compiler compiles the sketch into the native code, which is written to a .hex file. The loader “avrdude” puts a reset onto the ATMega 328P, and the bootloader opens short time window in which avrdude needs to send the code. If the reset doesn’t get there, or the code doesn’t start within that window, you get the infamous “not in sync” messages.

I think the programmer route is well proven and eliminates a lot of variables, so that’s the first step. It’s only ever failed for me when a wire’s fallen off (which is quite frequent given the abuse they get from me). So I advise trying with the programmer.
N.B. The programming baud rate isn’t the same as the one you use for serial comms when the sketch is in control.

OH NO YOU DONT.

The emonTx pins are wrongly labelled, so you’re actually connecting Tx-Tx if you do that. The emonTx expects to see data coming in on its Tx pin, and sends its data out on its Rx pin.

Don’t use any wander leads - just plug the programmer straight onto the header of the emonTx.

That sounds right. If you unplug the programmer, that port should disappear.


That is the default opening screen. You don’t want it. You can get rid of it after you’ve opened your sketch:

Did you follow the bits in the instructions about your “Sketchbook Location”? If you did, go File → Sketchbook and locate the source (that you downloaded from GitHub) - it should be called “EmonTxV3CM.ino” and when you load it, you should see three files in three panes, that one first (without the extension “.ino” on the tab), also “config” and “rfm”. All 3 are necessary.

To compile and upload, click the second button (the right arrow in a blue circle). If you get error messages, you’ve probably missed a library (emonLibCM isn’t on the list of those you must download: it’s at GitHub - openenergymonitor/EmonLibCM: Continuous Monitoring alternative to EmonLib).

You’ll need to use the inbuilt serial monitor (magnifying glass top right) to see the emonTx’s output, set 115200 baud and “Both CR & LF” [bottom right].

I was trying to avoid the need for this compiling stage, IDE etc. Ho hum, I’ll leave you to getting the TX flashed with the new firmware using the IDE. I’ll come back in after that is working :slight_smile:.

In my view, this is the best way to learn, because once you’ve got everything set up, you’re not dependent on finding a sketch that has exactly all the options you need. You can see - and in time understand - what you’re loading and running, and make changes to suit your individual needs. And should the compiled files ever disappear, you’re not sunk, like you are with proprietary software.

2 Likes

Sorry, I mis-typed. I should have written RST>RTS, RX>RXD, TX>TXD, “-”>3.3V and GND>GND; the only alternative would be to swap the whole thing 180 degs, and can’t be right…

Photo with programmer laid on top temporarily to show labelling.