Notifications
Clear all

Connect ESP8266 via WiFi to C#

26 Posts
3 Users
1 Likes
1,269 Views
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

Hi All,

Time for my first question on the forum. I bought an ESP8266 so I can connect my MEGA2560 to WiFI. I want to be able to read some sensor data and change certain parameters in the MEGA2560 wireless. I thought I write an app in C# for this. I know a bit of C# and have checked up some tutorials about the ESP8266 I think the connection between the MEga and ESP is not so really complicated. But write a program in C# for WiFi will be the biggest challenge for me as I'm not a real IT guy so I don't know much about WiFI etc.

Does anybody have some nice recourses for me on how to set up. I have seen quite some stuff on Google but the biggest question first is who is the client and who is the server?
Will my C# program be a client or a server......:S Next I need to be able to get te values of e..g. motor speed and visualize them in the C# program and have the possibility to change them.

 

I hope someone could help me with some nice recources I would appreciate.

 

BR

Ray

Grtz,
Ray


   
Quote
(@hilldweller)
Member
Joined: 1 year ago
Posts: 111
 

There is a mega256 board with on board ESP chip. But effectively you program the two totally separately. Mega to/from ESP is 4 wires +/- power Transmit Receive.

 

"Visualise them in C#", so a PC program. That means you program the mega to do the interface (C). You toss the numbers serially to the ESP. The ESP is programmed as an Access Point ( C+HTML) for your PC to pick up the data and parse the HTML data(C#).

 

Simples.

 

Maybe an ESP32 would do the interface side all on it's own.


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

In words it sounds simple agree to make it work sounds like a challenge for me. I have found also a program that do the job maybe someone has experience with it.

https://www.megunolink.com/

This would save me loads of time I think. I think it would take me days or weeks to get a program on C# that communicates and draw some graphs and is able to send dat to the Mega. And this just for calibration purposes

Grtz,
Ray


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@electricray1981 It is extremely difficult to know how to respond to you. Let me give one example. There are quite a few PHD's earned and books written about how NOT to do a project. One thing NOT to do is to decide on a language or specific hardware platform first. That is one I have intimate experience of having watched a company go bankrupt after buying all the hardware first.

The second example is starting at a level that is decades beyond your existing experience.

We have no idea what it is you are trying to do, you are speaking of solutions, we need to get back to what are the requirements, what is the problem you are trying to solve and say it without any tech language.

As far as language, we mostly use libraries held together with a tiny bit of C, no more multi-million lines of code.

Both boards that you want to use would be server and client since you seem to want to go both directions. BTW, an ESP32 can easily replace both those boards.

The biggest question is are you trying to actually analyze, design and build or just assemble a kit which is in truth what 90% of hobbyists are doing.

Your last post is of a canned solution that you pay to use, sounds similar to arduino cloud and is between a PC and an arduino, not between an 8266 and an arduino.

Try to start at the beginning.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

Posted by: @electricray1981

In words it sounds simple agree to make it work sounds like a challenge for me. I have found also a program that do the job maybe someone has experience with it.

https://www.megunolink.com/

This would save me loads of time I think. I think it would take me days or weeks to get a program on C# that communicates and draw some graphs and is able to send dat to the Mega. And this just for calibration purposes

What does this mean

In words it sounds simple agree to make it work sounds like a challenge for me. I have found also a program that do the job maybe someone has experience with it.

can you rewrite that in English?

As far as your comment re 'days or weeks', from what I see it will be more like many months to years.

A lot depends on if you are going to do original work, or simply copy. One takes years, the other depending on complexity can be just a few hours.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

Posted by: @hilldweller

There is a mega256 board with on board ESP chip. But effectively you program the two totally separately. Mega to/from ESP is 4 wires +/- power Transmit Receive.

 

"Visualise them in C#", so a PC program. That means you program the mega to do the interface (C). You toss the numbers serially to the ESP. The ESP is programmed as an Access Point ( C+HTML) for your PC to pick up the data and parse the HTML data(C#).

 

Simples.

 

Maybe an ESP32 would do the interface side all on it's own.

That combo board is a one of and from what I have seen has a lot of issues, not recommended. Obviously an ESP32 would be the better choice, but if the OP wants to play with two boards, why not an esp01 for the WiFi similar to the PICO + esp01 combo board offered by Cytron and shown in the pic. As you can see of the 8 pins, 3 are unused, 2 are 3V3, one is GND leaving only 2 actual pins to create the board to board connection.

Screenshot 2023 01 26 at 07.25.06

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

Thanks you for your detailed answer, sorry if my english (not everyone is native english speaking) is so bad and I was not clear enough.

What Im'm trying to create is wireless communication between a Mega and my pc. Because I want to read and graph measurements. Because my Mega doesn't have a WiFi option on board I thought to use an ESP8266. I want to use the wireless communication to tune a PID loop and monitor sensor readings wireless and send command to the bot wireless.

I haven't decided anything yet on how to do it I'm searching for options let's make that clear. That's why I asked for some advise here. 

The link I posted of Megaunolink is exactly what I wanted to do, so instead of writing this by myself I could use this (obviously this saves time). This program can communicate with ESP8266 as well, so than I would only make the connection between the ESP8266. At the moment I'm controlling 2 motors, 2 servos, a Ultrasone Sensor and have a OLED connected. Yes maybe a ESP32 will be a better solution, but thats not the point of the disccussion I think, I'm building ow with a MEGA and wanted to accomplish something.

Im not building a prepared kit I only have bought a frame for building a robot and all other components I choose and order for myself to make the robot working eventually. So as far I see it I'm analyzing, designing and building FOR FUN.

 

Grtz,
Ray


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

@zander 

I have the ESP-12F version almost similiar I beleive. Just the antenna and some firmware differences if I understood well.

Grtz,
Ray


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@electricray1981 Again, please use REPLY to insert the tag @.... just like I did  <<<<<< at start of line.

You say

I haven't decided anything yet on how to do it 

and yet you start by saying you are using a mega and want to add an esp8266. So you HAVE decided.

I see you did learn to reply, congrats. Yes there is a whole family of boards starting with ESP01, your ESP12, on up to the current ESP32-S3. ANY of them will do WiFi, if you have a 12 great. The mega thing you mentioned is a competitor to the arduino cloud and the basics will be similar, not sure about the cost however. I tried arduino cloud and was not impressed for a few reasons.

This is now where we are.

One option is the https://www.megunolink.com/ and we can't help with that.

Another option is arduino cloud and I don't recommend that.

A third option is as you said with the mega connected to some WiFi board (esp-01, esp-12, esp-8266 etc) for that I just googled and got https://www.instructables.com/noobs-guide-to-ESP8266-with-Arduino-Mega-2560-or-U/

Have fun

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@electricray1981 I see one question left outstanding, and that is which is the server and which the client. Basically a server receives messages and then responds to them with data from some source, whereas the client is usually the human facing part that you enter a request into either as text or a button or other GUI widget and the answer is displayed.

The WiFi module be it esp-01 or esp-8266 is the server, your PC or phone is the client. The mega is just a sensor or data resource via one of it's standard protocols, I2C, SPI, serial.

EDIT: One key fact is you may need a level shifter to go between 5V and 3V3 logic levels. If you don't, you will smoke your esp board.

EDIT2: Just found this

This application is intended to run on ESP8266 module with accessible HSPI interface (e.g. ESP-12).

library is at HERE  install as per usual using Sketch/Include Library/Add .ZIP Library... etc see pic

Screenshot 2023 01 26 at 08.06.31

EDIT3: Sorry, just saw this

The newest esp8266/Arduino repository code breaks the app. 

EDIT4: Check out this link HERE  for details, READ CAREFULLY and ask questions if you are in the slightest doubt. There may be both hardware and software disasters in there but also the concept of a solution.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

@zander 

Thanks a lot for your help, I'll have a good read and most probably I'll have to come back with questions 😉 . BTW the Mega has a 3.3V supply and for the Tx (Tx Mega side -> Rx Esp side) line a voltage divider with two resistors of 1k2 and 2k2 would suit the job. 

And maybe I'll leave all the work I have for what it is and jump to a ESP32 cause if Iunderstand previous posts it could do the same or more. The petty is I had done quite some work allready, but thats part of the hobby I guess.

Grtz,
Ray


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@electricray1981 Most of the code you have created for the mega will work on the esp32. If you have used some libraries they may need to change. The 8266 family is good, just short of pins. The latest esp32's the 3 series S3, C3, more? Is new and very powerful. Have you considered a Raspberry Pi PICO, I would ask about Pi's but they are still in short supply. The new PICOW has WiFi built in and supported under the arduino IDE. So you have 3 choices, Arduino/esp8266 family, esp32, picow.

All built in the same IDE.

That 3rd party product looked very cool but at what cost, if cloud based what reliability. There is also a fella on the forum here known as @inq who has an 8266 based library that does a lot of similar things you want to do.Check out library InqPortal and web site https://inqonthat.com/InqPortal/ highly recommended.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

@zander 

Regarding the lib I have used only some standard libs and one dedicated for the motordriver. The one for the motordriver I have my doubts as in the manual they only talk about arduino. I'll need to investigate a bit I can't check my code now because I'm not at home these days (on the road for work). Tomorrow I can check some more details regarding the motordriver and which libraries I actually have used.

I have read the thread the you recommended in previous post

Posted by: @zander

EDIT4: Check out this link HERE  for details, READ CAREFULLY and ask questions if you are in the slightest doubt. There may be both hardware and software disasters in there but also the concept of a solution.

Seeing all the comments I think I make my life to complicated especially because the signals I wanted to read are only used for some PID fine tunning.

Thanks for all your suggestions and help

Grtz,
Ray


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6970
 

@electricray1981 Keep in mind that 'arduino' encompasses arduinio traditional, esp family, both 8266 and 32, and various incarnations of the RP2040 chip that you may know as Raspberry Pi PICOW. If you look in your personal libraries folder and locate the library, look in the library.properties file. Usually, the last statement is like the following

architectures=esp8266,esp32

but can also be architectures=* meaning all.  arduino only is avr. Most are * for all architectures. Just as FYI, I have included a screen shot of what boards I have supported in my IDE. Traditionally the esp32 is the longest list, but the Raspberry Pi RP2040 is growing.

Screenshot 2023 01 26 at 10.15.06

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
ElectricRay1981
(@electricray1981)
Member
Joined: 1 year ago
Posts: 119
Topic starter  

@zander 

 

I'm going to install the Arduino IDE and than the library that I'm using here on my company pc to see how it is. I'm curious now. I remember what library I'm using it's from adafruit and the shield is V1. 

Grtz,
Ray


   
ReplyQuote
Page 1 / 2