Browse Tag: Arduino

Flying with ATtiny and ESP8266

So I decided to make an RC airplane and to make it as simple as possible. No sensors, no autopilot, just raw commands from the remote executing on the airplane. I’m not saying that’s a good idea, but I decided to go like that.

attiny

Anyway, I wanted the airplane to be as most simple as possible. So there are servos, engine, battery, receiver and the micro controller. Initially, the idea was to use the Arudino Pro Mini, but in the meantime, I remembered that somewhere in my boxes I have ATtiny25. I wasn’t sure will it fit and on the first sight it didn’t. Most specifications I was able to find on the internet was saying that there are just two PWM outputs, and I needed one more of them. I also needed some sort of communication port like serial port which was not discussed in the datasheet. I¬†lacked knowledge about that micro controller and I knew that. And I didn’t allow that to discourage me. I believed it should be able to do a job for me. I did a little research till late morning hours and it happened that I was right ūüôā

Programming the ATtiny25

I didn’t have programmer¬†for this ATtiny and I wanted to program it with my Arudino. I heard somewhere it is possible.

First, you need to upload a sketch to your Arduino to act like the ISP:

Then here is how to connect the ATtiny to the Arduino:

http://highlowtech.org/?p=1706

And after that, you’ll need some libraries, to explain your Arduino software how to program the ATtiny. If you have ATtiny 45/85 then I think this should work a job for you:

http://highlowtech.org/?p=1695

I had ATtiny25 so I also needed this:

https://code.google.com/p/arduino-tiny/

Getting one more PWM on the output

So as I said, there are two PWM outputs, and I wanted one more. I found the solution here:

http://www.technoblogy.com/show?LE0

It involved some advanced levels of Arudino programming (something weird on the first sight) but¬†it’s worth it.

Getting serial Rx channel

My ATtiny needed only Rx line on Serial, for receiving the commands. As it turned out, it was not that simple to get one, and after looking what serial libraries are used, there was no support for the Rx, only for Tx. By default it was using TinyDebugSerial library which always returns -1 when Serial.available() is called. SoftwareSerial was too big for ATtiny, so I had to google something new. I found the solution here:

https://code.google.com/p/nerdralph/source/browse/#svn%2Ftrunk%2Favr%2Flibs%2Fbbuart

http://nerdralph.blogspot.com/2014/01/avr-half-duplex-software-uart.html

-assembler-with-cpp option does not exist

After installing mentioned library, I got this error. And it was easy to fix. The solution is here:

https://github.com/arduino/Arduino/issues/1807

After that, all I had to connect ATtiny to ESP8266 via serial port. And ofc to put everything together with servos, engine, wings etc.

At the end, I think¬†it was possible to fly only with ESP8266 (some versions have more¬†outputs), but that’s for some other story.