Robotdyn atmega328 uno r3 + Wifi. How to use it?

Juraj:
use the WiFiEsp library, but I recommend to wire the esp8266 over SoftwareSerial, to have Serial for debug prints. there is a header with esp8266 pins on the board. wire pins 6 and 7 used with SoftwareSerial in WiFiEsp examples to TX/RX on the esp8266 header

Thank you for your help.

Anyway got this working and posting data to remote server

when uploading 1,2,3,4 ON
RXTX switch at 03

#include "WiFiEsp.h"

#ifndef HAVE_HWSERIAL3
#endif

char ssid[] = "SSID";            // your network SSID (name)
char pass[] = "password";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "myserver";
const String URI PROGMEM = "/api/exee/UpdatePowerConsumption";

// Initialize the Ethernet client object
WiFiEspClient client;
int amps;
void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial3);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");

  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  amps = analogRead(A0);
  String tempData = "";
  tempData.concat("{\"AccessToken\" : \"");
  tempData.concat("AccessToken");
  tempData.concat("\",\"LocationCode\" : \"");
  tempData.concat("L001");
  tempData.concat("\",\"TotalConsumption\" :\"");
  tempData.concat(amps);
  tempData.concat("\"}");
  Serial.println(tempData);

  if (client.connect(server, 80)) {
    Serial.println(F("con..."));
    // send the HTTP GET request:
    client.println("POST " + URI + " HTTP/1.1");
    client.println("Host: " + String(server));
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    client.println(tempData.length());
    client.println();
    client.println(tempData);
    // note the time that the connection was made:

  } else {
    // if you couldn't make a connection:
    Serial.println(F("con failed"));
  }

}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

thilinag:
Thank you for your help.

Anyway got this working and posting data to remote server

when uploading 1,2,3,4 ON
RXTX switch at 03

#include "WiFiEsp.h"

#ifndef HAVE_HWSERIAL3
#endif

char ssid = "SSID";            // your network SSID (name)
char pass = "password";        // your network password
int status = WL_IDLE_STATUS;    // the Wifi radio's status

char server = "myserver";
const String URI PROGMEM = "/api/exee/UpdatePowerConsumption";

// Initialize the Ethernet client object
WiFiEspClient client;
int amps;
void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial3);

// check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

// attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

// you're connected now, so print out the data
  Serial.println("You're connected to the network");

printWifiStatus();

Serial.println();
  Serial.println("Starting connection to server...");
  amps = analogRead(A0);
  String tempData = "";
  tempData.concat("{"AccessToken" : "");
  tempData.concat("AccessToken");
  tempData.concat("","LocationCode" : "");
  tempData.concat("L001");
  tempData.concat("","TotalConsumption" :"");
  tempData.concat(amps);
  tempData.concat(""}");
  Serial.println(tempData);

if (client.connect(server, 80)) {
    Serial.println(F("con..."));
    // send the HTTP GET request:
    client.println("POST " + URI + " HTTP/1.1");
    client.println("Host: " + String(server));
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    client.println(tempData.length());
    client.println();
    client.println(tempData);
    // note the time that the connection was made:

} else {
    // if you couldn't make a connection:
    Serial.println(F("con failed"));
  }

}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

// if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

// do nothing forevermore
    while (true);
  }
}

void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

// print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

// print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

you have an Uno? Uno doesn't have Serial3

Juraj:
you have an Uno? Uno doesn't have Serial3

sorry my bad it is a Mega

actually my board is
MEGA+WiFi R3 ATmega2560+ESP8266, flash 32MB

thilinag:
sorry my bad it is a Mega

actually my board is
MEGA+WiFi R3 ATmega2560+ESP8266, flash 32MB

ok. then Serial3 it is

This is by far the most useful information I can find about getting the boards with a mega chip and a esp8266 chip to work. But for me it is still not working.

