GrovePi and LED Power Supply

Hello,

I have a GrovePi which I would like to use to control a LED light fixture, as well as report some environmental data.

Specifically, I’d like to control power on/off and dimming of the light, and sense temperature, humidity and electrical consumption.

I have already installed a Grove relay into the fixture, and can power on/off the light with no issue. Adding the environmental sensors has been straightforward as well.

For the next part of my project, I’d like to be able to dim the fixture, and report on the electricity consumption.

The LED drivers I am using are detailed here: http://www.meanwell.com/webapp/product/search.aspx?prod=hlg-185h-c

For dimming the fixture, the power supply above supports a dimming function using either 1~10VDC, PWM signal, or resistance.

I have looked at the Grove options for this, and I see the MOSFET as a potential solution, however my knowledge in electronics isn’t very strong, and it would be great if I could get some suggestions on the best way to implement dimming with my GrovePi.

As far as electricity usage monitoring, I have also noticed the current sensor options for Grove are limited. Are there any other options for being able to monitor the electrical consumption of the power supply as well?

Thanks in advance!

Hey Paolo, I’m assumng the LED fixture is a 220V sort of thing? You should be VERY Careful working with this.

For dimming, you can get a 5V DC PWM signal out of almost any one of the analog ports on the GrovePi. This would require just a little bit of wire cutting.

For monitoring the current consumption, I think the Grove Current monitor is your best bet. Safest too: you can install it without cutting the line or anything.

Hi John, thanks for the reply.

I saw in my earlier research that the GrovePi ports can put out a 5V DC PWM signal, unfortunately this won’t work for the LED power supplies I intend on using, because the signal voltage is required to be 10V DC for PWM. This is why I was considering the Grove MOSFET here:
http://www.seeedstudio.com/depot/Grove-MOSFET-p-1594.html

I’m leaning towards the Grove Current sensor as well for that part of the project, the current limit of the sensor should be just enough for what I need.

Thanks.

Hey Paolo,
We would love to see pictures when you’re done! Thanks for sharing! I hope we helped.
John

Hi John,

I’ll be more than happy to share the results once we’re done!

I received the MOSFET’s this week and had a chance to sit down and play around a bit tonight.

I have a some questions about the functionality. Based on the example code, I was expecting that the MOSFET would deliver 100% of the source voltage (either from the Pi or an external source) with the command ‘grovepi.analogWrite(mosfet,255)’ and 50% of the source power with ‘grovepi.analogWrite(mosfet,128)’ and so on.

When I connect my multimeter to the output of the MOSFET, I get different results than expected, and also different results depending on which port I plug the MOSFET into.

Here’s a summary of the MOSFET settings and corresponding voltages, with the last column of data showing the voltage readings with a 12v power supply connected to the MOSFET on port D3 of the GrovePi:

analogWrite() Value Voltage Pi #6 Voltage Pi #5 Voltage Pi #3 Voltage Ext #3
0 0 0 0 0
1 3 3 1.68 3.34
2 3.02 3.02 1.71 3.39
4 3.05 3.04 1.74 3.49
8 3.1 3.05 1.82 3.68
16 3.22 3.22 1.96 4.06
32 3.44 3.44 2.25 4.81
64 3.84 3.84 2.81 6.32
128 4.44 4.45 3.84 9.2
147 4.57 4.57 4.11 10
255 4.7 4.7 4.69 12.08

It seems that the output with the MOSFET on port D3 on the GrovePi is somewhat closer to what I would expect than the output while connected to port 5 or 6 on the GrovePi.

Now my main question - Is it possible to get the voltage any lower? With my external 12v power supply attached, I’m unable to get below 3.34 volts.

Any help would be appreciated!

Thank you.

Sorry, I realized the formatting of my test values didn’t turn out so well. Here’s a pic.

Thanks!

Hey Paolo,
Does giving analogWrite(3,0) give 0V on the D3 pin and analogWrite(3,1) give 3.3V? Can you attach your program here too.

-Karan

Hey Karan, thanks for getting back to me.

No, giving analogWrite(3,1) gives ~ 1.68V. It gives ~ 3.3V when I have a 12V power supply connected to the MOSFET’s input.

I was just using the example code for my initial testing, so I would just fire up a python shell and manually run the commands, checking the output voltage each time. The 4th column in my attachment above shows the voltages with the 12V power supply turned on, and the 3rd column shows the voltages without the external 12V, both on D3.

What I’m trying to ultimately achieve is to supply an output voltage of 1 - 10 volts to control a dimmable LED power supply.

The power supply has a built-in dimming circuit which will dim the lights to 10% output with 1V applied to the circuit, 20% with 2V, 30% with 3V and so on up to full power at 10V.

