Some good advice already given here, and I don't have any kind of system worked out.
I tend to estimate my programming charges at shop rate....which might be $60/ hr, or whatever seems reasonable in your particular area. If you enjoy it, you will be making good money, hanging around while the program is proved out. You are actually accomplishing
most of the work on the job, past the 'button pusher', so maybe you should get
their shop rate
That might be 'greedy', because most shops would have a programmer on staff, to save money, and I suppose he would get what...... $40/hr or so? I dunno what pure programmers get paid.
If you get swamped, put your price up so that you can thin the demands on your time down, or even make it feasible to hire someone to work for you.