Netduino 2 Plus and Adafruit FONA 808

Hello All,

I’ve bought a couple of weeks ago my first Netduino Board together with an adafruit fona 808 shield to begin a little Geo Location Project.
During those weeks I’ve discovered a lot of subtle things such as the pinout issues with the shield and it’s default 5V TTL configuration.
Fortunately, the guys at adafruit designed the board to be completely compatible with Arduino and other microcontrollers that doesn’t work on 5V TTL. So I’ve soldered the 3V jumper and hardwired the TX pin of the shield with the RX pin of COM2 port on the netduino and vice-versa:

From there I’ve plugged the shield into the netduino headers and tried following code:

    public static void Main(){

                SerialPort COMport = new SerialPort(SerialPorts.COM2,(int)BaudRate.Baudrate4800,Parity.None,8,StopBits.One);
                COMport.DataReceived += SerialPort_DataReceived;
                COMport.Open();
                byte[] input_buffer = UTF8Encoding.UTF8.GetBytes("ATI");
                COMport.Write(input_buffer, 0, input_buffer.Length);
}



private static void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        SerialPort port = (SerialPort)sender;
        byte[] buffer = new byte[port.BytesToRead];
        port.Read(buffer, 0, buffer.Length);
        // print out our received data
        Debug.Print(new String(System.Text.Encoding.UTF8.GetChars(buffer)));
    }

According to the Adafruit library written in C for Arduino (available here: https://github.com/adafruit/Adafruit_FONA), the ATI command should respond with an OK message and eventually the version of the Chipset built into the FONA.
Unfortunately the only response I get in the DataReceived Event handler is ATI.

The thread '<No Name>' (0x2) has exited with code 0 (0x0).
ATI
The thread '<No Name>' (0x1) has exited with code 0 (0x0).
Done.
Waiting for debug commands...
The program '[18] Micro Framework application: Managed' has exited with code 0 (0x0).

So my question is obvious, What am I doing wrong?
In the debug window I’ve also noticed that there is a thread (no name) (0x2) which has completed without any error. What is that thread?

Thanks in advance for your suggestions.

Kind regards

Alain

Try putting a Thread.Sleep(Timeout.Infinite) as the last statement in your Main procedure.

Hi Stephen,

Thanks for your quick response.
You’re suggesting to put an infinite thread to allow the event handler for eventually receiving data before the program execution stops right?

To be honest, I’ve striped down the code I used to not bother you with unnecessary clutter. Therefore, I used a waiting loop to allow the event handler to receive any data .

A Thread.Sleep(…) or an infinite loop will work as long as the infinite loop has a mechanism (Thread.Sleep(…) in it. You do not want to consume all CPU time in your loop blocking all other events in your program.

Well instead of using Timeout.infinite as argument of the sleep method, I used a 500 Msec timeout, repeated 10 times to have an end to the waiting loop…

Hello All,

I’ve been digging a little bit deeper into the data sheets of the Simcom 808L chipset and the arduino API reference guide.
It seems that the Println() function (and even the print()) of Software Serial sends the data using 7Bit Asciiencoding.
In my search on the internet about Ascii encoding I stumbled on a webpage regarding Netduino whishlists in which Asciiencoding was asked.
As it is supposed that UTF8Encoding should be able to handle all possible situations, how can i validate the 7 bit encoding needed for the FONA shield using Netduino.
Is there any beta implementation of the System.Text.Encoding.Asciiencoding class that I can use to test it out?

Thanks for your input

Kind regards

Alain

Hi

I use a couple of libraries make http requests & send SMS via a SIMCOM 900 based shield (The command sets are based on a GSM standard so should play nice)

More details here

@KiwiBryn

Hello,

Thanks for your input.
I’ll investigate their code on github to see how they handle the AT commands…
I hope I’ll find some stuff that’ll help me further.

Kind regards

Hello,

I just got the expected reaction from the shield by putting \r after each one of my commands…

Many thanks for your hint

Helped me further in my project.

Kind regards