serial communication to MCU - EASY :-)

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

serial communication to MCU - EASY :-)

#1 Post by rayE » 25 Oct 2017, 14:19

Hi All,
Iv been on the ESP Easy uphill learning curve for around 2 weeks or so now. My main use for this firmware is the real nice web configurable front end. At the present moment im developing my own energy/utility monitoring sensors using the ESP module and a VERY low cost PIC processor that communicates with the ESP via the serial port.

So one requirement was the ability to set some parameters in the PIC via HTTP requests to ESP easy. I struggled with that for a while BUT the solution is unbelievably easy and NOT documented as far as i can see. For example you want to pass a variable back to an MCU that determines how many pulses per liter a flow sensor produces, then save this to ROM. This is how i have done it.

I set up a rule as follows.

on configFlowSensor do
Set a digital O/P high // This is used as a serial Interrupt request on the PIC and sets the PIC to listen on the serial port
$FlowSensorVariable=%eventvalue% // This string will be sent to the serial port, Event value is after the = sign in the HTTP send, below.
Set a digital O/P low // End of serial transmission
endon

I send the following HTTP request.
http://<your esp ip>/control?cmd=event,configFlowSenor=1

Then on the host MCU i have an interrupt that monitors the ESP D/O, this kicks off receive the string "$FlowSensorVariable=1" via the serial port. I wait for the $, parse the variable name, then parse the parameter, then store this parameter to ROM. You can set other rules that can be triggered from the MCU via the serial port to say acknowledge the comms (flash an LED for instance)

I thought i would share this as it may be useful to some like me out there that use the serial interface a lot. This is all to easy :-)
Ray

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: serial communication to MCU - EASY :-)

#2 Post by rayE » 25 Oct 2017, 14:41

I should have added that there are no devices set up for this, like dummy's or ser2net (tried all that but it was like rocket science for me) BUT you need to set the serial debug level to 2 or greater (check this, it may be 4?) so that the rule responses are passed out through the serial port.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: serial communication to MCU - EASY :-)

#3 Post by grovkillen » 25 Oct 2017, 15:56

Pretty clever! :)

Will try to add this to the wiki.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 17 guests