cdj wrote: Last question but interesting. Have you seen esphttpd project flashing the esp? if you implement this we can make a node only with esp and relay without arduino !
EasyIoT wrote: 9. Good idea, maybe someone will implement EasyIoT library on ESP8266 module
Please Log in or Create an account to join the conversation.
VasilijHCN wrote: Yes, U are right. This will be great, to control simple relay without arduino.
const String ESP8266_IP_ADDRESS = "102.168.1.5";
const String ESP_GPIO = "00";
/*
This code is running one time when program is enabled
*/
public void Setup()
{
EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
if (m.Domain == "Virtual" && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue")
sendCommand(ESP_GPIO, p.Value);
return true;
});
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
}
private void sendCommand(string pin, string value)
{
sendToServer("GPIO,"+pin+","+value);
}
private void sendToServer(String message)
{
try
{
Console.WriteLine("TCP client command:" + message);
Int32 port = 9999;
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient( ESP8266_IP_ADDRESS, port);
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
System.Net.Sockets.NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
// Close everything.
stream.Close();
client.Close();
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Thank U !!! All working perfectEasyIoT wrote:
VasilijHCN wrote: Yes, U are right. This will be great, to control simple relay without arduino.
Try this. Add virtual module and then add virtual module to group. Change module type to digital output. Remember module address. Then go to automation part and copy program below. Change ESP IP address, virtual module address and GPIO pin correspondingly. Enable automation program and go in WEB interface. Switch ON and OFF virtual module and see ESP8266 controlling GPIO pin without Arduino
const String ESP8266_IP_ADDRESS = "102.168.1.5"; const String ESP_GPIO = "00"; /* This code is running one time when program is enabled */ public void Setup() { EventHelper.ModuleChangedHandler((o, m, p) => { Console.WriteLine(m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value); if (m.Domain == "Virtual" && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue") sendCommand(ESP_GPIO, p.Value); return true; }); } /* This code is running periodicaly when program is enabled. Cron job detirmine running period. */ public void Run() { } private void sendCommand(string pin, string value) { sendToServer("GPIO,"+pin+","+value); } private void sendToServer(String message) { try { Console.WriteLine("TCP client command:" + message); Int32 port = 9999; System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient( ESP8266_IP_ADDRESS, port); Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); System.Net.Sockets.NetworkStream stream = client.GetStream(); stream.Write(data, 0, data.Length); // Close everything. stream.Close(); client.Close(); } catch(Exception e) { Console.WriteLine(e.StackTrace); } }
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
VasilijHCN wrote: How about a RGB(or single) LED Dimmer ?
www.esp8266.com/viewtopic.php?f=19&t=102...1&hilit=dimmer#p9041
This stuff also use tcp server, working on LUA firmware.
Also trying this in web browser:
http://192.168.1.105:88/Api/EasyIoT/Control/Module/Virtual/N5S0/ControlLevel/35
No change in the virtual N5S0 temperature node.
Please Log in or Create an account to join the conversation.