Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

To comunicate netduino 2+ with module bluetooth jy mcu(app android)

android serialport bluetooth com jymcu module bluetooth blink led appinventor

  • Please log in to reply
5 replies to this topic

#1 Archimede

Archimede

    Member

  • Validating
  • PipPip
  • 15 posts

Posted 17 November 2014 - 12:29 AM

Hello everybody,
 
i was written this code to comunicate netduino 2 plus and smartphone.
My goal is to send with my app tha word "H" or "L".
Netduino 2 plus recive the data and change led's state onboard on or off.
(Remind...before to use app with netduino you must to do the pairing between module bluetooth and your smartphone.
Connect module bluetooth on netduino.More information on module bluetooth find on line).
 
netduino 2 plus code:
 
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using System.IO.Ports;
using System.Text;
 
namespace Bluetooth
{
    
    public class Program
    {
        static SerialPort bt; //bt=bluetooth
        static byte[] buffer = new byte[1024];
        static int bufferOffSet = 0;
        
        static OutputPort led;
 
        public static void Main()
        {
            
            led = new OutputPort(Pins.ONBOARD_LED, false);
 
 
//initialize the serial port for com2
            bt = new SerialPort(SerialPorts.COM2);//my netduino 2 plus comunicate with com2 pin D2(RX) and D3(TX)
 
            bt.DataReceived += DataReceived;
 
//open the serial port so is possible to send and to recive  data.
            bt.Open();
 
            Thread.Sleep(Timeout.Infinite);
 
        }
 
 
private static void DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            var byteRead = 0;
 
//check if there are the data
            while (bt.BytesToRead > 0)
            {
                byteRead = bt.Read(buffer,bufferOffSet,buffer.Length-bufferOffSet);
                bufferOffSet += byteRead;
            }
 
            bufferOffSet = 0;
 
//convert the data in string
            var chars = Encoding.UTF8.GetChars(buffer, 0, byteRead);
            var data = new string(chars);
 
            
            if (data.Equals("H"))
            {
                led.Write(true);
                //Debug.Print("led on");
            }
            else
            {
                if (data.Equals("L"))
                {
                    led.Write(false);
                    //Debug.Print("led off");
  }
            }
            
            
            
        }
        
        private static void ExecuteCommand(string command)
        {
            throw new NotImplementedException();
        }
    }
}
 
 
the code for app on smartphone you can find on line.
Write appinventor bluetooth and there is the code to comunicate with bluetooth.
 
i hope that this code can to be helpful for you...
(sorry for my english.) 
 


#2 EagleSparrow

EagleSparrow

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationMiami, Florida

Posted 09 December 2014 - 02:10 PM

Have you picked hardware for the blue tooth part? I am trying something similar and need to pick a daughter card that has the blue-tooth on it to try one of these apps. I guess I will need a battery pack for it to demo it to.



#3 Archimede

Archimede

    Member

  • Validating
  • PipPip
  • 15 posts

Posted 17 December 2014 - 07:15 PM

Sorry EagleSparrow but i understand little bit in english....

i hope to answer your question....(else if you can rewrite your question in other way... tank you :) )

 

i took a compatible module with netduino plus 2 but i think that there are more modules bluetooth compatible with netduino plus 2 

i took jy mcu becouse is not expensive.

this bluetooth module can connect only one device at a time...therefore if at your appplication must connect 2 or more devices in the same time this bluetooth jy mcu doesn't good...

 

(you need of a battery if you don't want to connect netduino to the pc...)

 

regards... :) 



#4 henslecd

henslecd

    New Member

  • Members
  • Pip
  • 8 posts

Posted 20 December 2014 - 05:39 AM

Have you picked hardware for the blue tooth part? I am trying something similar and need to pick a daughter card that has the blue-tooth on it to try one of these apps. I guess I will need a battery pack for it to demo it to.

 

I am using the BLE Mini from RedBearLab.  You have to solder the pins for tx/rx/gnd/vin on the Mini and then use jumpers to the netduino (if COM1 then D0/D1/gnd/5v).  It is pretty simple and RedBearLab has a BLE Controller app for Android (4.3+) and iOS devices to test it out with.  I highly recommend it for prototyping.



#5 EagleSparrow

EagleSparrow

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationMiami, Florida

Posted 20 December 2014 - 02:36 PM

I am using the BLE Mini from RedBearLab. You have to solder the pins for tx/rx/gnd/vin on the Mini and then use jumpers to the netduino (if COM1 then D0/D1/gnd/5v). It is pretty simple and RedBearLab has a BLE Controller app for Android (4.3+) and iOS devices to test it out with. I highly recommend it for prototyping.


I purchased a little board but it came with no instructions nothing no schematic nothing so I'm going to have to look into the board that you purchased for the Bluetooth. In the end I want to integrate these all on to one little board, a Micro and USB, and bluetooth. I have to connect to some external hardware and talk to it somehow. This seems to be the best way. Also a web server solution might be the way to go. But then I would need a GSM at on where my device can phone home or connect to a web server. I don't know how I would do this right now. Basically falling home, get a website service URL get instructions on what to do and send back information. Pretty simple in theory. If anybody has done this already please let me know. I'm sure there's a lot of people that need to do this kind of thing.

#6 EagleSparrow

EagleSparrow

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts
  • LocationMiami, Florida

Posted 02 February 2015 - 05:44 PM

I got my USB board but have to figure out where to connect it to on my Netduino Duo Plus 2 device.

I also need a sample phone app to talk with it.

Anybody done this?







Also tagged with one or more of these keywords: android, serialport, bluetooth, com, jymcu module bluetooth, blink, led, appinventor

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.