Community
OpenEnergyMonitor

Community

Programmer USB to serial UART connections with EmonTx shield using Arduino IDE on Mac OSX


(emjay) #2

The error report is a generic avrdude complaint that it cannot have a meaningful conversation with the bootloader - many causes e.g. wrong baud rate, TX/RX pins switched etc
Do you have a /dev/tty.usbxxxx entry in the IDE Tools/Serial Port options list?


(Paul) #3

So clearly it works sometimes

I’m not sure why you are restarting the IDE, but if you do, ensure you have shut ALL the Arduino IDE windows, including the serial monitors. I could be that the “device is busy” because a previous serial monitor instance still has sole control of that serial port.

Likewise if you have an application consuming the data from the serial port (Arduino) you must stop that application whilst attempting to upload a new sketch.


(Andrew Findlow) #4

Here are the port that I have available on the Arduino IDE


I’ve not switched the pins on the EmonTx shield or on the USB to serial UART programmer; made sure they both matched and I had it correctly plugged in.
I don’t have tty.usbxxxx but cu.usbxxxx.


(Andrew Findlow) #5

I was just trying to make sure nothing else was accessing the Arduino (that it had stopped). I only get the error when I select the “dev/cu.SLAB_USBtoUART” port and not when I select “dev/cu.usbmodem1431 (Arduino/Genuino Uno)”
I very new to using Arduino’s, hence the sandbox, is there anyway of ensuring that the device is not busy - the amber LED is solid before I press the upload button?


(Andrew Findlow) #6

Forgot to mention that when I select “Get Board Info” with “dev/cu.SLAB_USBtoUART” I get:

56

but when I select “Get Board Info” with “dev/cu.usbmodem1431 (Arduino/Genuino Uno)” I get:

18


(Sharky1337) #7

I got my emontx v3 today and I have exactly the same problem. I want to update the firmware to the latest version.

avrdude -v -c arduino -p ATMEGA328P -P /dev/cu.SLAB_USBtoUART -b 115200 -U flash:w:emonTxV3_RFM69CW_DiscreteSampling_433.cpp.hexx

avrdude: Version 6.3, compiled on Sep 18 2017 at 20:31:51
Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright © 2007-2014 Joerg Wunsch

     System wide configuration file is "/usr/local/Cellar/avrdude/6.3/etc/avrdude.conf"
     User configuration file is "/Users/sharky/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.SLAB_USBtoUART
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x63
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x74
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x31
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x3a
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x2c
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x63
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x74
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x32
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x3a

avrdude done. Thank you.

Maybe it has to do with the brand new driver from the manufacturer ? They were updated three days ago.

System Mac OS Sierra
CP210x USB to UART Bridge VCP Drivers for Macintosh

From the relase Notes

Release Dates

CP210x Macintosh OSX VCP Driver 5.0.4 - January 19, 2018


(Andrew Findlow) #8

No, I don’t think it’s that, I’ve also tried the Legacy OS Software and Driver Packages. This is CP210x Macintosh OS X VCP Driver v4 Release (November 3, 2016) of this driver, which has the same results.


(Andrew Findlow) #9

I’ve also just used the PlatformIO IDE for Atom and get exactly the same results as the Arduino IDE. The port details available are:


(Andrew Findlow) #10

Hi Paul,
Sorry, I missed your first comment “So clearly it works sometimes”. It works all the time with the “dev/cu.usbmodem1431 (Arduino/Genuino Uno)” port (usb direct into the Arduino Uno) but not at all with “dev/cu.SLAB_USBtoUART” port into the EmonTx shield.


(Sharky1337) #11

My fault , was not connecting the rst port from my uart to the emontx


(Robert Wall) #12

Ah, that’s what puts the bootloader into programming mode. Therefore, if it does not get that, it will not go into programming mode, and it will not respond as the programmer expects.


(Andrew Findlow) #13

Made some progress with the uploading to the EmonTx shield and arduino uno using various USB to serial UART and FTDI programmers in a fashion. I have found that using these I have to manually press the reset button just prior to beginning upload (tried connecting the RST port direct on the uno but this did not work for me).
I have now collected data for the calibration of the AC/AC voltage sensor and the CT sensors; I have modified the Shield_CT1234_Voltage_SerialOnly.ino and voltage_and_current.ino uploaded these (using both Arduino IDE and Platform IO) and was able to stream these output data using the serial monitor.

So, having played with the EmonTx shield/Arduino Uno (my rudimentary sandbox) I wanted to then try the same with the EmonTx’s that I have in my monitoring system. First, I thought I would just try and upload the emonTxV3.4 Discrete Sampling V3.0 firmware (without any modification) to see if this method would work. Nevertheless, I have a problem with the compiling process (I have all library’s installed as per Installing the Arduino Libraries – macOS); when I run pio run from terminal I get:

Or when I compile using ‘PlatformIO: build’ I get this:

I also have the platformio.ini with in the project.

Any help with this would be much appreciated and help with my steep ‘one step forward, two steps back’ learning curve, what have done wrong or missed out for this to have?


(Robert Wall) #14

That link is to just one file, “src.ino” If you step back into the directory it’s in, you will find another file. You need all of the “src” directory on your machine for the Arduino IDE to compile. I can’t get platformio to work properly for me (it moved stuff about and destroyed my system), so I can’t help with that.
(This is a peculiarity of the Arduino IDE - it doesn’t work the same way as all the other IDE’s that I’ve come across, in that it assumes where other files are, and if they’re not there, it’s lost.)


