back to index

Cellphone PhoneOn

Cellphone power on

For the purpose of an SMS gateway, a cellphone has to be connected to the computer. For continuous function, it is also important to keep the phone switched on. Sometimes, especially in case of a blackout or a weaker battery, the phone decides to spontaneously power off. In that case, a manual operator intervention is required to come to the device and press its power-on button. When there is not any operator around, it can become a problem.


System board

Connection to phone

The device uses the ATmega8 microcontroller. Internal ADC with 2.56V reference is used for sensing analog values. The chip is configured to use internal 4 MHz oscillator; the fuse low byte is 0xE3, high byte is 0xD9, extended byte is 0xFF.

The chip senses the voltage on the BSI battery contact, by ADC0/C0 pin; when the phone is off, there is no voltage there and when the phone is on, there's about 0.5V there. This behavior may be specific to the phone (Nokia 3310). The decision threshold is hardcoded in the software (0x080) and it is indicated by the yellow COMPARATOR LED driven from the microcontroller D5 pin.

For switching on, the on/off switch was localized; one its end was connected to GND, the other one somewhere to the depth of the system board. It was determined that a bipolar transistor (BC337) in parallel to the switch can be used to simulate a keypress. The transistor is controlled from the D6 pin of the microcontroller, over 1k resistor to base. The same signal is also used to drive a red LED that indicates the activity of power-on signal.

For informative purposes, the power is sensed as well, by ADC1/C1 pin; as it is outside of the 0..2.56V range, a divider made of two 100k resistors is used.

For powering the phone, a battery replacement circuit is described here.


The software is written in C. avr-libc is used. Small pieces of Procyon AVRlib are used as well. The code is rough, sources were adapted from another project. Commented out pieces of junk code may still lurk there.

The software checks the SENSE input. When the input is below-threshold for a set period, the RESET signal is asserted and held for a set period, or until the sense signal gets above threshold (and then another short time). If the phone switch on is unsuccessful, some time is added to each of the intervals, then the device tries again. This period incrementation happens for first several retries, then further retries do not use additional intervals anymore. If the phone is switched on for a specified (long) time, the retry intervals are reset to initial values.

When the SENSE signal is below threshold, the yellow SENSE LED is lit. This LED is also shortly blinked periodically to indicate the device is alive.

The device sends status updates to the UART (9600 bps by default). Own initialization, changes in phone status, and retries are sent as asynchronous events. Voltage on SENSE and PHONE-POWER inputs is monitored and minimum-average-maximum values are reported for each. An identification prefix (PhG0) is prefixed to each output line:

PhG0|Vcc 3.44 3.57 4.20|Sens 0.50 0.55 0.56
PhG0|Vcc 3.44 3.56 3.59|Sens 0.54 0.55 0.58
PhG0|Vcc 3.44 3.56 4.19|Sens 0.54 0.55 0.58

The software source code is here:

phoneon.hex (compiled hexfile)


Circuitboard top

Circuitboard top

Circuitboard bottom

System assembly

System assembly

If you have any comments or questions about the topic, please let me know here:
Your name:
Your email:
Leave this empty!
Only spambots enter stuff here.