-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
42 lines (34 loc) · 1.18 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Threading;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using PowerReader.Input;
namespace PowerReader
{
public class Program
{
public static void Main()
{
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
led.Write(true);
VoltageDivider voltageReader = new VoltageDivider(Pins.GPIO_PIN_A1, 470000, 4700);
Acs712 currentReader = new Acs712(Pins.GPIO_PIN_A2, Acs712.Range.ThirtyAmps);
EmonCmsProxy.Start();
MpptOptimizer.Start();
led.Write(false);
led.Dispose();
GC.WaitForPendingFinalizers();
//Random r = new Random((int) DateTime.Now.Ticks);
while (true)
{
double current = //r.NextDouble() / double.MaxValue * 10;
currentReader.Read();
double voltage = //r.NextDouble() / double.MaxValue * 3;
voltageReader.Read();
EmonCmsProxy.Push(current, voltage);
MpptOptimizer.Push(current, voltage);
Thread.Sleep(50);
}
}
}
}