Based on my tests, it seems that the voltage reduction is not linear. I was expecting analogWrite(3,255) to be ~ 100%, analogWrite(3,128) to be ~ 50%, and analogWrite(3,64) to be ~ 25% and so on, as demonstrated here: https://www.arduino.cc/en/Tutorial/PWM

Also not sure why ports D5 and D6 differ so much from D3?

Thanks.

Can you run the troubleshooting script and upload the log on the forums by following the guide here: https://www.youtube.com/watch?v=ZMadpIEYq5o. Can you also update your script. I’ll try running it here and see what output I get.

-Karan

Hi Karan,

Here’s the troubleshooting script attached.

I pulled the latest script, re-installed and I’m getting the same results.

Cheers!

Hey Karan, any news on this?

Thanks!

Hey paolo,
Sorry for taking this long to reply back.

I just tested this on my setup here and it looks pretty good. I tried this program:

import time
import grovepi
led = 3

val=0
for val in range (0,255,10):
    grovepi.analogWrite(led,val)
    print ("%d,%.2f") %(val, 5.0*val/255)
    raw_input()

which basically print the value and waits for input so that I can check on a multi-meter. And this is what I got:

Analog Value Ideal (V) Reported (V)
0 0 0
10 0.2 0.175
20 0.39 0.345
30 0.59 0.517
40 0.78 0.689
50 0.98 0.861
60 1.18 1.03
70 1.37 1.2
80 1.57 1.37
90 1.76 1.55
100 1.96 1.72
110 2.16 1.89
120 2.35 2.1
130 2.55 2.25
140 2.75 2.4
150 2.94 2.51
160 3.14 2.74
170 3.33 2.92
180 3.53 3.03
190 3.73 3.26
200 3.92 3.43
210 4.12 3.78
220 4.31 3.95
230 4.51 4.12
240 4.71 4.3
250 4.9 4.5

I think my power supply was not beefy so that might be the reason for the displacement, but I was able to get low voltage too. Can you try this at your end and see if that helps.

-Karan

Hey Karan, thanks for testing it out. Your results look good, however my results are similar to what I originally reported.

Once I run your script and hit a key, the voltage jumps to 2.1 right away.

Very strange.

I tried another MOSFET, I get the same results.

I even tested my multimeter with some 1.5V batteries and a 12V car battery and it seems to be working fine. Below are the full results of your code.

Analog Value Ideal (V) Reported (V)
0 0 0
10 0.2 2.1
20 0.39 2.29
30 0.59 2.48
40 0.78 2.63
50 0.98 2.85
60 1.18 3.03
70 1.37 3.21
80 1.57 3.39
90 1.76 3.56
100 1.96 3.73
110 2.16 3.89
120 2.35 4.05
130 2.55 4.20
140 2.75 4.34
150 2.94 4.47
160 3.14 4.59
170 3.33 4.70
180 3.53 4.79
190 3.73 4.87
200 3.92 4.93
210 4.12 4.97
220 4.31 5
230 4.51 5.01
240 4.71 5
250 4.9 4.99

Not sure what I can try next. Do you think it may have something to do with the hardware version of the Pi?

Hey paolo,
Not really sure why that is happening. We have never seen that kind of behavior before. Can you upload a picture of your GrovePi setup. Can you also try a fresh image and maybe try burning the firmware once too. Follow the guide here: http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/.

Do let us know if this helps.

-Karan

Hi Karan,

I followed your suggestions and unfortunately I’m still getting the same result.

I installed the latest Dexter Industries Jessie, updated the O/S, merged the repo, and flashed the latest GrovePi firmware.

As you can see in the picture, I have my Pi2 (Model B) with the GrovePi+ and mosfet hooked up to my multimeter. In the background you can see my terminal window with the most recent command grovepi.analogWrite(3,10) and the multimeter showing 2.22 volts.

I’ve even tried an older Pi, and another multimeter with the same results.

Any other suggestions?

Thanks for the help!

Can you try it on ports D5 and D6 and see if they are any better.

-Karan

Also, what is that grove widget that you have in the picture. Can you directly measure the voltage on the Yellow and white wires on the GrovePi.

-Karan

I tried on D5/D6 and the results are even worse in terms of how low I could get the voltage to go. I found D3 to be the best. The widget is the Grove MOSFET.

After experimenting some more I finally got the expected voltages. Not sure how this makes sense, but if there are any kind of wires attached to the input (unpowered) and output sides, the output voltages were in line with what you were getting and what I was expecting - between 0 and 5V

The moment I removed the wires from the terminals, the results went back to 2 to 5V.

So it appears to work as expected only if there are wires in the terminals. Same on all 5 of the MOSFETS I tested. Is that strange or what?