Arduino Nano + GPS + GPRS + LoRa + WebSocket + PHP + MySQL - Page 1
Forum section: electronics / beginners

author: SouthCoding2
author_rank: Newbie
timestamp: April 23, 2023, 01:03:01 am
content: Hello I'm working on a project in which I need to remotely control, Radio Communication Towers Autonomous Safety Lights.At the top of the tower there's the Master light ,that sends data via GPRS to a central server, for example, the GPS location, battery status, charge status ,condition ON/OFF, blinks per second and a few things more.On the lower levels, the other lights ( you can have more than 1 light on each floor, more specifically, one in each corner, or at least 2 lights, on opposite sides ), report their status to the master/The idea is to interconnect for examples 2 towers to get redundancy, in case the cellular network goes down, and use LoRa to send messages between towers (10 miles maximum ).I’ve been testing alone each of the modules that I have, and they seem to work fine, but I’m having a bit of trouble to get all the system working together.Actually I can read the NMEA sentences from the GPS, and I can contact servers using my modem.But after watching the server with MySQL database, there's no trace of the data being sent.Maybe the PHP script is wrong, but really it looks so simple that I doubt that's the problem. I believe that the delays I wrote after each of the AT commands ,are giving me some trouble. But I don’t have any previous experience with this kind of stuff.My Arduino has plenty of space left and is working fine.The idea is to send the GPS data to the MySQL server with the SIM800L, establish a WebSocket to interact between the Arduino and the server, and the WebPage and the server, so I can control for example the switching of the lights, the brightness and also show the location in google maps of the light (I’m planning on using GeoFencing to detect movement of the lights, besides having a shock sensor ).If there's some kind of alarm it will send an email to a list of recipients.I need to protect the access to the web page with a simple user/password, and if its possible...log time and date of each user that logs in.I know I’ve wrote a lot and that can be a little bit intimidating but ……If someone is willing to help me I can post the code and start to troubleshoot it.Thank you in advance.My hardware specs are:Modem SIM800LGPS UBLOX 7Arduino NanoLoRa DRF1278DMSoftware specs:Arduino IDEPHP Servers ProgrammingHTML ClientDatabase MySQLGoogle Maps API

author: brucehoult
author_rank: Super Contributor
timestamp: April 23, 2023, 01:52:30 am
content: I think involving SQL and websockets and so forth is getting out of the range of things you should use an ATMega328 for.You can get a Linux-capable board for basically the same price as a Nano e.g. Raspberry Pi Zero {W}, or a RISC-V board such as the Pine64 ox64. If they have enough GPIOs for your purpose, they are a heck of a lot easier to get various software stacks all running at the same time on, with a l,ot more RAM, Flash, and CPU power -- and still under 1 W of power consumption.It's not that you CAN'T do that on an AVR .. it's more than it's more pain than it's worth, for basically zero savings.

author: SouthCoding2
author_rank: Newbie
timestamp: April 23, 2023, 04:25:55 am
content: I see...I already have the nano, and I'd like to try if its possible. But it's true that maybe it's not intended for multitasking. I've enough free ports because I'm using the SoftwareSerial library and I emulate the TX and RX ports for the GPS and SIM800L. I think it's more like an academic challenge. Thanks anyway, I'll try and if its not possible I think I'll switch to another board, I was thinking on the ESP32 because I can share all the Arduino code.

author: brucehoult
author_rank: Super Contributor
timestamp: April 23, 2023, 06:36:05 am
content: If nothing else, 2 KB RAM is very limiting!Yes, ESP32 is a good choice. Also Bouffalo Lab make similar products for similar prices:https://en.bouffalolab.com/product/Their BL808 is the chip on the Pine64 ox64 I mentioned previously. Three CPU cores (two 32 bit, one 64 bit Linux capable with FPU and vector), 64 MB RAM, 16 MB flash, $8.https://wiki.pine64.org/wiki/Ox64

author: radiolistener
author_rank: Super Contributor
timestamp: April 23, 2023, 03:29:58 pm
content: I would suggest STM32 if you're planning to implement websocket. This is very hard task. So, I would suggest to replace it with usual TCP or even better UDP, it will be much more easy and fast.Also implementing PHP and SQL server scripting for microcontroller is a huge overhead and very complicated task.All that things is too much even for STM32F7 series. I think for arduino it's impossible at all.If you're still needs SQL, PHP and websocket server, it's better to use some linux based mini pc like Raspberry-PI-4 or ODROID-M1. It has 4-8 GB of memory which is needed to run SQL and PHP scripting, TCP stack and HTTP server with TLS and websocket extension.

author: brucehoult
author_rank: Super Contributor
timestamp: April 23, 2023, 11:13:58 pm
content: You certainly don't don't 4-8 GB of memory to run some server tasks.In the mid 90s I was running web server with CGIs, database, and so forth on a Mac SE/30 located in an office. It could easily saturate 10 Mbps ethernet. I don't recall how much RAM it had. In theory the SE/30 could take 128 MB RAM but in practice I don't think I ever saw one with more then 8-32 MB. And that's a 16 MHz 68030.A couple of years later I was running a Pentium 133 with Linux, apache, PHP, MySql. I think it probably didn't have more than 32 MB RAM.Modern Linux uses more RAM than 2.0 or 2.2 or whatever it was did, but still, you can boot stock standard modern Fedora or Ubuntu in command line mode on a 64 MB machine such as that $8 ox64 and have almost 50 MB free RAM, or with Buildroot and BusyBox over 53 MB free.GBs of RAM are only required for running CLIENT software such as GUI UIs and web browsers with multiple tabs/windows each with huge images and videos and megabytes of html and JavaScript in each page.

author: radiolistener
author_rank: Super Contributor
timestamp: April 24, 2023, 12:10:46 am
content: you can fit some simplified hand-made server within STM32, but if you want to use full featured HTTP server with websocket, TLS layer with supported CHACHA cryptography suite and real database SQL server, you can do all that on mini pc with 4-8 GB memory. And there is no need to write it from scratch, you can just install required linux package...regarding to the memory, there is no need to economy, because they already come with 4-8 GB out of the box

author: brucehoult
author_rank: Super Contributor
timestamp: April 24, 2023, 02:16:47 am
content: Quote from: radiolistener on April 24, 2023, 12:10:46 amIf you want to pay $50+, yes.You can get a RISC-V board running Linux at 480 MHz with 64 MB RAM for $8.Big difference.

author: SouthCoding2
author_rank: Newbie
timestamp: April 24, 2023, 04:04:36 am
content: I think that i need to clarify that for the webserver I'm planning in using 000webhost that's free and can run the MySQL and PHP. So that my microcontroller just sends data and updates info. Eventually the server connects to the Arduino and turns ON/OFF a LED.But I guess I'm not seeing something, I understand that it might be too small to accomplish so many tasks. Maybe the Virtual Serial port is not a good idea, not only because of the polling but also the delay involved in executing each function might lead to corrupt data?Thank you all for your guidance, it's helping me a lot.