Category Archives: #Coding

DropBOB Upgrades to “Real-Boy” Status!


So as I hinted from my last post. I have decided to delve right into the world of professional software development. I have started using “Eclipse” as my development platform for my IoT chip – ESP32 by Sparkfun.

To be fair, I didn’t really have a choice. Not all of the features that I need this chip to do have been ported over into the “Arduino” platform yet. I’m sure it eventually will (possibly more than a year, as seen on the prior chip). So, I’m pulling up my big boy pants and learning all the things!

I will be keeping my software open-source. But it will be via the official ESP-IDF. Once I program for this (in C language) I won’t be porting it back into Arduino (Sorry arduino fans).

Continue reading DropBOB Upgrades to “Real-Boy” Status!

Wake Computer From Sleep WIFI Button


I’ve always setup my computer to be woken up from sleep via an app on my phone (Wol Wake on Lan Wan by Brobble, for anyone interested). But yesterday, I thought, I should just make a button that sits on my couch side table … that’s really where this button should be.
I use my computer as a media manager (using Plex, another app, to manage and stream to my smart TV). As I was thinking out loud that I wanted such an “Easy” button … I realized that I already had all the parts needed to make this happen.

Drop-BOB – a better coffee maker – Cold Drip


I’ve been working on my software today. I think I have a good base that I will call this version V0.1 … an alpha release, since I know there are a few crashes and more bugs than I would allow in my beta software.
But overall, I’m happy with the result. I have my Arduino code working well with the Blynk platform. From top to bottom & left to right I can: 

  – monitor network connection
  – visually see the servo position
  – monitor up-time
  – see the real time DPM (drops per minute)
  – automatically tweet about making Coffee
  – see the desired drip rate (Set-point)
  – count drops
  – see a history of DPM
  – modify desired drip rate (set-point)
  – Manually adjust the servo position
  – restart when finished
  – simulate a drop
  – and pause the system
All while using a smaller package than when I was using an arduino with an LCD … remember that?
The next step right now is to CAD this “THING” (that’s the real name) … And then place it nicely into my drop-BOB (3d printed design to hold all these components) … It counts drops … and it just bob’s under the water holding thing … kinda sounds cute.

Oh, and also, since my idea is to eventually release this into the world with huge potential for modifications and improvements, I’ve shared my code on my GitHUB. Feel free to make improvements. make comments, or even suggestions that I can implement (note, I’m not a software guy … I juts do this for fun. So go easy on my code).

Hack-on!

Cold Drip Coffee – THICK AND RICH!


So here’s a progress update on the development of my cold drip coffee machine. After my last post, I had determined that the only way to get this coffee just right, was to control the drip rate. 

The idea was to use either a photo-interupter or a pietzo electric disk to detect the drop. Since I need the servo to be used for feedback control (think back to your “Control systems” classes). If I did not have any feedback control, even after perfectly setting up the drop, the drip rate (DPM) would become less and less as the volume of water above the valve becomes smaller (simple fluids 1 class, of which I had to take 2x because of a terrible teacher & an overachiever’s workload).
So, as Lee’s Electronics nor Main electronics had any readily available photo-interrupters, I settled on the pietzo sensor … It turned out to work, but it happened to skip every third drop or so … “Not good enough!”
So, I turned to my next favorite electronics distributor Digikey. I used them for work to purchase the odd chip here and there and just love how cheap and fast they are. I ordered the GP1A57HRJ00F photo-interrupter and received it the next day as I got home from work. 
So off to the grinds I go (literally). I held off on cleaning my room as you can tell, I was just so excited to make this new sensor work. And work it did. Really well too. This thing has a 1-microsecond response time … that is really really fast.

So after throwing together a cheapo setup using my trusty wood clamps and some junk around my shop, I managed to get a reliable, easy setup.

As of this writing, I’m at 8483 drops and 16-hrs … bottle is only about half way filled (see first picture). My controller is set to 8-DPM and averages around 8 to 9 due to the play in the servo. But it really does work.

 Just look at this thick, sludge of a coffee. I haven’t tried it yet, but I have a feeling I’ll need to dilute it … Its just so THICK!

Arduino GSM Expandable Vehicle Connection Project


Working on some code today. I discovered the many awesome uses of switch(x){Case(0):} loops in the Arduino code. Here’s how they work:

if (buttons & BUTTON_UP) {                       // If a button is pressed and it is the Up button
          menu = menu – 1;                                 // Adjust the menu item to be the one before
          if (menu<0) menu=3;                            // If you went too far up, cycle through to the bottom
          switch(menu){                                      // Start the switch loop using the “menu” variable
            case 0:                                               // In case the menu = 0
              lcd.setCursor(0,1);                           // Place the LCD cursor at the bottom left
              lcd.print(“1-ChangeSensTrip”);         // Print “1-ChangeSensTrip” on the LCD
              break;                                              // Need this break, otherwise it will continue
            case 1:
              lcd.setCursor(0,1);
              lcd.print(“2)ShowSensorVals”);
              break;
          }
}

Here’s my code on Github if you would like to use it: https://github.com/Phoenix260/Capacitive_Sensor And don’t forget the licence agreement. Personal use only!

I’ll clean it up when I have time.

Enjoy.

Arduino GSM Expandable Vehicle Connection Project


Had some time today to put a few touch-ups on my project. I added a DB9 connection (currently using only 4 pins … I may expand it in the future).
I’ve also modified some code so that it only turns the LCD on when the driver is seated. The sensor is still functioning but it draws less battery this way. I don’t think the baby would want to know weather he is seated, the car temp, and the time until he may be in danger anyway. That’s more for the dad to know.
I managed to use my car inverter to run a soldering iron and a hot glue gun … I did notice a drop in voltage though over the 5 min of use. I don’t recommend doing this for too long without your engine running.
Now I just need to work on the menu options.
I’ve even done a quick calculation that the arduino would last a few months, basically sipping battery, while sensing. So not too worried about battery usage at this point.

Arduino GSM Expandable Vehicle Connection Project


Didn’t think I’d blog today but due to work circumstances I was nearer to home at the end of the day. Figured I might as well put a few hours in before school.

I managed to pick up an LCD kit from Lee’s. Solder it together, test it and incorporate it into my Arduino just in time for school.

And since I don’t really learn anything in school, I decided to bring Jenn’s laptop and do a little coding at school.

I got all the data now showing up on my LCD and I started working on the menu and UI.

Arduino GSM Expandable Vehicle Connection Project


Working late last night, I managed to figure out got to take apart my seat covers and insert my capacitance sensor.

Oh ya also, note to future self, don’t use 10 awg ground wire … I had to change all the wire routing in my car because it was to hard to work with.

I’ve also placed my Arduino in a protective case. Attached behind my rear view mirror with Velcro.

I’ve t-tapped into my constant-on 12v line from my ceiling light. This way I can have my vehicle constantly monitoring. I’ll be purchasing a lithium battery booster today until I can assess the power used by my system … I also haven’t setup any safeguards against battery drain in my code yet … I’ll have to look into that.

Today, I have school. So tomorrow I’ll have to go to Lee’s again to get a new LCD display. I would have had this done by now but my first one burnt out during the original accidental short (read: blowup). Also, when I bought my second one I didn’t read that it was for the raspberry pi.

Arduino GSM Expandable Vehicle Connection Project


/* This sketch is created for use of a GSM board with an arduino. The sensors utilized are 1x DHT11 + 2x BOCHEN 3386 Potentiometer + 5k resistor +
5V solar Array + 2 aluminum foils connected to 10k OHM resistors.
Copyright: Bobby Lumia, may be used and modified for personal use only. No resale.
Please reference my project blog: http://bobbobblogs.blogspot.ca/ if useing this sketch in your work.
*/

#include // Library Needed for our capacitance readings
#include // Library Needed for the tempeature readings

dht11 DHT11; // Declare our sensor, I bid thee dht11 … the first

//============================= \/ DEFINE PINS \/ ==============

//Do Not use Pins A4 & A5 … reserved for LCD
//Do not use Pins 0 & 1 (digital pins) these are used for GSM data transmission

int LED_1 = 4;                 // BABY Led
int LED_2 = 9;                 // DAD Led

int sol = A0;         // analogue pin 0
#define DHT11PIN A1   // analogue pin 1
int pot1 = A2;        // analogue pin 2
int pot2 = A3;        // analogue pin 3

CapacitiveSensor   cs_DAD = CapacitiveSensor(11,12);    // 10M resistor between pins 11 & 12, pin 12 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_BABY = CapacitiveSensor(6,7);    // 10M resistor between pins 6 & 7, pin 7 is sensor pin, add a wire and or foil if desired

//============================= \/ DEFINE VARIABLES \/ ==============

int const SAMPLES = 5;                         // number of samples taken to average out capacitance
int s_val[SAMPLES];                            //array to store the 5 samples to average
int const Initial_SAMPLES = 20;                // number of samples to initilize capacitance with
float RAW_initializer_VALS[Initial_SAMPLES];   // Array to hold initial Capacitance Values

