The problem.
Refer to my site for updated version https://www.mischianti.org/2019/01/31/arduino-remote-wireless-programming/
I developed 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 goes 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 rewriting the sketch, I want to continue programming like previously, but my Arduino must go on my freezer.
I need two things. 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.
Additional ComponentFor remote connection I'm goint to use:
Bluetooth adapter like:
- HC-05 (only partially tested)
- SPP C (eBay) (If you search you can find it at 1.5$)
- 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:
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)
- TP4056 Lithium Battery Charger Module (eBay)
- 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)
- 18560 Battery holder (Digi-Key) (SparkFun)
- 2 position switch (eBay)
If you want all in one module you can look at this (Digi-key)
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.
Power Bank: at WorkA minimal video of standard usage of this power bank/UPS.
Remote ConnectionTo 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.
Configure Bluetooth Module: HC-05 Clone(refer to SetBluetoothModuleHC05.ino attach)
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.
Configure Bluetooth Module: HC-05 (zs-040)(refer to BluetoothATSender.ino attach)
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.
Configure Bluetooth Module: SPP C(refer to SetBluetoothModuleSPPC.ino attach)
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"
Connect Bluetooth Adapter to Arduino to Use As Serial ConnectionFor 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.
Simple Sketch and Upload Via USBI 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.
Same Simple Sketch Upload via BluetoothIn this video the previously sketch upload remotely via Bluetooth without change code.
Real TestNow 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.
ThanksBug on DHT12 lib now fixed.
Comments