Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Unable to get emonupload to work

I am trying to use emonupload to change the AVR software for direct serial output.
My setup is a RPi 3, Nov16 release of emonpi SW, EmonTXv3.4.1 (dated March 2015) with RF69 module.

When I first ran emonupload it updated itself and created all the firmware folders and copies of latest firmwares.
I initially tried with direct wired connection from the ISP connection on the Emontx to the GPIO header of the Rpi and can see the serial output of the emontx when using option ‘s’ of emonupload but it wouldnt program a new firmware because it couldnt find a valid usb port.
So I connected a CP2102 usb-serial converter (NOT the openenergy one) between the Rpi and emontx ISP port and got a similar result.
In both cases, when running the firmware upload option (x) I get the following output:

emonTx 3-phase Upload

Burning Bootloader
sudo avrdude -p atmega328p -c avrispmkII -P usb -e -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U flash:w:bootloaders/optiboot_atmega328.hex:i -Ulock:w:0x0f:m
avrdude-original: usbdev_open(): did not find any USB device “usb” (0x03eb:0x2104)

avrdude-original done. Thank you.

As a secondary observation of the emonupload program I notice that everytime I run it, it downloads the same firmware images, ie:
RFM69Pi detected
Testing internet connection…
Internet connection detected
Already up-to-date: emonUpload
Already up-to-date. repos/openenergymonitor-emonth2
Already up-to-date. repos/openenergymonitor-emonth
Already up-to-date. repos/openenergymonitor-emonpi
Already up-to-date. repos/openenergymonitor-emontxfirmware
Already up-to-date. repos/openenergymonitor-emontx-3phase

Latest openenergymonitor/emonth2firmware: V3.2.1
_ Downloading: firmware.hex Bytes: 49118 49118 [100.00%]_
Latest openenergymonitor/emonthfirmware: V2.6.0
_ Downloading: emonTH_latest.hex Bytes: 36885 36885 [100.00%]_
Latest openenergymonitor/emonpifirmware: V2.8.2
_ Downloading: firmware.hex Bytes: 50356 50356 [100.00%]_
Latest openenergymonitor/emontxfirmwarefirmware: V2.6.0
_ Downloading: firmware.hex Bytes: 53912 53912 [100.00%]_
Latest openenergymonitor/emontx-3phasefirmware: V0.9.4
_ Downloading: firmware.hex Bytes: 38022_

Additional info:
[email protected](rw):emonupload$ lsusb
Bus 001 Device 005: ID 13ba:0018 PCPlay Barcode PCP-BCG4209
Bus 001 Device 004: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[email protected](ro):emonupload$
[email protected](ro):emonupload$
[email protected](ro):emonupload$ ls -la /dev/{tty{AMA,S,USB},serial}*
crw-rw---- 1 root dialout 204, 64 Jan 11 17:10 /dev/ttyAMA0
crw-rw---- 1 root dialout 4, 64 Jan 11 16:52 /dev/ttyS0
crw-rw---- 1 root dialout 188, 0 Jan 11 16:52 /dev/ttyUSB0

/dev/serial:
total 0
drwxr-xr-x 4 root root 80 Jan 11 16:52 .
drwxr-xr-x 15 root root 3380 Jan 11 16:52 …
drwxr-xr-x 2 root root 60 Jan 11 16:52 by-id
drwxr-xr-x 2 root root 60 Jan 11 16:52 by-path
[email protected](ro):emonupload$

emonupload is designed to work using a USB Atmel AVR MkII ISP programmer.

However, the ISP programmer is only needed to upload the Arduino Uni / Optiboot bootloader. If you are trying to upload to an existing emonTx, the upload should be done via a serial UART programmer. Have you got a USB serial to UART programmer you can try and use? Any 5V USB to UART (FTFDI) programmer should work as long as the pinout is the same as the one from the shop: shop.openenergymonitor.com/programmers

Thanks Glyn,
I used my CP2102 based USB-Serial converter to connect between the Rpi usb port and the EmonTX ISP port, but the emonupload program seems to get stuck on that first bootloader command. The only keystroke that has any effect is CTRL which drops out of the whole python program.

I finally did have some success when I copied the avrdude string used in the ‘update now’ function on the administration page of emoncms, and modified the target firmware to be the direct serial version. I then reconfigured the connection so that the ISP port is wired to the GPIO pins on the RPi and voila!! it uploaded the firmware.
(avrdude -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:…)

The output of the emontx now looks correct (5 sets of numbers and a CR/LF), though emonhub just repeats the invalid character message. (not in front of RPi ATM and cant quite remember the message).

The connection should be between the RasPi USB port and the emonTx UART connector not ISP. The application code is uploaded via serial UART not ISP.

Oops, I’ve confused the names of the ports. I was actually using the UART connector on the emonTx not the ISP port, I just called it the wrong name.
Emonhub just reports the ‘thread is dead’ message continually, though when I tap into the output of the UART port I can see that the message is correctly formatted.

emonTx V3 Direct serial Example
231.44 -1.41 282.66 0.04 224.85

2017-01-12 09:23:17,019 WARNING MainThread RFM2Pi thread is dead
2017-01-12 09:23:17,020 WARNING MainThread SerialDirect thread is dead

I have it wired as:
Rpi ------------------->emonTx UART
6 --------------------------Gnd
8 ---------------------------Tx
10 --------------------------Rx
7 --------------------------Rst

Ah to run emon upload you will have to stop emonhub since emonhub will be using the serial port

4 posts were merged into an existing topic: emonTx connecting to arduino IDE using programmer

A post was merged into an existing topic: emonTx connecting to arduino IDE using programmer