Hi all. I have checked other threads but can’t seem to find a definitive answer.
I have an Arduino Mega, D1307RTC and an HMSoft bluetooth module.
I am trying to create a project but failing at the initial stages of building. I used to use it with an ethernet shield always connected to the internet but cannot use that now hence the bluetooth.
In a nut shell I want to create a sketch that turns a pump…
On and off at a specific time
Have it run for a specific time
Turn the whole timer part on and off
Be able to turn the pump on manually via a toggle button.
I want the above to work using Blynk and a mixture of time input, number input and buttons by connecting via bluetooth on my phone. However, I want to be able to disconnect from it once set and still have it run.
Of course I am having the dreaded issue whereby the sketch will not run when I’m not connected to it via the BT and gets stuck at the Blynk.begin(Serial, auth); and won’t progress until its connected.
It seems to go straight to the loop section if not connected to BT, but then when I connect it almost instantly connects and functions (albeit the function is only to turn the on board led on and off) but appears to work.
Hi Steve,
First of all, you wont be able to control the device from your Blynk app unless you are connected via Bluetooth. You also wont be able to monitor the status of the device or the pump unless its connected via Bluetooth, so the Blynk functionality will be ;limited to when you are within a few metres of the device.
Also, using your serial port for both the connection to your Bluetooth module and for debug messages is doomed to failure. The debug messages will be seen by the BT module and will be misunderstood and cause Blynk disconnections. A bit like trying to have a sensible conversation on an old Party Line (if you’re old enough to remember those )
I’m guessing that there is no WiFi available in this location, and that you don’t want to go down the GPRS route?
To be fair, I don’t need to be connected to it all the time. It’s basically a dosing pump system for a fish tank that will be set to come on and deliver and specific amount of millilitres of liquid into my tank every day. So I only need to connect now and again to adjust the time and maybe the dosage.
To be honest, for the amount of time that I will be adjusting it, I could just write it all in the sketch without Blynk and then just plug the laptop in to make changes, but I’ve got all this kit now and want to challenge myself.
I am by no means a coder. I learned everything myself and my old ethernet aquarium controller that I built (around 6000 lines of code) was self taught and took me 18 months to do lol. It wasn’t the cleanest code but it worked. Unfortunately my hardware failed so I’ve ripped it out and making this smaller project.
The serial outputs were just literally to find where it was halting. I normally delete them all after I know it works.
I do remember there was a ‘debug’ way where you could turn them on and off but just removing the // from a debug tag at the top but I can’t remember what it was now.
Just turned 60 actually, but I do remember my grandmother still had had a party line when I was a kid and it could get very confusing when she rang us. She was a bit batty by then anyway, but trying to have a conversation with her when her neighbour was chatting away to someone about the price of fish at the same time was more than she could cope with!
It did indeed. I was having to take the bluetooth module out of the Arduino every time I wanted to upload the sketch, now I don’t have to. Works great.
I have another ask…
Is there a way of syncing the buttons, time inputs and number inputs on my app when I connect to the Arduino via bluetooth?
When I open the app and it connects, I need it to refresh the values on the app from the hardware but can’t figure it out.
I mean I could put in a 'sync; button the app that will pull the data, but I’d rather it be automatic.
Now if I add this to the bottom… I get the serial print, but only the FIRST time I connect after resetting the Arduino. If I then close the app and reopen, it does not find it again.
I’m not sure what the limitations are with Bluetooth, but I know that some things that work perfectly when using WiFi/Ethernet are limited with BT, because of the nature of the connection (the device cant talk directly to the server, it needs the phone connected, so some server-based things synch as synchronisation and off-line alerts may not work the same way).
Is there no way of providing internet access in this location, preferably via WiFi?
I do have a network shield but space in the box is limited and I don’t really have a network port that close. It’s not much of a big deal if I have to add a sync button to pull the values from the Arduino and refresh the data on the app, just thought I’d ask in case there was an easy fix.
I thought that the app on my phone would at least pull the last known data on the Blynk servers though but it’s just opening up as blank widgets.
Have you thought about dumping the Mega and going for a NodeMCU connected via WiFi instead, or if you’re committed to the Mega then add an ESP-01 as a WiFi adapter, which would be smaller than the BT module.
Normally it’s device>>cloud server >>App but with BT it’s device>>App>>cloud server and the cloud server bit is (I think) optional depending on connectivity and the use of Direct Connect.