I can install the Blynk Blink example on the Mega. But is there any code required in the ESP8266 processor for this example to work?
I currently have Arduino code in the ESP8266 from another example i tried from Jaycar for setting it up as a webserver.
Do I need to clear this code before running the BLynk Blink example and how would I do that?
You will need to reload the with 8266 firm ware for AT commands. The mega will talk to the esp with the TX and RX pins with AT commands. The Blynk sketch will need to be loaded on the mega. There is lots of setups and their many issues here on this forum. (The esp8266 as a breakout is less problematic)
Please excuse my ignorance. If I program the ESP8266 firmware for AT commands then I assume I will need to programe the AT commands in the Mega Arduino code and likewise program something in the ESP8266 that can read and send serial data using AT commands as well.
What I am trying to understand is how does the ESP8266 internally transfer a command from wifi over to the Mega, is it just black magic in the firmware or do I need to write code to process this.
No, it’s ‘black magic’ (if we’re allowed to use that term anymore) in the BlynkSimpleShieldEsp8266.h library file that is included in the sketch examples that use an Arduino + ESP8266 shield.
When ESP8266’s ship from the factory they are programmed with AT firmware. When you uploaded a sketch to the ESP you over-wrote this, and if you want the ESP to act as a WiFi modem for your Mega then you need to re-install the factory AT firmware. This can’t be done using the Arduino IDE, you have to use something like ESPTool.
Then, the ESP8266 (which incidentally is several times more powerful than the Mega) will act as a dumb modem for the Mega and give it a limited degree of WiFi functionality.
The board you’ve chosen is probably the worst possible way of getting started with IoT connectivity (and ridiculously expensive for what it is as well). Getting the switch settings right, and using the correct serial port configured in your sketch is confusing for beginners and at the end of that process you still have a low powered MCU with no IoT connectivity which is using a higher powered MCU as a WiFi modem. Something we tend to compare to the idea of using a sports car to tow a cart.
Admittedly, there are some situations where an Uno or Mega with an ESP8266 are better choices than an ESP8266 on its own, but often in those situations an ESP32 is a better overall choice of board.
I’d usually encourage newcomers to start with an ESP8266 based board such as the NodeMCU or Wemos D1 Mini, as they are much simpler to get up and running with, and don’t have the drawbacks associated with the Uno/Mega plus ESP8266 combo. If they then need to use an Uno or Mega based solution then what they’ve learned with the NodeMCU will be an excellent grounding in IoT systems such as Blynk.
Thanks to all for your help. It took me a week to update the firmware on the ESP8266. In the end I tried the FW version 2.2.1 and everything worked OK.
All other more recent versions did not accept. AT commands from the Arduino serial monitor.
I spent hours trawling the Internet for information, it’s just rubbish.
I’m not exactly a newbie, I am an Electrical Engineer and upgrading FW should not be this difficult.
This is the second bad experience I have had with an ESP8266 type module. It just blows my mind how it can be so difficult. I think from now on I will rather purchase approved and tested Arduino boards and at least that way I have the vast experience of the Arduino forum to fall back on as well.
My recommendation would be exactly the opposite.
The most widely used Arduino boards don’t have WiFi connectivity. The ones that do are not so widely used.
Arduino missed the boat on IoT boards and that gap was filled by Espressif with the ESP8266 and ESP32 chips. The bad experience you have experienced is because your trying to use the more powerful ESP8266 as a ‘dumb modem’ for the less powerful Arduino Mega. Also, you’ve selected a board that looks good on paper compared to the Arduino Mega plus a separate ESP-01 board, but in reality it’s the worst of both worlds.
I’d suggest you take a read of this, then order some NodeMCU/Wemos D1 Mini type boards, or some ESP32 Dev boards…
Thanks for the advice Peter. I will look into your suggestions a bit more. I want to make sure there is a community Forum out there where I can share my ideas if I get stuck on something. Also I use 4D Systems LCD screens via serial coms to the Arduino, I also want to make sure this is still possible with the Expressif boards.
At the moment I have a uLCd-35DT LCD screen connected to a Uno and has been working fine for a number of months now.
As a slot car enthusiast I am designing and building a new track. There are a few straight sections where I want to measure and display the time taken to race down the straight and the speed and display this on a small LCD screen at the end of the straight. The hardware is designed and needs to be built and tested for interfacing to a micro, parts are coming and will test this part soon.
As for the LCD to use, I don’t know yet. I imagine I could use the ESP32 serial port to communicate to the LCD screen or even the IC2 bus. I think both of these options are do-able, I will need to investigate.
There are other fancy things I would like to add, just as a LED light show programmed within the ESP32 and communicating to a smart LED light strip, street lighting, building lighting etc.
Perhaps an operational Ferris wheel, it’s all up to the imagination really.
Okay, that sort of screen should work with a NodeMCU. Personally, I prefer the Nextion screens, but it seems that they are similar.
You might want to look at what some of the model railway enthusiasts do. @Lichtsignaal is one of the community regulars that spring to mind.
I’d probably use separate MCUs to do individual jobs, like your speed sensor with display. These may not even need to link to Blynk is you don’t need them to.
My approach with this type of automation project is to use MQTT and Node-Red, which simplifies integration between devices and allows the Node-red server to act as a gateway to Blynk and other automation systems like Amazon Alexa.
I’d probably use loose MCU’s like the Nano and so on to control individual things, most certainly a simple job like LED’s and a Ferris wheel (nice one! I once made a flying hot air balloon in 1/87 scale) all connected together with I2C for ease of use and use one or two ESP32’s to control all the individual (cheap) MCU’s.
You may want to start with a block diagram of what to control, come to think of it.
I might have created some confusion. I did create a garden watering system using the Uno and a 4D systems LCd screen. It works fine. My next step to this project was to control the Uno via Wifi from my smartphone, hence why I started looking at Blynk, Blynk appears easy and simple to use. Yes, I will need to do a bit more coding in the Uno, but that’s OK.
As far as the slot cars go I was not intending this to be an Iot project. I am tossing up whether to make the individual units on the slot cars standalone or networked. Perhaps it’s simpler to make them standalone and network them later on.