Serial output?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Serial output?

#1 Post by Troubled » 30 Aug 2016, 21:36

Hi. I have a setup consisting of two NodeMcu ESPs and a raspberrypi. I have migrated from other framework and I arrived at a problem:

Is it possible to send commands to serial by command? I could use something like

Code: Select all

http://192.168.0.xxx/control?cmd=Serial,(string to send through serial com)
to my project. Or if this is impossible, some other means of communicating with arduino-like hardware.

In general my idea would look like this:

Domoticz <-> EspEasy (with sensors and relays) -> Arduino -> WS2812 LEDs

I have seen scripts for controlling WS2812 LEDs directly from ESP8266, but I do not want to lose EspEasy functionality on each device with them.
Last edited by Troubled on 31 Aug 2016, 08:37, edited 1 time in total.

User avatar
nonflammable
Normal user
Posts: 42
Joined: 09 Mar 2016, 22:19
Location: Poland

Re: Serial output?

#2 Post by nonflammable » 30 Aug 2016, 23:24

Troubled wrote:Hi. I have a setup consisting of two NodeMcu ESPs and a raspberrypi. I have migrated from other framework and I arrived at a problem:

Is it possible to send commands to serial by command? I could use something like http://192.168.0.xxx/control?cmd=Serial,(string to send through serial com) to my project. Or if this is impossible, some other means of communicating with arduino-like hardware.

In general my idea would look like this:

Domoticz <-> EspEasy (with sensors and relays) -> Arduino -> WS2812 LEDs

I have seen scripts for controlling WS2812 LEDs directly from ESP8266, but I do not want to lose EspEasy functionality on each device with them.
I think it's possible with IRTX (Infrared Transmit) plugin (R124+) or plugin playground P106 for older versions.
You can configure ESP to transmit some codes to Arduino with wire between ESP and Arduino (bypassing IR Transmit LED and IR receiver).
On Arduino you should use some infrared receiver library.
You can use HTTP to send string. Eg.

Code: Select all

http://192.168.0.xxx/control?cmd=IRSEND,RC5,138c,12

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#3 Post by Troubled » 31 Aug 2016, 08:33

nonflammable wrote:I think it's possible with IRTX (Infrared Transmit) plugin (R124+) or plugin playground P106 for older versions.
You can configure ESP to transmit some codes to Arduino with wire between ESP and Arduino (bypassing IR Transmit LED and IR receiver).
On Arduino you should use some infrared receiver library.
You can use HTTP to send string. Eg.

Code: Select all

http://192.168.0.xxx/control?cmd=IRSEND,RC5,138c,12
That would be absolutely perfect! I have looked through espeasy wiki, github and google to find more details, but found just IRTX as a plugin without any information. My EspEasy reponds with "Unknown or restricted command!" so do I need to install or setup it separately?

User avatar
nonflammable
Normal user
Posts: 42
Joined: 09 Mar 2016, 22:19
Location: Poland

Re: Serial output?

#4 Post by nonflammable » 31 Aug 2016, 15:39

You should have ESPEasy R124 or newer version to use IRTX plugin. Then configure it in Devices tab.

Martinus

Re: Serial output?

#5 Post by Martinus » 31 Aug 2016, 16:00

I think that linking the Arduino using I2C could be easier, no additional libraries required.
Or create/adapt a plugin to control WS2812 leds directly from the ESP. Just like the P101_NeoClock plugin in the plugin playground

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#6 Post by Troubled » 01 Sep 2016, 13:03

nonflammable wrote:You should have ESPEasy R124 or newer version to use IRTX plugin. Then configure it in Devices tab.
Oh, yes, it works, I had older version installed. I will work on arduino side now. Dziękuję bardzo ;)
Martinus wrote:I think that linking the Arduino using I2C could be easier, no additional libraries required.
Or create/adapt a plugin to control WS2812 leds directly from the ESP. Just like the P101_NeoClock plugin in the plugin playground
Could you explain how to use I2C? I found the ProMini expander, but that would only give me additional GPIO, but not another controller of its own. As for driving LEDs I have bad experience in using ESP for this. It works, but generating even constant signal for WS2812 LEDs messes and blocks WiFi, so I am afraid the problem could repeat here. Also I am only amateur programmer and I do not have the skills to write new plugin

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#7 Post by Troubled » 05 Sep 2016, 12:48

So I found a IR library for arduino as a downloadable within Arduino IDE and experimented with it, but with absolutely no results. So after trying different combinations with joining grounds and power supply and still coming up with nothing I straight up connected a LED between transmit pin and ground... and saw nothing. So either I am doing something wrong, or the IRTX plugin just happily reacts with "IR Code Sent" and does nothing.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Serial output?

#8 Post by costo » 05 Sep 2016, 13:06

You probably should first try to make it work with a arduino. That would be easier to solve problems.
There can be many reasons why it does not work.

If you have it working with arduino you can then make it work with the same components on ESP8266, ESPEasy and the IRplugin.

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#9 Post by Troubled » 06 Sep 2016, 17:02

It would seem that it requires more development that I thought. While connected to EspEasy device the reciever was just silent, but when I connected it to other arduino it started getting a lot of noise that it interpreted as signal (no matter the pin it was connected to, apparently) and the signal itself was unstable and undecodable.
I am ready to give up, this method does not look very reliable. So please tell me, how hard it would be to write a serial output plugin? Or could can I put it somewhere as an idea for the developers?

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#10 Post by Troubled » 02 Oct 2016, 17:06

I made my own solution based on "pulse" command and "pulseIn" function in Arduino. So for any other person looking for similar feature - here it is:
ESP side:

Code: Select all

http://<espip>/control?cmd=Pulse,<pin>,1,<duration>
Then on Arduino:

Code: Select all

int pin = 13;
unsigned long duration;

void setup(){
  Serial.begin(9600);
  pinMode(pin, INPUT);
}
void loop(){
  duration = pulseIn(pin, HIGH)/1000;
  Serial.println(duration);
}
All that is left is assign function to duration times. Nevertheless I think it would be a good idea to implement some easy transfer of data between arduino and esp8266 as arduino has vast number of ready libraries and even bigger amount of ready tutorials on the web, so it would easily multiply the functionality of EspEasy.

Troubled
New user
Posts: 8
Joined: 30 Aug 2016, 21:14

Re: Serial output?

#11 Post by Troubled » 08 Oct 2016, 12:00

The thread is dead, but here is my last update. I used code like this:

Code: Select all

volatile int pwm_value = 0;
volatile int prev_time = 0;
 
void setup() {
  Serial.begin(115200);
  // when pin D2 goes high, call the rising function
  attachInterrupt(0, rising, RISING);
}
 
void loop() { }
 
void rising() {
  attachInterrupt(0, falling, FALLING);
  prev_time = micros();
}
 
void falling() {
  attachInterrupt(0, rising, RISING);
  pwm_value = micros()-prev_time;
  Serial.println(pwm_value);
}
It works better

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests