If you want to flash or configure your AM32/BLHeli ESC using just an Arduino, here's a quick sketch that turns your Uno or Nano into a 1-Wire passthrough interface.
If you want to flash or configure your AM32/BLHeli ESC using just an Arduino, here's a quick sketch that turns your Uno or Nano into a 1-Wire passthrough interface.
Wiring:
For Arduino Nano → connect the ESC signal wire to pin D3
For Arduino Uno → connect the ESC signal wire to pin D11
For Arduino Mega → connect the ESC signal wire to pin D51
Ground always connects to GND
How to use:
Open the code below in Arduino IDE.
Select your board (Uno or Nano) under Tools > Board.
Upload the sketch — the correct pin is selected automatically based on your board choice.
Wire your ESC signal wire to the pin mentioned above, and ground to ground.
Connect to BLHeliSuite or AM32 configurator and flash your ESC.
Code:
#include <avr/io.h>
//1-Wire Pin:
//Arduino Nano only -> PD3="D3
//MEGA boards -> PB2="D51=MOSI"
//all other -> PB3="D11=MOSI
#define OW_PINB3
#if defined OW_PINB3
#define OW_DDR DDRB
#define OW_PORT PORTB
#define OW_PIN PINB
#define OW PINB3
#elif defined OW_PIND3
#define OW_DDR DDRD
#define OW_PORT PORTD
#define OW_PIN PIND
#define OW PIND3
#elif defined OW_PINB2
#define OW_DDR DDRB
#define OW_PORT PORTB
#define OW_PIN PINB
#define OW PINB2
#endif
#if (defined (_AVR_ATmega2560) || defined (AVR_ATmega1280_))
#define IN_DDR DDRE
#define IN_PORT PORTE
#define IN_PIN PINE
#define IN_RX PINE0
#define IN_TX PINE1
#else
#define IN_DDR DDRD
#define IN_PORT PORTD
#define IN_PIN PIND
#define IN_RX PIND0
#define IN_TX PIND1
#endif
#define SetOWout (OW_DDR|= (1<< OW))
#define SetOWin (OW_DDR &= ~(1<< OW))
#define SetOWlow (OW_PORT &= ~(1<< OW))
#define SetOWhigh (OW_PORT |= (1<< OW))
#define IsOWhigh (OW_PIN & (1<< OW))
#define IsOWlow (!(OW_PIN & (1<< OW)))
#define SetTXlow (IN_PORT &= ~(1<< IN_TX))
#define SetTXhigh (IN_PORT |= (1<< IN_TX))
#define IsRXhigh (IN_PIN & (1<< IN_RX))
#define IsRXlow (!(IN_PIN & (1<< IN_RX)))
int main(void)
{
//Very important disable hardware UART
UCSR0B =0;
IN_DDR |= (1<<IN_TX );
IN_DDR &= ~(0<< IN_RX);
IN_PORT|= (1<<IN_TX )|(1<< IN_RX); //pullup RX ;TX high
//SetOWin;//Set OW as input / default
SetOWhigh; //pull up on
while(IsRXhigh); //wait for RX go Low = 1 Incoming data
while(1)
{
//RX low = 1 -> set oneWire to output
SetOWout;
SetOWlow; //Set oneWire low =1
SetTXlow; //Echo low to TX
//Wait RX go high = 0 again
while(IsRXlow);
// input // RX is high (or high again) = 0 end of bit or idle - so listen to data from TRX
SetOWhigh; //Set OneWire High = 0 for sharper edge //can be skipped?
//and Echo low to TX
SetOWin;
SetOWhigh; //Set OneWire pull up
while (IsRXhigh) //while RX high (no incoming bytes)
{
if (IsOWhigh) SetTXhigh; //Set TX High = 0
else SetTXlow; //Set TX Low = 1
}
}
}