I have the same board as Thilinag: the RobotDyn MEGA+WiFi R3 ATmega2560+ESP8266, flash 32MB, USB-TTL CH340G, Micro-USB. When I upload the code from Thilinag to the ATmega2560 chip with DIPs 1,2,3,4 on ON and the RXTX switch on 3 I get this error in my serial:

14:48:51.749 -> AV⸮[WiFiEsp] Initializing ESP module
14:48:53.568 -> [WiFiEsp] >>> TIMEOUT >>>
14:48:55.545 -> [WiFiEsp] >>> TIMEOUT >>>
14:48:57.563 -> [WiFiEsp] >>> TIMEOUT >>>
14:48:59.573 -> [WiFiEsp] >>> TIMEOUT >>>
14:49:01.573 -> [WiFiEsp] >>> TIMEOUT >>>
14:49:02.569 -> [WiFiEsp] Cannot initialize ESP module
14:49:08.572 -> [WiFiEsp] >>> TIMEOUT >>>
14:49:08.572 -> [WiFiEsp] No tag found
14:49:08.572 -> WiFi shield not present

Although I have a new board and never uploaded something to the ESP8266 chip is my firmware not good?

Should I install/flash new firmware? Is it also possible to do it from a Macbook? To update/flash the firmware the DIPS 5,6,7 should be ON? Or should other pins be connected?

do you set the WiFiEsp library to use Serial3?

you could try my library
here are the instructions including how to flash the AT firmware

for this board I recommend not to switch the dip switches to often. they break after time. put some firmware in esp8266 and use the corresponding networking library in ATmega. or if you write a sketch for esp8266, then add ArduinoOTA library to the sketch and upload from IDE to esp8266 over WiFi.

Juraj:
do you set the WiFiEsp library to use Serial3?

I did not change anything at the WiFiEsp library. How do I change it to Serial3?
I could not find it at wifiesp.h and wifiesp.cpp. Where do I have to look?

Juraj:
you could try my library
here are the instructions including how to flash the AT firmware
WiFiEspAT/README.md at master · jandrassy/WiFiEspAT · GitHub

for this board I recommend not to switch the dip switches to often. they break after time. put some firmware in esp8266 and use the corresponding networking library in ATmega. or if you write a sketch for esp8266, then add ArduinoOTA library to the sketch and upload from IDE to esp8266 over WiFi.

Thanks for the tips. I will look into it after I have the above example working and I can upload the data from 6 analog pins. But with the Atmega2560 the pins can be at 1,2,3,4 on ON when I use it as an Arduino Mega with wifi.

MacQwerty:
I did not change anything at the WiFiEsp library. How do I change it to Serial3?
I could not find it at wifiesp.h and wifiesp.cpp. Where do I have to look?

not in library. I don't see your sketch, but the examples have WiFi.init(&Serial1) and you want to have WiFi.init(&Serial3)

MacQwerty:
Thanks for the tips. I will look into it after I have the above example working and I can upload the data from 6 analog pins. But with the Atmega2560 the pins can be at 1,2,3,4 on ON when I use it as an Arduino Mega with wifi.

yes, but to upload to esp8266 you may want to connect it to USB chip. better option is to use the SerialPassthrough sketch in ATmega

I have WiFi.init(&Serial3)
I used the script above from thilinag he posted on june 12th 2019.

#include "WiFiEsp.h"

#ifndef HAVE_HWSERIAL3
#endif

char ssid[] = "SSID";            // your network SSID (name)
char pass[] = "password";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "myserver";
const String URI PROGMEM = "/api/exee/UpdatePowerConsumption";

// Initialize the Ethernet client object
WiFiEspClient client;
int amps;
void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial3);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");

  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  amps = analogRead(A0);
  String tempData = "";
  tempData.concat("{\"AccessToken\" : \"");
  tempData.concat("AccessToken");
  tempData.concat("\",\"LocationCode\" : \"");
  tempData.concat("L001");
  tempData.concat("\",\"TotalConsumption\" :\"");
  tempData.concat(amps);
  tempData.concat("\"}");
  Serial.println(tempData);

  if (client.connect(server, 80)) {
    Serial.println(F("con..."));
    // send the HTTP GET request:
    client.println("POST " + URI + " HTTP/1.1");
    client.println("Host: " + String(server));
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    client.println(tempData.length());
    client.println();
    client.println(tempData);
    // note the time that the connection was made:

  } else {
    // if you couldn't make a connection:
    Serial.println(F("con failed"));
  }

}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

I only changed the two lines with char ssid and char pass with my own said and password.
I used a brand new RobotDyn Mega + Wifi R3 mega2560 esp8266 32mb.

try with SerialPassthrough sketch from Examples and Serial Monitor.

in the SerialPassthrough change the baud rate to 115200 and Serial1 to Serial3.
then open the Serial Monitor, set 115200 baud and both line ends.
then send AT

also you can try to set in SerialPassthrough the baud rate for Serial3 to 74880. then you will see in Serial Monitor the boot log of the esp8266. don't change to 74880 Serial and Serial Monitor

I tried the SerialPassThrough sketch from 04.communications at examples and edited it to:

void setup() {
  Serial.begin(115200);
  Serial3.begin(115200);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial3.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (Serial3.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(Serial3.read());   // read it and send it out Serial (USB)
  }
}

But nothing happens. My Serial Monitor is empty and stays empty when I write AT. When I changed Serial3.begin(115200); to Serial3.begin(74880); also nothing happened in my Serial Monitor when it was “Both NL & CR” “115200 baud”

MacQwerty:
When I changed Serial3.begin(115200); to Serial3.begin(74880); also nothing happened in my Serial Monitor when it was "Both NL & CR" "115200 baud"

you would need to reset the esp8266 to see the boot log

so flash the AT firmware

For doing that. I should use an windows PC? Then I have to go to a friend an make a list what to do.

1.) Use Flash Download Tools from espressif.com
2.) Use firmware ESP8266 NONOS SDK V1.5.4 from sdks-demos
3.) Connect Mega+wifi board with usb to PC and have DIP-Switch 6,7,8 ON.
4.) Flash it.

After flashing change DIP-switch to 1,2,3,4 ON
Power on and open serial monitor? (I have already the last sketch on the ATmega2560)

use esptool.py

I got an windows PC. Installed Flash Downlood Tools and downloaded two firmware zip files and flashed it.

I have attached two images. One photo of the esp8266 download tool en an screenshot of my Arduino Serial Monitor with in the background the used sketch.

The serial monitor gives the values AT and AT+RST in the serial monitor. But when I type AT+GST and hit the send button: nothing happens. (with the serial3.begin(74880))

What is going on? I also tried the arduino sketch to use wifi. But still the same error.

Edit: now with all baudrates at 115200. I can write AT, AT+RST or AT+GST. But I get different results in the serial monitor:

21:48:27.592 -> R
21:50:04.839 -> AAT
21:50:24.360 -> h
21:50:39.914 -> AT+GST
21:50:45.554 -> AT+GS
21:50:55.158 -> AT+RST
⸮AT+RST
⸮AT+GST
21:51:39.837 -> A⸮%⸮j⸮⸮⸮
21:52:02.964 -> AT+RS
21:52:10.623 -> AT+GST
21:52:21.006 -> ⸮AT
21:52:25.396 -> A⸮
⸮

Later I tried my second Mega + Wifi board. And suddenly it is giving a response to AT commands:

22:18:07.050 -> AT

22:18:07.050 ->
22:18:07.050 -> OK
22:18:19.583 -> AT+GST

22:18:19.583 ->
22:18:19.583 -> ERROR
22:18:23.442 -> AT

22:18:23.442 ->
22:18:23.442 -> OK
22:18:36.440 -> AT+RST

22:18:36.440 ->
22:18:36.440 -> OK
22:18:36.548 ->
22:18:36.548 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
22:18:36.548 ->
22:18:36.548 -> load 0x40100000, len 1856, room 16
22:18:36.548 -> tail 0
22:18:36.548 -> chksum 0x63
22:18:36.548 -> load 0x3ffe8000, len 776, room 8
22:18:36.586 -> tail 0
22:18:36.586 -> chksum 0x02
22:18:36.586 -> load 0x3ffe8310, len 552, room 8
22:18:36.586 -> tail 0
22:18:36.586 -> chksum 0x79
22:18:36.586 -> csum 0x79
22:18:36.586 ->
22:18:36.586 -> 2nd boot version : 1.5
22:18:36.586 -> SPI Speed : 40MHz
22:18:36.586 -> SPI Mode : QIO
22:18:36.586 -> SPI Flash Size & Map: 32Mbit(512KB+512KB)
22:18:36.586 -> jump to run user1 @ 1000
22:18:36.586 ->
22:18:36.803 -> ⸮⸮s⸮l⸮l⸮ l⸮⸮r⸮l⸮l⸮ l⸮⸮r⸮l ⸮⸮⸮ ll`sl⸮⸮⸮
22:18:36.837 -> ready
22:19:09.040 -> AT+GST

22:19:09.040 ->
22:19:09.040 -> ERROR
22:19:15.177 -> AT+RST

22:19:15.177 ->
22:19:15.177 -> OK
22:19:15.323 ->
22:19:15.323 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
22:19:15.323 ->
22:19:15.323 -> load 0x40100000, len 1856, room 16
22:19:15.323 -> tail 0
22:19:15.323 -> chksum 0x63
22:19:15.323 -> load 0x3ffe8000, len 776, room 8
22:19:15.323 -> tail 0
22:19:15.323 -> chksum 0x02
22:19:15.323 -> load 0x3ffe8310, len 552, room 8
22:19:15.323 -> tail 0
22:19:15.323 -> chksum 0x79
22:19:15.359 -> csum 0x79
22:19:15.359 ->
22:19:15.359 -> 2nd boot version : 1.5
22:19:15.359 -> SPI Speed : 40MHz
22:19:15.359 -> SPI Mode : QIO
22:19:15.359 -> SPI Flash Size & Map: 32Mbit(512KB+512KB)
22:19:15.359 -> jump to run user1 @ 1000
22:19:15.359 ->
22:19:15.575 -> ⸮⸮s⸮l⸮l⸮ l⸮⸮s⸮l⸮l⸮ l⸮⸮r⸮l ⸮⸮⸮ ll`sl⸮⸮⸮
22:19:15.611 -> ready

Do you understand it?

what version of the AT firmware did you flash? you should use 32Mb-C1 and the '1024' bin and addresses

I did 32Mb without the C1 and 512 user1. One board did work, the other did not.
With 1024 user1 now both work. Now I know how to do it. I will try the 32Mb-C1 version when I have the time. But what difference does it make? I also see people flash with user1 and user2. I have the robotdyn mega wifi now working with 32Mb and user1.512 or user1.1024.

Thank you juraj for your help. I can now continue to the next fase and get all my sensors connected to the Mega board.

C1 is different partitioning of the flash memory. it should be used with the 1024 version of bin.

Hello,

So my Uno r3 + WIFI just arrived. (not the mega)

After reading a lot it seems the conclusion is that even though I got everything on one board I have to use a breadboard to make a voltage divider (or use a voltage level shifter) and use software serial if I want to see the serial output of the ATmega so I can debug en see what is going on and have the ATmega talk to the ESP?

That really feels like some one missed a point some where? Or is that some one me and am I missing something?

The only advantage this board than has is the extra esp pins and a wifi antenna connector?

Something else. if I set the dipswiches to "ESP8266 (connect) OFF OFF OFF OFF ON ON OFF NoUSE" I expected to beable to send AT commands. Instead I see a . (dot) send every second or so if I set serial on the laptop to 9600. I asume that the esp is sending this as a hard beat? But that must mean there is no AT firmware by default?