CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How does ESP8266 work with Pic16f877a?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ghostmanzero



Joined: 01 Jan 2017
Posts: 12

View user's profile Send private message

How does ESP8266 work with Pic16f877a?
PostPosted: Thu Mar 02, 2017 8:29 am     Reply with quote

Hi everyone, I'm trying to build a circuit that can comunitacate with WiFi and send two simple data from pic circuit to a port(pc port which is connected to the same network)
I have been working on ccs c projects for a year. I believe that I can handle it but I need to know where I should start. There are some questions that I want to ask you.
1)how does ESP8266 work? (just a little summary to understand it)
2) Esp works with 3.3v (even rx and tx pins) but 877a works with 5V. Is there a device that can turn 3.3v into 5v while both Esp and pic are operating? I think I saw a little device for it once. But I couldn't find that page once again :/
3) I read the data sheets but I don't think that I can write a library file. I'm not good at it that much. Is there a ccs c library for it? I found something but I'm not sure that are working

I'm read to learn Smile just need someone to teach me Smile thank you for all answers (sorry for the mistakes. It is not my main tongue)
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 8:52 am     Reply with quote

Regarding 3.3V - 5V level translation: http://www.hobbytronics.co.uk/mosfet-voltage-level-converter

Honestly, if you have the full CCS compiler, you'd be better off choosing a higher-end part, like something from the PIC18 family (or higher), and by choosing a PIC capable of running at 3.3V.

You also need a power supply with rather high current to run the wifi module. That also implies a good PCB with adequate capacitors too.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 9:55 am     Reply with quote

First, forget about the 877. It HAS to be EOL by now(20+ years old). There are much newer PICs with more features for less money. I'm using the 18F46K22 as my 'Swiss Army Knife' for the past few years. several projects and I've never run out of pins,memory or peripherals. 2 HW UARTs is almost mandatory these days.
2nd, if this is a single point to point, consider the HC-12 series of RF modems. Far simpler to design/build/code. You literally could be 'up and running' in an afternoon.The HC-12 can be use for networks as well(master,several slaves) though I haven't used them for that yet. I like the 1Km range though !

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 11:13 am     Reply with quote

He wants WiFi not generic serial.

The ESP is a very good way of actually doing this, but I have to say the 877A is an awful choice. As already said, you have the problem of 5v to 3.3v interfacing, but also you need to be aware of just how much ROM/RAM you will need to do anything even remotely useful. On the interfacing, you can get away with simple resistive dividers for the signals going from the PIC to the 8266, but depending on what interface you are using, you will almost certainly need a way of raising the voltage to feed the PIC or use a PIC that has lower Vih levels.
A huge amount depends on what you actually want to 'do' with this. Likely code size, and the amount of RAM needed will depend on this.
ghostmanzero



Joined: 01 Jan 2017
Posts: 12

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 1:32 pm     Reply with quote

Thank you for the advice Smile well I can use a 3v level pic in order to get over the that voltage difference . so What then? Am I gonna only use the TX and rx pins? I have worked with rf modules before. And I did too many Rs232 examples. I used i2c too but I just used a library.anyway I tried to find an example about the Esp8266 but all I could find was just arduino arduino and arduino :D I wouldn't want to say that but I'm am an electrical and electronic engineer but unfortunately we didn't work on these topics at school. I just try to learn on my own. So I truly need your help Smile
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 02, 2017 3:12 pm     Reply with quote

Whichever ESP module you buy be SURE to read the power requirements ! Some need at least 1/3 of a AMPERE to transmit ! If you don't have a big enough supply, then VDD drops ,and the PIC stops running. So don't think that a two AA batteries will power the 'device', at least not for long.
Also antenna placement greatly affect range of the units.
It's never as easy 'as seen on TV'.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Mar 03, 2017 1:46 am     Reply with quote

My question still stands about what you actually want to 'do' with this?.

It's worth understanding just how complex some modern protocols actually are. If you look as simple RS232, most people here could do a program to send a message using this, in response to a message, in a handful of lines of code, using a few dozen bytes in a chip. Compare to USB, where the same thing, even using the 'off the shelf' libraries, would be several dozens of lines of code, with a lot more to go wrong, and the result in the PIC would occupy several KB of ROM.
Now the ESP itself is a very smart device, and handles a lot of this for you. However how much 'extra' you have to do, depends on what particular WiFi abilities you want to implement. Also there may be lots of other ways of getting the functionality you want, that are easier.
For instance, on the USB example, you could use a little stand alone USB to TTL module, and connect this to the PIC serial port, and in code terms you are then back to just the handful of code lines. If you just wanted a wireless connection to a PC, then one of the little Wireless Bluetooth dongles can do everything for you and put you back to the handful of lines of PIC code.

Potentially the WiFi solution offers more range, and gives connection to the Internet, but with every extra ability comes more code....
The complexity is also made worse, because the ESP8266 is not a fully standardised device. Unfortunately there are several different code versions of these, and a couple of different chip versions (though the EX is now the commonest), with poor documentation on the code in particular. Different versions have modifications to the command set, and also run at different baud rates. You can also program the chip on the unit itself, and use it to be a device like a data server on your network (there is though an NDA to get access fully to this programming data).
A summary of the 'known' basic command set is at:
<https://nurdspace.nl/ESP8266#AT_Commands>

This also has links covering most of the modules abilities.

The simplest way to use this module, is via the Hayes command set. It then behaves effectively as a 'modem', talking to your WiFi network, and to whatever else this attaches to. Even with this though how much code you need depends on what you then want to do.

