How can I use PWM two power either one of the 4 sensors

Hello,

I asctually have a problem because my circuit is using to much power (10mA in sleep mode)
I suspect the my SeeSaw board Overview | Adafruit seesaw | Adafruit Learning System is the cause. My sensor must be powered only when a measure must be taken. otherwise, during 59mn, the board sleep.

I only have 1 pin free of 3.3V in my AMD21 microcontroller.

I wonder if I could use PWM to define a instruction.

For example, if I code

analogWrite(pin, 0) // All sensors are not power
analogWrite(pin, 1) // sensor 1 is powered
analogWrite(pin, 2) // sensor 2 is powered
analogWrite(pin, 3) // sensor 3 is powered
analogWrite(pin, 4) // sensor 4 is powered
analogWrite(pin, 5) // sensor 5 is powered
analogWrite(pin, 6)

I could use the gate of the transitor to power the sensor the the gate is closed.

But I have no idea, how I could read the out put pin value and how I could power ON or OFF, one sensor at time.

Would you have any siggestion to program my micrcontroller for this?
But from this point, I have no idea how I could
Read the value

pierrot10:
I wonder if I could use PWM to define a instruction.

I don't see how that could work unless you use another microprocessor to interpret the output from the analogWrite().

Would it work to switch all the sensors on or off at the same time - you could do that with one I/O pin. It may not be as economical as switching them individually, but it may be a big improvement on not switching them off ever.

...R

Dera Robin

Yes, but I have 3 tensiometric moisture sensor and my micro controllor does have enough power to power the 3 at the same time. The other are I2C which does not required a lot of power...

The idea is to use a transistor (or a CMOS)and when the gate is closed, one mositure sensor is powered, and etc.

The difficulty is, I have one pin to manage the sensors power.

As with PWM we can modulate the width of the pulse, my idea is use a width pulse to indicate which transistor must be powered, but how? :slight_smile:

pierrot10:
As with PWM we can modulate the width of the pulse, my idea is use a with pulse to indicate which transistor must be powered, but how? :slight_smile:

With another Arduino that can detect and time the pulses to measure the widths.

By the way I reckon it would be difficult to distinguish reliably between analogWrite(pin, 1) and analogWrite(pin, 2) etc. I think you would need bigger gaps such as analogWrite(pin, 50) analogWrite(pin. 100) etc

Maybe it is worth considering a wider distribution of tasks between two Arduinos?

...R

Maybe it is worth considering a wider distribution of tasks between two Arduinos?

Yes, that a good point of view. I though about that.

But I am not aware about is how to transfer the data (sensor value) between microcontroller with I2C or Rx and Tx. (may be Rx and Tx would be the best)

The second idea was:

The first µcontrollor wake up and wake up the second
The second powers the sensors altenatively and get the value
The second µcontroller send the values to the first and goes to sleep
The first µcontroller send the value with LoRA (and manage the LCD, the LEDs, the RTC module, and may be some I2C sensors

pierrot10:
But I am not aware about is how to transfer the data (sensor value) between microcontroller with I2C or Rx and Tx. (may be Rx and Tx would be the best)

Serial communication has the advantage of familiarity. It also has the benefit that you can easily test the communication with either board on its own using the Arduino Serial Monitor.

I2C or SPI are short range mechanisms - distances measured in centimetres. I have never used I2C but SPI is straightforward.

...R

I am thinking about one things. As my I2C sensors are powered by the 3V pin of my main µcontrollor, is possible to turn off the 3V pin by code?

The other solution which sound interresting, is to add a two MOSFET at the 3V pin


and with another pin connected to the gate to power the I2C sensor with an HIGH state on the pin.

I believe with that solution, when I re-power the sensors, I will have to re-initiate it...

Or with a transistor and having all the GND of my I2C sensors connected to the GND of the DS18B20!

Vce will not be zero volts being supplied to the sensor devices, consider the effect upon the sensors not having a zero volt reference.

Also, if the xsistor is cut off your sensors will feel max V.

It may be better to use a MOSFET and to cut power to the devices instead of circuit common. I'd, also, use a cap to the sensor supply to cause the voltage to the sensors to rise instead of suddenly appear when power is supplied.

Use the MOSFET or Xisxor more like, when supplying power, a regulator type of configuration; like: http://www.circuitstoday.com/wp-content/uploads/2009/10/Zener-Controlled-Transistor-Series-Voltage-Regulator.jpg. The xistor/mosfet can be cut off and the base of the xistor/mosfet can be adjusted with a resistor to make up for Vce drop.

As well, the sensors may need some time after power on to do their own power on reset routines and the sensors may loose their settings with power interrupted.

Just some random thoughts.

Yes, thank for your reply
And now I wonder why I always want to make this things complicate.

If I can use pin 13 to change the state of the base transistor, so as a trigger, why should I not use it to power my Ic2 sensors??????????

When pin 13 is LOW, the sensors will not cunsume and when is HIGH it will all cunsume may be ~10mA?

I have 4 I2C sensors and 1 OnwWire sensor and 1 wind speed sensor.

I want to have them LOW for 59mn and 1 mn HIGH during the measures