int HIGH_Thresh;     // Threshold to trigger Capacitace 1 HIGH
int LOW_Thresh;      // Threshold to trigger Capacitace 1 LOW
int HIGH_Thresh_2;   // Threshold to trigger Capacitace 2 HIGH
int LOW_Thresh_2;    // Threshold to trigger Capacitace 2 LOW

int i;              // loop counter
int triggered = 0;  // Baby text trigger … don’t want to send out too many texts

long start;         // Start the timer for performance monitoring
float Where_DAD;      // Start the Where’s DAD counter
float Cap_1;        // Capacitance Sensor – 1
float Cap_2;        // Capacitance Sensor – 2
float SolVolt;      // Solar Voltage value (0-5 Volt)
float Amb_Temp;     // Ambient temperature Variable
int chk;            // Checks the Temperature sensor status and possible faults
int pot1Value;      // Potentiometer 1 value — Used to calibrate Capacitor 1 Trigger sensitivity
int pot2Value;      // Potentiometer 1 value — Used to calibrate Capacitor 2 Trigger sensitivity
int T_multi = 4;    // Scaling factor for threshold (1 = 1024, 2 = 2048 MAX)

char str1[]={‘A’,’T’,’+’,’C’,’S’,’C’,’S’,’=’,'”‘,’G’,’S’,’M’,'”‘};  // AT+CSCS=”GSM”  — This sets:  GSM default alphabet
char str2[]={‘A’,’T’,’+’,’C’,’M’,’G’,’S’,’=’,'”‘,’1′,’7′,’7′,’8′,’8′,’8′,’2′,’1′,’8′,’6′,’7’,'”‘};  // AT+CMGS=”17788821867″  — This sets Phone number to Text
char hex1[]={0x1A};  // Stop Character used to signify the end of a Text Msg

void setup()                  
{
   Serial.begin(115200);
 
   pinMode(LED_1, OUTPUT);           // set pin to output
   pinMode(LED_2, OUTPUT);           // set pin to output
   pinMode(LED_1+1, OUTPUT);           // set pin to output
   pinMode(LED_2+1, OUTPUT);           // set pin to output
 
   Serial.println();
   Serial.println(“Starting GSM Communication…”); //Just an FYI … not really chacking anything
   Serial.println();
}

void loop()                  
{

    ReadSensors();               // All sensor readings grouped in a function
    Print_Sensor_Vals_Serial();  // Now print these values on the screen for all to see!
 
    if (Cap_2 > HIGH_Thresh_2) LED_1_ON();
    else LED_1_OFF();
 
    if (Cap_1 > HIGH_Thresh) LED_2_ON();
    else LED_2_OFF();
 
    delay(200); // no use reading less than half a second … it just confuses the sensors (mostly temp)
 
    if (Cap_2 > HIGH_Thresh_2){ // If Baby is in seat
      if (Cap_1 < LOW_Thresh) { // If daddy in not there
         if (triggered == 0){
           Where_DAD = millis(); // DAD, your timer has begin
           triggered = 1; // Level 1 trigger
           Serial.println();Serial.println();Serial.println(“Countdown Begins! Where are you dad?”);Serial.println();
         }
       
         if ((millis() – Where_DAD > (5.0 * 1000.0)) && triggered == 1){ // If daddy is still not there after 120 seconds
           Serial.println();
           SendTXT();  // Send dad a text to tell him that something is wrong
           triggered = 2; // Level 2 trigger
           Serial.println();Serial.println();Serial.println(“Baby on Board! Where are you dad? THIS IS AN ALARM”);Serial.println();
         }
      }
   
      if (triggered == 1){
         Serial.print((millis() – Where_DAD)/1000.0,1);Serial.print(” Seconds .. “);Serial.println();
         LED_1_OFF();
       }
     
       if ((millis() – Where_DAD > (5.0 * 1000.0)) && triggered == 1){ // If daddy is still not there after 120 seconds
         Serial.println();
         SendTXT();  // Send dad a text to tell him that something is wrong
         triggered = 2; // Level 2 trigger
         Serial.println();Serial.println();Serial.println(“Baby on Board! Where are you dad? THIS IS AN ALARM”);Serial.println();
       }
     
    }
 
    if ((Cap_2 HIGH_Thresh&& (triggered == 2 || triggered == 1))){ // Stop panic if, Baby is removed, or Dad has arrived … after an even was triggered
      triggered = 0;
      Serial.println();Serial.println();Serial.println(“Baby SAFE!”);Serial.println();
    }
}

void ReadSensors()
{
    start = millis();  
 
    Cap_1 = avg(); // DAD Read capacitor time constant 1
    Cap_2 = avg2(); // BABY Read capacitor time constant 2
 
    SolVolt = analogRead(sol) * (5.0 / 1023.0); // Read output voltage created by the SUN!
 
    pot1Value = analogRead(pot1);
    pot2Value = analogRead(pot2);
 
    chk = DHT11.read(DHT11PIN);
    Amb_Temp = DHT11.temperature;
 
    HIGH_Thresh = T_multi*pot1Value;
    LOW_Thresh = T_multi*pot1Value-100;
    HIGH_Thresh_2 = T_multi*pot2Value;
    LOW_Thresh_2 = T_multi*pot2Value-100;    
}

void Print_Sensor_Vals_Serial()
{
  if (triggered != 1){
    Serial.print(“performance:   “);
    Serial.print(millis() – start);        // check on performance in milliseconds
    Serial.print(“\t”);Serial.print(“\t”); // tab character for debug windown spacing

    Serial.print(“C1: “);
    Serial.print(Cap_1);Serial.print(“/”); // print sensor output 1 / Threshold
    Serial.print(HIGH_Thresh);
    if (Cap_1 > HIGH_Thresh) Serial.print(“*PROXI*”);
    else Serial.print(”       “);
    Serial.print(“\t”);                    // tab character for debug windown spacing
 
    Serial.print(“C2: “);
    Serial.print(Cap_2);Serial.print(“/”); // print sensor output  / Threshold
    Serial.print(HIGH_Thresh_2);
    if (Cap_2 > HIGH_Thresh_2) Serial.print(“*PROXI*”);
    else Serial.print(”       “);
    Serial.print(“\t”);                    // tab character for debug windown spacing
 
    switch (chk){
      case 0: Serial.print(“Temperature: “); Serial.print(Amb_Temp); Serial.print(” oC”); if (Amb_Temp > 38.0) Serial.println(“*TEMP*”); break;
      case -1: Serial.print(“Checksum ERR: data was received but may not be correct”); break;
      case -2: Serial.print(“Timeout ERR: communication has failed”); break;
      default: Serial.print(“Unknown ERR: this is the catch-all bucket … S.O.L. buddy”); break;
    }

    Serial.print(“\t”);                    // tab character for debug windown spacing
    Serial.print(“Solar Voltage: “);
    Serial.print(SolVolt, 2);
    if (SolVolt > 4.0) Serial.print(“*SUN*”);
    Serial.println();
  }
}

float avg()
{
  float sampleSum = 0;
  for(int i = 0; i < SAMPLES; i++) {
    s_val[i] = cs_DAD.capacitiveSensor(15);
    sampleSum += s_val[i];
    delay(1); // set this to whatever you want
  }
  float meanSample = sampleSum/float(SAMPLES);
  return meanSample;
}

float avg2()
{
  float sampleSum = 0;
  for(int i = 0; i < SAMPLES; i++) {
    s_val[i] = cs_BABY.capacitiveSensor(15);
    sampleSum += s_val[i];
    delay(1); // set this to whatever you want
  }
  float meanSample = sampleSum/float(SAMPLES);
  return meanSample;
}

void SendTXT()
{
      for(i=0;i<13;i++)
        Serial.print(str1[i]);//AT+CSCS=”GSM”  ==> It must be done this way due to double quotes
      Serial.println();
   
      for(i=0;i<21;i++)
        Serial.print(str2[i]);//AT+CMGS=”17788821867″  ==> It must be done this way due to double quotes
      Serial.println();
   
      Serial.print(“Baby may be in danger!”);
      delay(1000);
      Serial.print(hex1);
      delay(1000);
      Serial.println();
}

void LED_1_ON(){
  digitalWrite(LED_1, HIGH);       // turn on
  digitalWrite(LED_1+1, LOW);       //
}

void LED_1_OFF(){
  digitalWrite(LED_1, LOW);       // turn off
  digitalWrite(LED_1+1, LOW);       //
}

void LED_2_ON(){
  digitalWrite(LED_2, HIGH);       // turn on
  digitalWrite(LED_2+1, LOW);       //
}

void LED_2_OFF(){
  digitalWrite(LED_2, LOW);       // turn off
  digitalWrite(LED_2+1, LOW);       //
}