The Hardware
- Netduino 2 Plus USD60 NZD108
- Grove System Starter Kit V3 USD50
- MP3 Shield USD20 or NZD31.97 or NZD45
- GPS Shield USD25 + Antenna USD7 or USD29.90
- Ultrasonic Ranger USD2.80 or USD14.90
- ADXL345 Accelerometer USD4 or USD9.90 or NZD35
- Joystick ShieldV2.4 USD9.98 or USD16.80 or NZD38.17
- Rotary Encoder USD3.80 or USD4.90
- nrf24l01 long range module USD12
- Embedded coolness nrf24l01 shield + Long range module AUD17.85
- 16×2 LCD Keypad shield USD8
- RFID Tag reader USD10.80 or USD12.90
- Current Sensor 30A USD3.98 also available 5A and 20A versions
- MOSFET Module USD3.90
The software
- Development tools
- MP3 Shield driver polled or interrupt driven
- ADXL345 driver
- .Net Micro framework toolbox for GPS & RFID Tag reader
- nRF24L01 library
- Xively library
Flash an LED
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); while ( true) { Led.Write(!Led.Read()) Thread.Sleep(500) }
Digital Input – Polled
InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled); OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); while (true) { led.Write(button.Read()); Thread.Sleep(1000); }
Digital Input – Interrupt
static OutputPort interuptled = new OutputPort(Pins.ONBOARD_LED, false); InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);</span></code> Thread.Sleep(Timeout.Infinite); static void button_OnInterrupt(uint data1, uint data2, DateTime time) { interuptled.Write(!interuptled.Read()); }
Analog Input
AnalogInput Sensor = new AnalogInput(Cpu.AnalogChannel.ANALOG_0); while ( true) { Debug.Print( "Value " + Sensor.Read("F2")); Thread.Sleep(500) }
Pulse Width Modulation Output
AnalogInput brightness = new AnalogInput(AnalogChannels.ANALOG_PIN_A0); PWM led = new PWM(PWMChannels.PWM_PIN_D5, 1000, 0.0, false); led.Start(); while (true) { Debug.Print("Brightness " + led.DutyCycle.ToString("F2")); led.DutyCycle = brightness.Read(); Thread.Sleep(500); } led.Stop();
Telemetry – Mobile station
Configure the NRF24L01 library for the elecfreaks Joystick ShieldV2.4, for more detail see this post
_module.OnDataReceived += OnReceive; _module.OnTransmitFailed += OnSendFailure; _module.OnTransmitSuccess += OnSendSuccess; _module.Initialize(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D1); _module.Configure(myAddress, channel); _module.Enable(); Timer joystickPositionUpdates = new Timer(JoyStickTimerProc, null, 500, 500); Thread.Sleep( Timeout.Infinite ) ;
Send the data to the base station (converting it from Unicode to ASCII)
private void JoyStickTimerProc(object state) { double xVal = x.Read(); double yVal = y.Read(); Debug.Print("X " + xVal.ToString("F1") + " Y &" + yVal.ToString("F1")); _module.SendTo(baseStationAddress, Encoding.UTF8.GetBytes( xVal.ToString("F1") + " " + yVal.ToString("F1"))); }
Telemetry – Base Station
Configure the NRF24L01 library for the Embedded Coolness board, for more detail see this post
private readonly NRF24L01Plus _module; _module.OnDataReceived += OnReceive; _module.OnTransmitFailed += OnSendFailure; _module.OnTransmitSuccess += OnSendSuccess; _module.Initialize(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D2); _module.Configure(_myAddress, channel); _module.Enable();
Display the inbound message (converting it from ASCII to Unicode)
private void OnReceive(byte[] data) { string message = new String(Encoding.UTF8.GetChars(data)); Debug.Print("Receive " + message); ; }