Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Programming baby orangutan from Arduino IDE by serial port

Hi

I want to share how to program baby oranguntan 328P from Arduino IDE using the serial port.

1-Load this modified arduino bootloader macetech.com/Arduino_20MHz.zip (ATmegaBOOT_168_atmega328_20MHz.hex) into your baby orangutan using an avr programmer

-fuses high: 0xDA -fuses low: 0xFF -fuses extended: 0xFD -lockbit: 0xFF

2-Download and install the libpololu-arduino pololu.com/docs/0J17/3

3-Add this at the end of libpololu-arduino\avr\platform.txt:

tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf tools.avrdude.upload.params.verbose=-v tools.avrdude.upload.params.quiet=-q -q tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

4-Add this at the end of libpololu-arduino\avr\boards.txt

orangutan_328_s.name=Pololu Orangutan or 3pi robot w/ ATmega328P (serial) orangutan_328_s.upload.tool=avrdude orangutan_328_s.upload.protocol=arduino orangutan_328_s.upload.maximum_size=30720 orangutan_328_s.upload.speed=57600 orangutan_328_s.build.mcu=atmega328p orangutan_328_s.build.f_cpu=20000000L orangutan_328_s.build.board=AVR_ORANGUTAN orangutan_328_s.build.core=arduino:arduino orangutan_328_s.build.variant=arduino:standard

Now you can upload your code using serial port (you can use usb2uart, bluetooth hc05/hc06, wifi esp8266, etc). You have to choose the “Pololu Orangutan or 3pi robot w/ ATmega328P (serial)” board and the serial port of your usb2uart device. After pressing upload sketch, you have to reset quickly the baby orangutan. I have recorded a video that shows it:

Watch it at full resolution and full desktop to see details. First I show you the baby orangutan connected by serial to a usb2uart module. Then I change the skecth pololu.com/docs/0J17/4 to modify the led blinking speed. I push the upload button and then I join RST pin to ground with a wire during a second.

1 Like

Hello.

Thanks for sharing. I am sure some people might find it useful to have an alternative way of programming their Orangutan controller.

- Jeremy

The best is you can program your robot based on baby oranguntan without wires, so you dont have to go where it is, take it, plug the programmer and then put it again on the floor.

I have recorded a video where I reprogram remotely the behaviour of 4 leds. The orangutan’s serial port is attached to a hc-06 bluetooth module and the reset pin is connected to PD7. So when baby orangutan receives the bytes 0x30 0x20 from the serial port (stk500 protocol sync sequence), the program configures the PD7 pin as output and then sets it to low, making a reset and starting the arduino bootloader, who finally reprogram the baby orangutan with the new skecth.

This is the arduino sketch:

[code]void setup() {
Serial.begin(57600);
for(int indice = 8; indice <= 13; indice++)
pinMode(indice, OUTPUT);

}

void loop() {

if(Serial.available() > 0)
{
if(Serial.read() == 0x30)
if(Serial.read() == 0x20)
{
pinMode(7, OUTPUT);
digitalWrite(7, LOW);
}
}

delay(200);
for(int indice = 8; indice <= 13; indice++)
digitalWrite(indice, HIGH);
delay(200);
for(int indice = 8; indice <= 13; indice++)
digitalWrite(indice, LOW);

// for(int indice = 8; indice <= 13; indice++)
// {
// digitalWrite(indice - 1, LOW);
// digitalWrite(indice, HIGH);
// delay(50);
// }

}[/code]

Very good job Osropa! Very impressive but I cannot repeat what you did. Dispite 4d efforts…

I tried with both HC05 & HC06, none allows me to upload my sketch to my Pololu Baby Orangutan.

I’m able to program via USB/TTL serial & manual Hard reset thanks to ATmegaBOOT_168_atmega328_20MHz.hex.

I’m able to use Serial Monitor with both HC05 & HC06 Bluetooth .

But I cannot upload my sketch via BT !?! Always this “avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x2a”.

What BT module module did you use please? Are sure this is HC05 or HC06? I read that HC05 & HC06 cannot manage the HW reset (stk500 protocol sync sequence).

Thanks for supporting :slight_smile:

Hi

Yes, it is a HC-06 (and HC-05 works too).