The power has already been mentioned. When transmitting the unit can draw up to about 0.25A. Even on standby it draws about 50mA. Momentarily when the transmit switches on, surges over 0.3A are seen. Generally you need a supply that can reliably deliver about 0.5A, and has some good high frequency decoupling close to the device.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 03, 2017 7:27 am     Reply with quote

As Mr T points out WIFI isn't 'easy'. It's complicated and basic questions need to be answered.
What is the desired range for the communications?
What is the power supply for the 'remote'
One remote or a network of several ?

BTW, I can get 15 miles on direct wire a whole lot easier than any 'wireless' system.

Jay
ghostmanzero



Joined: 01 Jan 2017
Posts: 12

View user's profile Send private message

PostPosted: Fri Mar 03, 2017 8:45 am     Reply with quote

Ttelmah wrote:
My question still stands about what you actually want to 'do' with this?.

It's worth understanding just how complex some modern protocols actually are. If you look as simple RS232, most people here could do a program to send a message using this, in response to a message, in a handful of lines of code, using a few dozen bytes in a chip. Compare to USB, where the same thing, even using the 'off the shelf' libraries, would be several dozens of lines of code, with a lot more to go wrong, and the result in the PIC would occupy several KB of ROM.
Now the ESP itself is a very smart device, and handles a lot of this for you. However how much 'extra' you have to do, depends on what particular WiFi abilities you want to implement. Also there may be lots of other ways of getting the functionality you want, that are easier.
For instance, on the USB example, you could use a little stand alone USB to TTL module, and connect this to the PIC serial port, and in code terms you are then back to just the handful of code lines. If you just wanted a wireless connection to a PC, then one of the little Wireless Bluetooth dongles can do everything for you and put you back to the handful of lines of PIC code.

Potentially the WiFi solution offers more range, and gives connection to the Internet, but with every extra ability comes more code....
The complexity is also made worse, because the ESP8266 is not a fully standardised device. Unfortunately there are several different code versions of these, and a couple of different chip versions (though the EX is now the commonest), with poor documentation on the code in particular. Different versions have modifications to the command set, and also run at different baud rates. You can also program the chip on the unit itself, and use it to be a device like a data server on your network (there is though an NDA to get access fully to this programming data).
A summary of the 'known' basic command set is at:
<https://nurdspace.nl/ESP8266#AT_Commands>

This also has links covering most of the modules abilities.

The simplest way to use this module, is via the Hayes command set. It then behaves effectively as a 'modem', talking to your WiFi network, and to whatever else this attaches to. Even with this though how much code you need depends on what you then want to do.

The power has already been mentioned. When transmitting the unit can draw up to about 0.25A. Even on standby it draws about 50mA. Momentarily when the transmit switches on, surges over 0.3A are seen. Generally you need a supply that can reliably deliver about 0.5A, and has some good high frequency decoupling close to the device.


It looks like this will be really difficult Smile I just want to learn how to send two different bytes from a pic to a pc which both are connected to the Internet. Receiver (pic + esp8266) will be on a table in my room. (I also request you to suggest me a supply schematic if you have. I normally use 7805 or any 5v or 5 to 3.3v circuits). Modem will be in the same house.

But I want a wireless connection between Esp and modem. I need two buttons on receiver (like turning on and turning off buttons) when I press one of these two buttons, the PIC will send a simple message like "A" or "AB" by Esp8266. Then I will be able to get this message from somewhere else (maybe from another room, another house or another city. All of them are OK for me).
So my purpose is, just building a simple (I know that is NOT simple actually Smile ) circuit with Esp in order to understand using these Ethernet modules. Is it possible with Esp8266 ? Does it have a server system or a port section ? What would you suggest me to learn first? And also I've heard of enc28j60 and MRF24WG0M 802.11G WIFI. I have the required sections in my C Compiler for ENC and MRF. But I couldn't find the MRF24WG0M in my country. Are these (MRF and ESP) the same?

I have a Pickit 3 and programmer (beta release). Would it be enough to select the 3.3v (there is "target power" section on this software) to load the codes? I don't want to roast the PIC Very Happy
My problem is that I cannot find any information about these things. We just learnt the assembly with Pic16f628a in school (yeah I know it is ridiculous). So I need any schematic, article... Etc.
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Fri Mar 03, 2017 9:36 am     Reply with quote

If it's anywhere else in your house, garden, or within several hundred feet, then take Temtronic's suggestion, and look at the HC-12.
Honestly much easier.
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Mar 03, 2017 9:43 am     Reply with quote

Power supply: you might be able to get away with using a linear regulator, but you're going to need ample capacitance on both the input to and output of the regulator. Use pairs of capacitors, one high value electrolytic (e.g. 10uF - 470uF), and the other a 0.1uF or 10nF ceramic capacitor. You're going to need a pair of these very close to the wifi module. I'd throw in perhaps another 3 ceramics close to it as well. Ensure that the linear regulator has sufficient heat sinking so it won't overheat.

A switching supply is the logical progression, but at this point in your education I'd suggest buying one instead of trying to build one. They're honestly not that hard to create, but the trick is in proper PCB layout and that's not something that can really be either discussed here or properly explained here.

Personally, I'd specify/design a 2A peak supply for this. That gives you plenty of head room to be able to source momentary current spikes when the module transmits.

Simplest way forward is to find a "wall wart" switching power supply. Probably cheapest too.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group