Main Site Documentation

Output of the di1 pin not enough to function the relay


i brought a Panda II and Relay e block
but when i run the code it is not functioning only the small LED just light it with a poor bright. i think the output of the di1 pin not enough to function the relay .
pls help me to overcome this problem


You can NOT connect a relay directly to a pin on processor, not on FEZ and not on any other microcontroller. This will damage your micro, your FEZ.

The internet is full of tutorials on this, like this one

You can use our relay board which already has the transistor on it


i brought a 3-Pin E-Block RELAY and plug it to JST Connector(Di1)


What JST connector, there is no JST connector on the Panda?

So how did you connect it?


@ EricSan500 - I think he means via the eBlock or Connect shield.


ya i have connected relay e block via connected shield


My aim is to control relay through the web server . i have try several codes but i failed.pls some body help me


First, make sure you are able to control the relay directly. If you still have problems then post a picture of how the relay is connected and post your code as well please


thanks GUS

now my relay is functioning this is the code i have run.but i don’t how to off the relay by clinking OFF button

using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.NetworkInformation;
public class Program
    public static void Main()
         FEZ_Components.Relay myRelay = new FEZ_Components.Relay(FEZ_Pin.Digital.Di1);

        byte[] ip = { 192, 168, 2, 5 };
        byte[] subnet = { 255, 255, 255, 0 };
        byte[] gateway = { 192, 168, 1, 1 };
        byte[] mac = { 0x00, 0x88, 0x98, 0x90, 0xD4, 0xE0 };

        WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
        (Cpu.Pin)FEZ_Pin.Digital.Di7, true);
        NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);

        // start server
        HttpListener listener = new HttpListener("http", 80);
        while (true)
            HttpListenerResponse response = null;
            HttpListenerContext context = null;
                context = listener.GetContext();
                response = context.Response;

                // The button is pressed
                if (context.Request.HttpMethod == "POST")
                // Sends response
                response.StatusCode = (int)HttpStatusCode.OK;
                byte[] HTML = Encoding.UTF8.GetBytes(
                "<html><body>" +
                "<h1>LIVING ROOM</h1>" +
                "<p>SWITCH ON OR OFF</p>" +
                "<form action=\"\" method=\"post\">" +
                "<input type=\"submit\" value=\"ON\">" +

                 "<form action=\"\" method=\"post\">" +
                "<input type=\"submit\" value=\"OFF\">" +
                "</form>" +
                response.ContentType = "text/html";
                response.OutputStream.Write(HTML, 0, HTML.Length);
                if (context != null)

also i want tell u i don’t have much knowledge in C# but try to learn …


Good, now you know the hardware is working fine and you only need the correct software.

Have you looked at the internet of things ebook? It already has many project examples.


As Gus says, the IoT book will have relevant samples that you can use.

But what doesn’t work in your app as it stands today? What does it do when you do the POST? What stepping through your code have you tried to see the behaviour? And what values do you get in your response?

The next logical step is to change your arbitrary turn relay on wait 2 sec turn relay off into a conditional check from the response to handle the two different conditions you’re expecting.