Is your sketch making a hard reset? When I receive by serial port the bytes 0x30 and 0x20, I send a low signal to pin 7 (PD7), as it is connected directly to reset pin, the baby orangutan reboots and the bootloader starts, waiting for the next sequence of 0x30 and 0x20 bytes to begin the programming.

Regards.

     Hi

Very strange. I tried with 2 different baby and 2 BT, hc05 & hc06. Of course, pd7 is directly connected to reset. I also tried to program pd6 to hard reset… Always the same result: BT Serial Monitor but no BT sketch upload.

From your video, I can see that your Hc05 is not as used to be. It is bigger with external led, capa… Any reference please?

Could that be something like those: https://sites.google.com/site/wayneholder/inexpensively-program-your-arduino-via-bluetooth

Thanks.

I forgot to precise that I’m working under MacBook Pro with latest IDE.
Could that issue be related to driver version?

Anybody else who has ever succeeded to reproduce the great work done by Osropa?

Thanks for your feedback.

Hi

The bluetooth board is a custom pcb, the heart is a HC-06 (similar to the one you linked):

Another question, the bootloader communicates at 57600 baud, is your bluetooth module running at that speed?

Yes I did set 57600bds into HC05/06 with AT command and it is working fine with Serial Monitor 57600bds over Bluetooth with Serial.println(“Test1”) every 500ms.

Thanks to your JPEG, I can see only Tx, Rx, 5V, Gnd coming out of your HC05, exactly like me. However, Baby connections are not very clear.

From video, it sounds that you do not use PD0 & PD1 as I would expect but PD1 & PD7 for HC05 com. Right?

Does your HC05 powered by the same 5V supply than your baby?

Can’t you post an electrical schematic please?

Thanks again. I will post the results here.

Cheers

Hi

Wops, you modified the message and I couldn’t read it because I didn’t receive any notification.

It uses PD0 and PD1, you can see at the video (red circle is the PD0/RX pin):

This is the schema:

If you can’t achieve it, I’ll try to record another video this weekend, customized to this message, and I will try it with a mac mini.

Another question, did you set the fuses to the values I posted in the first message?

Regards.

Finally I have recorded the demo again in mac environment with same results:

I have used a hc-05 commercial bluetooth and there is no difference.

Beside the fuses question, did you program the sketch the first time using a usb2serial in baby orangutan? That is necessary because the sketch code looks for the 0x30 and 0x20 bytes and makes a reset if they are found. At the beginning there isn’t any sketch with the code to do the reset when the bytes are received.

Hope it helps you to achieve the remote baby orangutan programming.

Regards.

Thanks a lot Ospora.

Your schematic helps a lot but it still does not work but I’m not far to succeed.

  1. “Pololu Orangutan or 3pi robot w/ ATmega328P (serial)” selected
  2. Schematic just confirms what I’ve been doing: PD0 & PD1. No cabling mistake.
  3. Boot ATmegaBOOT_168_atmega328_20MHz.hex is well loaded into Flash with AVRfuses.
  4. Fuse are good but AVRfuses does not allow to set nor to show “lockout”.
  5. Copy paste of your sketch and IDE programming “Upload using programmer” (USBtinyISP).
  6. PD7 for hard reset.
  7. LED’s PB0…4 are flashing as expected
  8. Serial Monitor running fine at 57600bds via Bluetooth.
  9. RESET to GND does reboot the Baby, as expected

BT programming:

     System wide configuration file is "/Users/Love16/Desktop/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
     User configuration file is "/Users/Love16/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/cu.KissOiler-DevB
     Using Programmer              : arduino
     Overriding Baud Rate          : 57600

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x2a
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x2a
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x2a

While trying to upload via HC05, I can see the HC05 well pairing. But PD7 does not generate the required HW reset for upload. Strange…

Best regards.

Kissino

Try one thing, verify if bootloader and arduino sketch are both in flash memory (example pictures from atmel studio 7):

If it fails, try first to program the arduino skecth and then the bootloader, but uncheck the “Erase device before programming” before program the bootloader.

If you think than PD7 is not working, try to connect a button between reset pin and GND and when the arduino wants to program it, press the button like in this video: