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

Atlas Scientific ENV-RGB Sensor not responding

serial ENV-RGB

  • Please log in to reply
No replies to this topic

#1 itsme

itsme

    New Member

  • Members
  • Pip
  • 6 posts

Posted 14 January 2013 - 12:08 AM

I just got a Atlas Scientific ENV-RGB sensor from sparkfun, and I've spent the last two days trying to get it to work. I hooked it up according to the datasheet with red going to 3.3V, black to ground, white (tx) to digital pin 0(rx) and  green(rx) to digital pin 1(tx) on the Netduino. Also I have the following code. 

 

public static void Main()        {            SerialPort sp;            try            {                sp = new SerialPort(Serial.COM1, 38400, Parity.None, 8, StopBits.One);                sp.Open();                sp.DataReceived += new SerialDataReceivedEventHandler(SerialDataReciever);                byte[] message = Encoding.UTF8.GetBytes("Er");                Debug.Print(new string(Encoding.UTF8.GetChars(message)));                sp.Write(message, 0, message.Length);                while (true) { }            }            catch (Exception e)            {                Debug.Print(e.StackTrace);            }        }        public static void SerialDataReciever(object obj, SerialDataReceivedEventArgs args)        {            SerialPort thePorts = obj as SerialPort;            if (thePorts.BytesToRead > 4)            {                byte[] buffer = new byte[30];                thePorts.Read(buffer, 0, thePorts.BytesToRead);                Debug.Print(new string(Encoding.UTF8.GetChars(buffer)));            }        }

 

 

The problem I'm having is that even though my SerialDataReciever method is getting called the bytes are empty when its called. Also by default it should return 5 bytes though the first time that SerialDataReciever is called it only contains 2 bytes, both of which are empty. Does anyone have any experience with this sensor? I'm not sure if I am using the SerialPort class correctly, but from what I've read I feel like it should work. Any help would be greatly appreciated. Thanks.







Also tagged with one or more of these keywords: serial, ENV-RGB

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.