Question about "pull to high 5v" with Photon (usb power vs VIN power)

That is an easy to understand explanation. Thank you!

@Ric - Thank you.

So the key parts I got from this:

  • Hi-Z = disconnected
  • Floating is bad; in that state, you don't know what voltage is on the pin, and it might change randomly.
  • when the Photon is asleep, and the GPIO pin is in the Hi-Z mode, it is neither LOW, nor HIGH, it's floating.

And solution to this thread:

No. The solution is simple, and @ScruffR has already given it to you; cut the trace, connect the enable pin to one of the Photon's GPIO pins, and add a 10k pull-up resistor from enable to 5v.

Marking original reply from @ScruffR as the solution, and adding link to it + @Ric's
1.) Question about "pull to high 5v" with Photon (usb power vs VIN power) - #3 by ScruffR
and
2.) Question about "pull to high 5v" with Photon (usb power vs VIN power) - #43 by Ric

1 Like

@ScruffR @Ric - I cut the lead (note for anyone else stumbling on this: you can cut through the bottom trace - which is not going anywhere, to get to the top one that you have to cut), added the 10k pull up resistor, and it works.

I’ll post a picture + final code for anyone else reading this eventually.
I am also going to try and create a PCB in order to make it small/contained. Started poking at it in Fritzing, but I need to read up on this+learn a bit about it.

By the way - over the past couple of days I started reading up (+watching lots of videos) on tri-state switches, what floating actually is, and the concept of pull up/pull down. I think I understand it much better now.

Here is a list of some of the easier/better content that helped me with the electrical engineering concepts:




http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/CompOrg/tristate.html

2 Likes

Ok, here is the final setup:

and another angle:

And here’s the code:

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

int heater = D5;
int gasSensorData = A0;
int gas = 0;
int trigger = 600;

void setup() {
    pinMode(heater, OUTPUT);
    pinMode(gasSensorData, INPUT);
    //Serial.begin(9600);
}

void loop() {
    // Turn off power to control pin, which turns ON the heater
    digitalWrite(heater, LOW);
    
    // Wait for the heater to heat up - 8 seconds seems to stabalize readings
    delay(8000);
    
    // Reset alert and gas flags
    int alert = 0;
    int gas = 0;

	// Take a few samples
	for (int i=1; i <= 5; i++) {
		// Read gas value.
		gas = analogRead(gasSensorData);
        //Serial.printlnf("===> %d", gas);

        // Raise flag for alert
		if(gas > trigger) { alert = 1; }
  

        //Serial.printlnf("Gas Detected ===> %d", alert);
        // Wait a second before "re-measuring" in case anything changes
        delay(1000);
    }

    if(alert) {
        Particle.connect();
        waitUntil(Particle.connected);
        Particle.publish("Push", String(gas), 60, PRIVATE);

        // https://community.particle.io/t/flush-messages-before-going-to-sleep/8902/23?u=ventz
        // (firmware version 0.7.0 is stable - should have msg flush built in)
        delay(2000);
    }

    // https://community.particle.io/t/difference-between-input-input-pullup-input-pulldown/8543/2
    // (major thanks to community member: @ScruffR)
    pinMode(heater, INPUT);
    System.sleep(SLEEP_MODE_DEEP, 300);
}
1 Like

Sweet!

So how are you using the sensor?

How do you like its performance?

@RWB - This is where that part of the testing starts. So far, if you open a bottle of vodka and place it near the top of the bottle, it spikes the reading to 3500-4000. I need to test sensitivity when distance is applied. Also, the methane gas is where I have no easy way of just “testing” it :smiley: – which brings me to the end goal: strap this on the outside of a diaper and get alerted when it needs to be changed.

Hardware wise - I need to add a pin from the basic boost battery notify to the photon, and check it on startup to see if I should do a “last notify” (that the battery needs to be charged) + a long long sleep – assuming this is the best I can do for a “shutdown”. Also, again - I really want to create a custom PCB for portability, so at the end of the day, I can just velcro this thing and easily snap it on and off.

Sure you do :wink: Just eat some foods that make ya Fart :smile:

Seriously though, the VOC sensor I use can detect a fart in a 2 car sized garage easily :smile:

Is that really what you're wanting to accomplish? If so it can easily be done using the CCS811 chip which is smaller and probably lower power but does still require the heater to heat up for accurate measurements.

You want to velcro this onto what exactly? A diper?

I think the CCS811 would pick up more on the CO2 side and “other stuff” rather than mathane. (it does pick up alcohol though if someone wants to use it for that). Another good one for that would be this: BME680. It’s nice because both seem to work directly with 3v.

Velcro - yea, I haven’t thought this though yet. But my thought is make it “portable” and be able to attach/detach it quickly from the outside of a diaper.

I'm not sure since the sensor your using also picks up on Co2 also.

I do know I have a 3-week old baby boy here that is making about 60 diapers a day it seems :smile:

Never tried the BME680 but do have the BME280 which for me gave bad temp readings.

If you're specifically working with Baby/Kid diapers I wonder how much the sent they put on the diapers would affect the sensors readings? This is something I could test with the CCS811.

I have a 3-week old baby boy here that is making about 60 diapers a day it seems

This is something I could test with the CCS811.

@RWB - That would be really helpful actually. You seem to have both requirements :wink: :smiley:
Hope you are getting enough sleep!

So you think about this for babies and small kids, right? Not elderly adults? Or both maybe?

I was thinking at first babies (pre 6-7 months), but you are right - something like this would be key for elderly too.