topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 1:57 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Bluetooth Power Monitor  (Read 7358 times)

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Bluetooth Power Monitor
« on: February 16, 2016, 01:43 PM »
Hi everyone!

I'm proud to introduce my latest project, the bluetooth power monitor! It's still in the prototype stage, but what this device will do is monitor your power usage over bluetooth, the power supply can be turned on via bluetooth, you can be informed of how low your battery is via hepatic feedback, and it will start beeping if your power supply gets too low!

For now, all I have right now is non-specific power monitoring and can turn any battery powered device on and off via bluetooth! Here's a picture of what it looks like attached to a Game Gear:
gamegear.jpgBluetooth Power Monitor

I'm so proud of my first arduino project!
If I do it more than 2 times I want to automate it in C#!

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,761
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #1 on: February 16, 2016, 06:04 PM »
Seems a bit counterintuitive at first glance...can you explain how this helps anything with the fact that simply having Bluetooth turned on (on most devices) will make your battery drain way faster (even when not in use)  :huh:

Forgive me if I have missed something xD

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #2 on: February 16, 2016, 06:18 PM »
Seems a bit counterintuitive at first glance...can you explain how this helps anything with the fact that simply having Bluetooth turned on (on most devices) will make your battery drain way faster (even when not in use)  :huh:

Forgive me if I have missed something xD
No you didn't miss anything... except the small rechargeable battery pack that powers the bluetooth module. Whoops, that was my bad not to include it in the photo. But yes, there is almost no power drain from the actual power source you are testing because the device has it's own little battery pack.
If I do it more than 2 times I want to automate it in C#!

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #3 on: February 19, 2016, 07:36 PM »
It's all tiny tiny now!  :D
compact.jpgBluetooth Power Monitor
If I do it more than 2 times I want to automate it in C#!

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #4 on: February 23, 2016, 05:06 PM »
Even more tedious than coding, soldering, or researching has been creating a new part in a PCB creation program called "Fritzing"... I'm about halfway done with this board so I can begin customizing my own board to create a more finished looking prototype that will be ready for... housing creation... *sigh*  :'(

svg.breadboard.feather-pcb_3_breadboard.pngBluetooth Power Monitor
If I do it more than 2 times I want to automate it in C#!

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #5 on: February 27, 2016, 10:49 AM »
eagle_export.pngBluetooth Power Monitor
So I've discovered the power of EAGLE cad software and oh my goodness, this is amazing! I will have a fantastic looking prototype!
If I do it more than 2 times I want to automate it in C#!

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,964
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #6 on: February 27, 2016, 02:16 PM »
^ the drawing looks great :up:
Tom

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #7 on: February 27, 2016, 02:56 PM »
^ the drawing looks great :up:
Thanks, here's the first Rev. 00 I've submitted for printing! I'm very excited! :D
eagle_export.pngBluetooth Power Monitor
If I do it more than 2 times I want to automate it in C#!

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #8 on: March 02, 2016, 09:27 AM »
Perhaps I might receive better feedback here over the official support forums: I have made a little program to test the logic of the microcontroller of the device.

In many examples created by the manufacturer, to wait for a bluetooth connection in the setup() routine, the following code is used:
  /* Wait for connection */
  while (! ble.isConnected()) {
    delay(500);
  }
And it works correctly. However calling this from within the loop() method yields.... interesting results.


The logic of the Feather's microcontroller is tested in 4 ways:
If the bluetooth module is not connected, it should return false.
  if (!ble.isConnected())
  {
    printBoth(F("True"));
  }
  else
  {
    printBoth(F("False"));
  }
If the bluetooth module's connected status is false, it should return false.
  if (ble.isConnected() == false)
  {
    printBoth(F("True"));
  }
  else
  {
    printBoth(F("False"));
  }
If the bluetooth module is not connected or if the bluetooth module is not connected, it should return false.
  if (!ble.isConnected() || !ble.isConnected())
  {
    printBoth(F("True"));
  }
  else
  {
    printBoth(F("False"));
  }
If the bluetooth module is connected, it should return 1.
printBoth(String(ble.isConnected()));
Where "printBoth" is simply a function which outputs the string to both the Serial and bluetooth for display. If I run the program with an incremental timer, here are the results:
Test#, Delay in Seconds, Test 1 results, Test 2 results, Test 3 results, Test 4 results
  • 0, True, True, True, 0
  • 1, False, True, True, 0
  • 2, False, True, True, 0
  • 3, False, True, True, 0
  • 4, False, True, True, 0
  • 4, False, True, False, 0

So, I thought that was strange, but check this out....

  • 4, False, True, False, 0
  • 4, False, True, False, 0
  • 4, False, True, False, 0
  • 4, False, True, True, 0
  • 4, False, True, False, 0
  • 4, False, True, False, 0

So yeah, I don't know what's going on, but I don't know what to believe anymore...
If I do it more than 2 times I want to automate it in C#!

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,649
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #9 on: March 03, 2016, 06:51 AM »
Code: C# [Select]
  1. if (!ble.isConnected())
  2.   {
  3.     printBoth(F("True"));
  4.   }
  5.   else
  6.   {
  7.     printBoth(F("False"));
  8.   }



...Okay, am I completely off my nut...or does this really read as:

If it's true, that connection is false, print true?? ...I don't think the '!' is helping the output's clarity any.

I know nothing about the BT controller you're working with, but that code just strikes me as painfully confusing to work with.

Asudem

  • Member
  • Joined in 2015
  • **
  • Posts: 132
  • C# data manipulation junkie
    • View Profile
    • Donate to Member
Re: Bluetooth Power Monitor
« Reply #10 on: March 03, 2016, 08:21 AM »
I know nothing about the BT controller you're working with, but that code just strikes me as painfully confusing to work with.
You are 100% correct. I hate it. But as illustrated from my example, I can't just say
ble.isConnected() == false
because that just gives me the wrong answer, as every other logic test does here, including ble.isConnected() by itself.

It's by far one of the dumbest things I've ever coded, but it's kind of the point to demonstrate how silly the API is.
If I do it more than 2 times I want to automate it in C#!