Recent

Author Topic: give some ideas please  (Read 1472 times)

krolikbest

  • Full Member
  • ***
  • Posts: 246
give some ideas please
« on: September 16, 2020, 11:58:30 am »
Hi,

currently I'm developing some project with couple of esp8266 which should send some simply datas (number 0..100) over wifi to the pc computer. These esp8266 will work in station mode. Every esp has own IP number.
Next step would be to collect this datas using some computer, for example RPi. And there comes questions according to collecting these datas assuming that on RPi application written in Lazarus is working:

1a. at first glance I would like to use fphttpclient to coumunicate with multiple esp8266s: get raw datas from every esp, but then this application is multithreaded, in other words create x threads and  every thread is checking for new datas from some esp..

Maybe I'm making it too complicated?

2a. after receiving datas (and maybe after parsing them maybe not) use some webserver to present received datas. Then would like to use fpWeb in order to create my webserver.

Really in that way, or someting different, but I prefer simply solutions ;)?

3a. Received datas from 1a will be put in this webserver.. I cant' say I'm crazy for this solution and maybe there is more convenient way for whole problem? So please give some advices.

Regards


paweld

  • Hero Member
  • *****
  • Posts: 991
Re: give some ideas please
« Reply #1 on: September 16, 2020, 01:07:21 pm »
ja robiłem rozwiązanie oparte o parę arduino+esp, i zrobiłem to w ten sposób, że komputer (w Twoim przypadku RPi) służył jako serwer.
aplikację serwerową oparłem na TCP Server z pakietu Indy, ale w Twoim przypadku napisałbym serwer http, który zarówno przyjmowałby jak i prezentował zapisane dane z urządzeń.
---
I was making a solution based on the arduino + esp pair, and made it so that the computer (RPi in your case) served as the server.
I based the server application on TCP Server from the Indy package, but in your case I would write an http server that would both receive and present saved data from devices.
Best regards / Pozdrawiam
paweld

ccrause

  • Hero Member
  • *****
  • Posts: 856
Re: give some ideas please
« Reply #2 on: September 16, 2020, 01:21:29 pm »
currently I'm developing some project with couple of esp8266 which should send some simply datas (number 0..100) over wifi to the pc computer. These esp8266 will work in station mode. Every esp has own IP number.
Next step would be to collect this datas using some computer, for example RPi. And there comes questions according to collecting these datas assuming that on RPi application written in Lazarus is working:

1a. at first glance I would like to use fphttpclient to coumunicate with multiple esp8266s: get raw datas from every esp, but then this application is multithreaded, in other words create x threads and  every thread is checking for new datas from some esp..

Can you tell a bit more about the data transfer requirements & limitations? Do you need synchronized logging? Can the esps buffer data until contacted to upload to a server? Will there be some kind of registration process where say a esp gets online and register its presence to the server? Are the data transfers event driven on the esp side, in other words the server may not know when data should be read?

Quote

Maybe I'm making it too complicated?

2a. after receiving datas (and maybe after parsing them maybe not) use some webserver to present received datas. Then would like to use fpWeb in order to create my webserver.

Really in that way, or someting different, but I prefer simply solutions ;)?

3a. Received datas from 1a will be put in this webserver.. I cant' say I'm crazy for this solution and maybe there is more convenient way for whole problem? So please give some advices.

One option is server polling, basically each esp register with the server (or gets statically compiled in a list on the server), then gets polled in a loop by the server.  No multi threading required.  This may require the esp to buffer data (possibly time stamped) until polled for data.  May not be the best option if data transfer depends on external factors/triggers.

What should happen if a) one or more of the esps are offline or b) the server is offline?

Once you have the data serving up a web interface should be straight-forward (at least in principle).

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: give some ideas please
« Reply #3 on: September 16, 2020, 05:56:29 pm »

Can you tell a bit more about the data transfer requirements & limitations? Do you need synchronized logging? Can the esps buffer data until contacted to upload to a server? Will there be some kind of registration process where say a esp gets online and register its presence to the server? Are the data transfers event driven on the esp side, in other words the server may not know when data should be read?

 Behind esp there is atmega (attiny or so) and esp in my case is used only as a wifi stuff driven by AT commands. Don't need synchronization. Every esp will be registered on pc-side so in fact, simpler would be in a loop. After receiving pc can confirm this withi some sign/mark so then atmega "knows" when to send something next. Ok, more or less I know what is going on..

@paweld - lately did webserver on my arduino uno with W5100 hat (it is written in Bascom) and then i discovered esp8266.. :)


ccrause

  • Hero Member
  • *****
  • Posts: 856
Re: give some ideas please
« Reply #4 on: September 16, 2020, 07:13:35 pm »
@paweld - lately did webserver on my arduino uno with W5100 hat (it is written in Bascom) and then i discovered esp8266.. :)
Have you considered moving the logic currently on the AVR to the esp8266 and do everything on the esp (including programming it using FPC)? The one aspect that is relatively poor compared to the AVRs is ADC.  The esp only has one ADC pin which is often not accessible on cheap breakout boards such as the ESP01.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: give some ideas please
« Reply #5 on: September 16, 2020, 07:25:04 pm »
Exactly mine is esp8266-01 :)  It has only 2 gpio pins and I don't use ADC (even don't know whether it has any..). It is used in this way that it acts as a wifi card only. Logic is on avr.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: give some ideas please
« Reply #6 on: September 17, 2020, 01:40:02 pm »
If I understood well, you have several Arduinos, each connected via serial link to his own esp8266.

In such configuration, you use esp8266 as a dummy serial<>tcpip transparent bridge. Besides access point authentication, you just set esp8266 IP address and single TCP/IP port in Arduino code, and then any data sent to that TCP/IP port goes to RX of Arduino, and all data that Arduino sends to TX port will be received from esp8266 TCP/IP port. In such configuration, you can not use fphttpclient as data is not available through web server. You should use Synapse or some other TCP/IP client lib on Pi side to cyclically read data from your devices (each having unique IP address). Just keep in mind that serial communication in Arduino is interrupt based, so you should have a small silence period between readings. Something like 1 second should be more then enough (you can experiment how low you can go). You can implement some standard (or your own) request/reply protocol, or make it even simpler by making Arduino to constantly send measured value to TX each second and just parse it on Pi side when received.

Of course, in order for PI to be able to find them, it is simplest if your devices have fixed IP addresses. Either by settng them in Arduino code (you can use the same code on all Arduinos if you use DIP switches), or by using DHCP and making them static in your wireless router / access point.
« Last Edit: September 17, 2020, 01:50:17 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: give some ideas please
« Reply #7 on: September 18, 2020, 10:59:47 am »
@Avra, you described exactly what I'm doing. And actually yesterday I discovered that it is "no way" in using httpclient in my case. I used tcpclient from Synapse instead. Currently build httpserver on RPi side in order to show received datas. RPi should be configured also as an AP but don't expect problems - there is plenty of tutorials how to.

 

TinyPortal © 2005-2018