LowPowerLab Forum

Hardware support => Moteino => Topic started by: KISA on June 04, 2018, 06:38:12 AM

Title: Program Moteino using Ardunio Uno
Post by: KISA on June 04, 2018, 06:38:12 AM
Hi,
I just received two Moteino's today, with the expectation I could easily program them using my Arduino Uno. From the searches I've done over the last hour I can't find any information explaining how to do it (let alone how to wire it up).
If someone could please tell me how to do it I'd be very appreciative, as I'd rather not wait another couple of weeks before I can try them out  :-[.
I already have 5v -> 3.3v and 3.3v -> 5v logic converters so I've got the safe voltage levels sorted  :).
Thanks and regards,
Markus
Title: Re: Program Moteino using Ardunio Uno
Post by: LukaQ on June 04, 2018, 10:25:18 AM
Hello,

Moteinos are made to be programed with usb to serial, like uno, which has this converter onboard. In most cases, you use another arduino as programmer, when you want to change bootloader. This is not the case here. You can (I think) do with with uno also, you upload bootloader with sketch at the same time. Anyway, normal way is to use converter, like FTDI.

I haven't look, if uno could be used as usb to serial converter (I think I would be possible, but very impractical). So get yourself usb to serial... or remove atmega from uno and use it's lines for this purpose.

BTW, many Moteinos and Arduinos don't have this converter onboard, to save size, cost, consumption,... But you do have Moteinos, da also have this converter on it, just just plug it into USB 
Title: Re: Program Moteino using Ardunio Uno
Post by: Felix on June 04, 2018, 10:46:46 AM
All of this is explained in the Moteino guide (https://lowpowerlab.com/guide/moteino/programming-libraries/).
Title: Re: Program Moteino using Ardunio Uno
Post by: KISA on June 05, 2018, 04:18:08 AM
Thanks for the replies LukaQ and Felix.

I have seen the link you provided Felix, it basically say's buy your USB card to program the Moteinos.

As per my original email, I am interested to know why the Moteino's can't be programmed using an Arduino (e.g. Uno) as the programmer, using their ability to function as an ArduinoISP. I have done this with ATTiny84's and as the Moteino is primarily a MEGA328P I'm of the thought it could be programmed the same way.

Is this correct, i.e. program the MEGA328P via D10, D11, D12 and D13? (like this: http://www.instructables.com/id/Arduino-UNO-as-AtMega328P-Programmer/)

I just don't know if the configuration of the Moteino, now that you're added the RFM69, affects it's ability to be programmed that way?
Title: Re: Program Moteino using Ardunio Uno
Post by: TomWS on June 05, 2018, 07:25:45 AM
Quote from: KISA on June 05, 2018, 04:18:08 AM
As per my original email, I am interested to know why the Moteino's can't be programmed using an Arduino (e.g. Uno) as the programmer, using their ability to function as an ArduinoISP.
Your original post did NOT say you were trying to use the Uno as an ISP programmer.  This makes a HUGE difference.
Quote
I just don't know if the configuration of the Moteino, now that you're added the RFM69, affects it's ability to be programmed that way?
If you are trying to program a Moteino using an ISP, you must pullup the radio SS (pin D10) and the Flash SS (if you have Flash onboard - pin D8).
Title: Re: Program Moteino using Ardunio Uno
Post by: KISA on June 06, 2018, 08:45:11 AM
Thanks for the reply TomWS. The question wasn't method specific, it was simply "Program Moteino using Ardunio Uno", I'd be happy for any way that doesn't require me to paid the extra and wait for the part :).
I just suggested ISP after the reply basically dodged the question and I wanted to throw a suggestion in :).

In addition to your directions to pull up D10 and D8, do you know what the other connections are? Are they as per the link I added in my previous post?
I'm also concerned about the Uno +5V logic and want to confirm any actions I need to ensure I don't fry the Moteino or RFM69, e.g. use 3.3v to 5v logic converters for all the connections. Or if there is a requirement to supply 5v to the vcc (or some other pin) to allow programming? There is such a mixture in info out there (pertaining to the MEGA328P, but not the Moteino), I'm not confident on which way to go :(
Title: Re: Program Moteino using Ardunio Uno
Post by: Felix on June 06, 2018, 10:34:01 AM
I don't know the answer to this, I did this once just to prove to myself I can do it but then I never wanted to repeat or remember how to do it again. Ever. Just got myself a proper programmer.

Do you plan to use an Arduino UNO in perpetuity to program your 328p based boards?

An FTDI-Adapter is $14.95, and it's designed to make it easy and convenient and to just work so you spend your time doing other more useful things than trying to determine how to wire ISP, how to shift voltage levels correctly from the 5V UNO etc etc etc etc etc. There are many alternatives out there that are equivalent and can be even cheaper (clones etc).

Any time I see this question in the forum I wonder how much is the user's time worth, which they spend doing all this figuring out?
Title: Re: Program Moteino using Ardunio Uno
Post by: perky on June 06, 2018, 11:23:27 AM
@KISA
If you have a standard FT232R 5V VCC and 3.3V I/O USB to TTL FTDI cable, which you possibly do if you have a UNO, you can use that as an ISP programmer. Felix's USB card is just a USB to TTL converter, it performs the same function as that cable. Just check you have the 3.3V I/O version of the cable with a 5V VCC output, and you can use the 5V pin to power the Moteino (not the Moteino without the LDO).

I think the latest version of AVRdude supports libftdi:

https://electronics.stackexchange.com/questions/353577/configure-avrdude-for-programming-with-a-ft232r-cable

Mark
Title: Re: Program Moteino using Ardunio Uno
Post by: KISA on June 07, 2018, 04:17:31 AM
Thanks again for the replies. To answer your question/thought Felix, I actually started by purchasing a Uno, numerous ATTiny84's, numerous RFM69CW boards and a Ethernet shield for the Uno. I built a PCB to attach one RFM69 to the Uno and a small pcb to connect an RFM69 to one of the ATTiny84's. The plan is to construct I home monitoring system (initially temperature), with the ATTiny's acting as the nodes and the Uno as the gateway talking to my OpenHAB gateway.

Then the fun started.

I got the Uno communicating to the OpenHAB fine, but I could not get the RFM69's to connect to each other. I tried a number of example software designed to test the RFM69's, without luck. I checked my construction many times over, tried different control lines, etc, none of which worked. I connected my logic analyser to the pins running to the RFM69's and they seemed to be pulsing as they should. So that left me with two options, purchase two of your boards to see an example of successful communications (and 100% correct logical communication to the RFM69's) and/or to purchase a RTL-SDR to use as a spectrum analyser to confirm they boards were transmitting. I did both :).
The RTL-SDR turned up today and it appears all my boards are transmitting, but do not have the same center frequency, they appear to be about 80khz apart, but I don't know it that's normal and the unfiltered signals still overlaps and they can communicate. So once I program your boards and test them I will know (hopefully) what the correct operation should look like and get all my boards working :).
So in answer to your question, I do not intend to purchase any more 328p's, I just wanted these for testing, hence why I'd rather not spend any more money just to program them once.
I have a number of USB to TTL devices, most don't have CTS or DTS, so I'll look through what I have.

Title: Re: Program Moteino using Ardunio Uno
Post by: LukaQ on June 07, 2018, 07:04:55 AM
just keep in mind that SDR is not spectrum analyzer, yes you can see if your in the ballpark, but nothing more then that
Title: Re: Program Moteino using Ardunio Uno
Post by: KISA on June 07, 2018, 11:09:37 PM
I managed to find an XBEE Explorer USB to TTL in amongst my electronic gear, got the programming working and got the 2 Moteino's communicating :). Checked the signals on the RTL-SDR and they were apart by 20kHz-30kHz, so there is clearly a bit of slack. Was then able to get one of my other boards communicating with the Moteino, so all looking promising.

Just have to get the RFM's working with the ATTiny84's

I'll just add, the AIRSPY SDR software with the RTL-SDR is awesome (especially for the overall price).

Thanks for all the help and suggestions.