(Andrew Findlow) #15

Ah yes, I did see the config.ino file but was not sure what to do with it. If I then put that file in the same directory as the src.ino, open the src.ino and compile it, it will read the config.ino file from the same directory; or do I have to set something somewhere in Arduino IDE?


(Paul) #16

Yes. The normal convention is/was to have a sketch in a folder of the same name minus the .ino , for example mysupersketch.ino would reside in a folder called mysupersketch. Any other files can then be bundled with the main .ino by including them in the mysupersketch folder.

This still works the same way, however when Platformio was adopted by this project, pretty much every sketch was renamed to “src” as at the time it was believed that was essential for Platformio operation (which I don’t believe is the case).

So basically the “src” directory you are compiling the sketch from is actually part of the sketches structure and not just a folder of the same name, any files you place in the src folder will be seen by the IDE and assumed to be part of the same sketch (if the file extension is valid).

For the record, IMO if the src folder (and sketch) was more appropriately named, this would be more obvious for both Arduino IDE and Platformio users, or indeed anyone navigating or discussing the code.


(Robert Wall) #17

I second that. As platformio misbehaved for me so I can’t and won’t use it, I now have the problem, when I’ve got several different sketches open in a decent editor, that every page is called “src.ino”. That’s utterly confusing.

That’s what I was alluding to when I wrote “You need all of the “src” directory”. Most IDE’s and compilers will allow and use a full path (or relative path) for included files. Not so the Arduino IDE. You don’t specify them in the ‘main’ sketch file, instead you must have them (and nothing else that can be compiled) in the same bottom-level directory.


(Andrew Findlow) #18

One small step forwards, I have both *.ino files in the Arduino IDE (and also PlatformIO) and the error reporting has significantly reduced to (I’ll just report the Arduino IDE error for the time being):

I noticed that it mentions “multiply libraries were found” (line 9), but I only have the one library in Arduino IDE (the other set of libraries are associated with PlatformIO - totally not connected). BTW is this screenshot of the window suitable or would you need to see a copy and paste of the text?


(Robert Wall) #19

I’m not even going to try to read that!
My personal advice, and definitely not the official OEM advice (and bear in mind I have only less than superficial knowledge of the MacOS) is to run with Arduino IDE and forget platformio. I’ve no idea where platformio needs the libraries to be, or if it and the Arduino IDE can successfully share the same files, but having two sets where one or the other system can see both is definitely wrong.

So I think you need to think why you need both, and work from there.


(Andrew Findlow) #20

After taking onboard the advice

So I think you need to think why you need both, and work from there.

and the information about firmware file locations.

So basically the “src” directory you are compiling the sketch from is actually part of the sketches structure and not just a folder of the same name, any files you place in the src folder will be seen by the IDE and assumed to be part of the same sketch (if the file extension is valid).

I did some more researching and read carefully PlatformIO: Compile & upload firmware. Blog post 1/3, which was very informative. The penny dropped when I read this blog, specifically step 2 about cloning from GitHub

  1. Clone emonTx / emonPi repo
    We’ll use the emonTx (V3 discrete sampling) as an example here but the steps are exactly the same for emonPi.
    emonTx V3
    $ git clone https://github.com/openenergymonitor/emonTxFirmware$ cd emonTxFirmware/tree/master/emonTxV3/RFM/emonTxV3.4/emonTxV3_4_DiscreteSampling emonPi $ git clone https://github.com/openenergymonitor/emonpi
    $ cd emonpi/firmware

After following these instructions I was then able to use PlatfomIO on my Mac OSX to compile, upload, use terminal window and serial monitor. I used PlatformIO on Mac OSX the to up load firmware to EmonTx’s and EmonTh’s, changing node ID’s and saving config to EEPROM [emonTx / emonTH configure RF settings via serial (released FW: V2.6 / V3.2)] using instructions here emonTx / emonTH configure RF settings via serial (released FW: V2.6 / V3.2)

I was then ‘feeling brave’ and decided to have ago at the CLI PlatformIO on my EmonPi and this worked very well also to upload firmware etc., using the upload port /dev/ttyAMA0 stopping and starting emonhub. The only snags I had with this was firstly, the LCD on the EmonPi locked with the screen saying it was booting, which easily rectified with rebooting the EmonPi from local Emoncms; the second was, the very last PlatformIO CLI

  1. View serial port with PlatformIO CLI
    $ pio serialports monitor -b9600

I could not get this to work with baud-rates 9600 or 115200, what is the correct baud-rate or have I missed something out?.

I still have both Arduino IDE and PlatformIO IDE installed, PlatformIO (now) works for me nevertheless, I’m a relative newbie to this level of open source hardware and software (so had no prior experience of using IDE’s to compare it with); still climbing up this learning mountain just beginning to see ‘base camp’.

I’m just starting to get to grips with calibrating the voltage sensor and CT sensor outputs in EmonPi and EmonTx, which I’ll continue in the first topic I posted Ref voltages on emonpi and emontx calibration and more accuracy when I have some more data and made adjustments in the firmware.

Many thanks for all the help.


(Robert Wall) #21

I can’t comment about platformio. As I’ve previously said, I threw it out when it fouled up my system and cost me several hours work to restore.