Introduction: Arduino Remote/wireless Programming and Power Bank Homemade

About: Software developer but I love electronics, wood, nature, and everything else as well.

The problem.

I develop a sketch near PC and I use usb and serial to "debug" in this case I create the lib for DHT12, I deliver a version on github of the library.

But arrive an issue: "when temperature go under 0 the readed value is wrong".

Now I must test the problem on my freezer (:P) and I don't want to rewrite a sketch and use WIFI for a simple situation like so.

So without rewrite sketch I want continue programming like previous, but my Arduino must go on my freezer.

I need 2 thing, one is a battery, but I don't know how many test I must do so I need a rechargeable battery, and an adapter to work with microcontroller remotely, like Bluetooth.

Refer to mi site for upgrade version https://www.mischianti.org/2019/01/31/arduino-remote-wireless-programming/

Step 1: Additional Component

For remote connection I'm goint to use:

  1. Bluetooth adapter like:
    1. HC-05 (only partially tested)
    2. SPP C (eBay) (If you search you can find it at 1.5$)

    3. 0.1uf Capacitor (for HC-05).

For power supply I'm going to use (you can use a simple 9v battery for arduino but It isn't rechargeable and I don't know how much test I need) a small rechargeable power pack:

  1. TP4056 Lithium Battery Charger Module (eBay)
  2. 0.9V-5V to 5V DC-DC USB Voltage Converter Step Up Booster Power Supply Module (eBay), It have only 600mha of output, If you want something more professional >1A you must go here (Digi-key)
  3. 18560 Battery holder (Digi-Key) (SparkFun)
  4. 18560 Battery (SparkFun) (Digi-Key) buy from here, I create a battery capacity checker and I see that the majority of 18650 battery on the net have fake capacity (the battery on test is 4500mha declared and 1100mha real)
  5. 2 position switch (eBay)

If you want all in one module you can look at this (Digi-key)

Step 2: Power Supply (simple Power Bank or UPS)

In my lab I have various device (buy to build something) but I think that a little emergency rechargeable usb power supply/battery pack is usefully, so with 2 simple component we are going to create one.

I buy TP4056 Lithium Battery Charger Module to create my solar power weather station.

And I have 5 step up usb module to recharge my phone with various battery, It's convert voltage from 0.9-5v to constant 5v.

In the connection schema you can see that we must add a switch before step up module because to get 5v It drain continuously current.

It can be used as power bank or UPS, the recharge module can recharge and give power supply at the same time.

The connection is simple, TP4056 battery output go to battery, TPR056 output go to step up usb module, on the positive wire must add a 2 position switch.

Step 3: Power Bank: at Work

A minimal video of standard usage of this power bank/UPS.

Step 4: Remote Connection

To create a remote connection without USB cable I want use bluetooth module as serial pass throw.

Than we must connect and program It with our Arduino. The connection schema is for programming bluetooth adapter.

In my lab I have 2 module an HC-05 and an SPP C.

But I use HC-05 to do wireless connection of my CNC router, but the low cost SPP C It's sufficient.

Normally I use 115200 baud rate for serial transmission, so I configure my bluetooth module to that rate.

Step 5: Configure Bluetooth Module: HC-05 Clone

For HC-05 I use that code to configure for my cnc.

Serial output baud rate is setting here:

#define SERIAL_SPEED 115200

Bluetooth comunication baud rate here:

#define BLUETOOTH_SPEED 38400

First time you must set to configure bluetooth to 9600 to HC-06 devices, 38400 to HC-05 devices.

Than set bluetooth baudrate to set:

#define SET_BLUETOOTH_SPEED 115200

You can set new device name:

#define BT_NAME "TEST-Reef"

But HC bluetooth module is quite clean and standard, but that code not work on SPPC.

Step 6: Configure Bluetooth Module: HC-05 (zs-040)

This module is different from the other, connection is the same.

First you must pay attention to if button is present (to go on configuration mode press that button instead of but high pin 9 of the sketch). When led blink slow (every 2 secs) you are in configuration mode, configuration mode put device at 38400 baudrate, so you must put serial and software serial to that boudrate. Than insert this command:

AT
AT+ORGL
AT+POLAR=1,0
AT+NAME=Test-Reef
AT+UART=115200,0,0
AT+INIT

Pay attention ATèORGL reset device.

AT+INIT can give Error(17) but don't worry It means that It's already in that mode.

Step 7: Configure Bluetooth Module: SPP C

The code for SPP C isn't so clean like HC-05, but the result remain the same.

Serial output baud rate is setting here:

#define SERIAL_SPEED 115200

Bluetooth comunication baud rate here:

#define BLUETOOTH_SPEED 38400

First time you must set to configure bluetooth to 9600 to HC-06 devices, 38400 to HC-05 devices.

Than set bluetooth baudrate to set:

#define SET_BLUETOOTH_SPEED 115200

You can set new device name:

#define BT_NAME "TEST-Reef"

Step 8: Connect Bluetooth Adapter to Arduino to Use As Serial Connection

For HC05 the only thing to note is that long leg (+) of capacitor going on reset, the negative going to DTR (or MCU-INT or State) of bluetooth adapter, you can use also a 0.1uf ceramic capacitor.

I didn't test HC-05 as programmer but only as substitute of USB cable for serial communication, so I'm going to show SPP-C module.

The SPP-C module in my case not work if I add capacitor, but work great without :D.

The rx of bluetooth adapter go wired on tx of microcontrollor, and tx to rx, than you must connect VCC and GND and DTR or MCU-INT or State of bluetooth adapter to reset of microcontroller.

For a better stability It's good thing to do a voltage divider versus RX bluetooth pin like in the image because transfer voltage is 3.3v not 5v.

Step 9: Simple Sketch and Upload Via USB

I create very simple sketch to upload, It's only write progressive number on serial every 1500 milliseconds.

In the video is show standard usage via USB cable.

Step 10: The Same Simple Sketch Upload Via Bluetooth

In this video the previously sketch upload remotely via Bluetooth without change code.

Step 11: Real Test

Now I need response from the freezer.

From the deep of freezer, near the sausages, the remote test tell me that (damn) there is a bug on my DHT12 library when go under 0.

Step 12: Thanks

Bug on DHT12 lib now fixed.

Arduino Contest 2017

Participated in the
Arduino Contest 2017

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017